KnowledgeTogether AI

How Together AI works

Together AI makes it easy to run leading open-source models using only a few lines of code. The platform provides fast inference, OpenAI-compatible APIs, and access to cutting-edge models like Llama 4, DeepSeek, and more. Built for developers who need reliable, scalable AI infrastructure without the complexity.

We recommend good coding models with high context windows and competitive pricing.

For the most updated information, please visit Together AI’s pricing page.

ModelPricing (1M tokens)Context Window
Llama 4 Maverick recommended$0.27/$0.85~128k tokens
DeepSeek-V3$1.25~128k tokens
Llama 3.1 70B Turbo$0.88~128k tokens
Qwen 2.5 72B$1.20~128k tokens

Creating API Key

Together AI Account is required to create API Key.

Go directly to Together AI Console to create a new API Key.

Or, follow these steps:

  1. Create an account at api.together.ai or log in if you have one already
  2. In the main dashboard, scroll down to the “Manage Account” section
  3. In the “API Keys” card, click on “Manage Keys” button
  4. Click on “Add Key” button
  5. Give it a name like ‘Mesrai’ or any descriptive name
  6. Copy your API key, and you’re ready to go!

New accounts come with $1 credit to get started for free.

How to use

System Requirements

Recommended Hardware

Sized for the default local sandbox mode (mesrai-graph + cross-file context run inside the worker container).

  • CPU: 2+ cores (4+ recommended for repos above ~100k LOC)
  • RAM: 8GB+ (16GB recommended when running the local sandbox on large repos)
  • Storage: 60GB+ free space (Postgres holds the AST graph cache; grows with repo count and PR volume)
Required Software
  • Docker (latest stable) with the Compose plugin
  • Domain name or fixed IP if you want to receive Git webhooks from cloud providers (GitHub.com, GitLab.com, etc.)
Required Ports

Default host port mappings — adjust in .env if any conflict.

  • 3000 — Mesrai Web App
  • 3001 — API
  • 3332 — Webhooks
  • 5432 — PostgreSQL
  • 27017 — MongoDB
  • 5672, 15672, 15692 — RabbitMQ (AMQP, management UI, metrics)
  • 3101 — MCP Manager (only if API_MCP_SERVER_ENABLED=true)
Services

What ./scripts/install.sh brings up, based on your .env.

Core (always on):

  • api — main backend
  • worker — code-review jobs
  • webhooks — Git provider webhook receiver
  • mesrai-web — Next.js frontend
  • db_mesrai_postgres, db_mesrai_mongodb, rabbitmq — local infrastructure. Skip with USE_LOCAL_DB=false / USE_LOCAL_RABBITMQ=false to point at managed instances.

Optional:

  • mesrai-mcp-manager — Model Context Protocol broker. Enable with API_MCP_SERVER_ENABLED=true. See MCP Manager.
  • worker-analytics — Cockpit ingestion (DORA metrics, PR classifier). Self-hosted Enterprise only, not wired by default. See Analytics Worker.

Code review uses an AST graph + cross-file context that runs in a sandbox — local (default, runs inside the worker) or e2b (paid remote sandbox). See Sandbox & AST Graph for the modes, caching behavior, and when to pick each.

Internet access is required if you plan to connect to cloud-based Git services (GitHub, GitLab, Bitbucket) or cloud LLM providers (OpenAI, Anthropic, etc.). For self-hosted Git tools and on-prem LLMs within your network, external internet access is optional.

Domain Name Setup (Optional)

If you’re planning to integrate Mesrai with cloud-based Git providers (GitHub, GitLab, or Bitbucket), you’ll need public-facing URLs for both the Mesrai Web App and its API. This allows your server to receive webhooks for proper Code Review functionality and ensures correct application behavior.

We recommend setting up two subdomains:

  • One for the Web Application, e.g., mesrai-web.yourdomain.com.
  • One for the API, e.g., mesrai-api.yourdomain.com.

Webhooks are handled by a separate service (port 3332). You can either:

  • Use a dedicated webhooks subdomain, e.g., mesrai-webhooks.yourdomain.com, or
  • Keep using the API domain and route /github/webhook, /gitlab/webhook, etc. to the webhooks service in your reverse proxy.

Both subdomains should have DNS A records pointing to your server’s IP address. Later in this guide, we will configure a reverse proxy (Nginx) to route requests to these subdomains to the correct internal services. This setup is essential for full functionality, including webhooks and authentication.

Note: If you’re only connecting to self-hosted Git tools on your network and do not require public access or webhooks, you might be able to use a simpler setup, but this guide focuses on public-facing deployments.

Setup

  1. 1

    Clone the installer repository

    git clone https://github.com/mesraiofficial/mesrai-installer.git
    cd mesrai-installer
  2. 2

    Copy the example environment file

    cp .env.example .env
  3. 3

    Generate secure keys for the required environment variables

    ./generate-keys.sh
  4. 4

    Edit the environment file

    Edit .env with your values using your preferred text editor.

    nano .env

    See Environment Variables Configuration for detailed instructions.

  5. 5

    Run the installer

    ./scripts/install.sh
  6. 6

    Success 🎉

    When complete, Mesrai Services should be running on your machine. You can verify your installation using the following script:

    ./scripts/doctor.sh
  7. 7

    Access the web interface

    Once you access the web interface for the first time, you’ll need to:

    1. Create your admin account - This will be the first user with full system access
    2. Configure your Git provider - Connect GitHub, GitLab, or Bitbucket following the on-screen instructions
    3. Select repositories for analysis - Choose which code repositories Mesrai will review

    For detailed steps on the initial configuration process, refer to our Getting Started Guide.

Configure Together AI in Environment File

Edit your .env file and configure the core settings. For LLM Integration, use Together AI in Fixed Mode:

# Core System Settings (update with your domains)
WEB_HOSTNAME_API="mesrai-api.yourdomain.com"    
WEB_PORT_API=443                               
NEXTAUTH_URL="https://mesrai-web.yourdomain.com"

# Security Keys (generate with openssl commands above)
WEB_NEXTAUTH_SECRET="your-generated-secret"
API_CRYPTO_KEY="your-generated-hex-key"
API_JWT_SECRET="your-generated-secret"
API_JWT_REFRESH_SECRET="your-generated-secret"

# Database Configuration
API_PG_DB_PASSWORD="your-secure-db-password"
API_MG_DB_PASSWORD="your-secure-db-password"

# Together AI Configuration (Fixed Mode) 
API_LLM_PROVIDER_MODEL="meta-llama/Meta-Llama-4-Maverick-Instruct"  # Choose your preferred model
API_OPENAI_FORCE_BASE_URL="https://api.together.xyz/v1"             # Together AI API URL  
API_OPEN_AI_API_KEY="your-together-api-key"                         # Your Together AI API Key

# Git Provider Webhooks (choose your provider)
API_GITHUB_CODE_MANAGEMENT_WEBHOOK="https://mesrai-api.yourdomain.com/github/webhook"
# or API_GITLAB_CODE_MANAGEMENT_WEBHOOK="https://mesrai-api.yourdomain.com/gitlab/webhook"
# or GLOBAL_BITBUCKET_CODE_MANAGEMENT_WEBHOOK="https://mesrai-api.yourdomain.com/bitbucket/webhook"

Webhook URLs must reach the Webhooks service (port 3332). Use a dedicated webhooks domain or route /.../webhook to port 3332 in your reverse proxy.

Fixed Mode is ideal for Together AI because it provides OpenAI-compatible APIs with competitive pricing and access to cutting-edge open-source models.

Run the Installation Script

Looking for more control? Check out our docker-compose file for manual deployment options.

Set the proper permissions for the installation script:

chmod +x scripts/install.sh

Run the script:

./scripts/install.sh

What the Installer Does

Our installer automates several important steps:

  • Verifies Docker installation
  • Creates networks for Mesrai services
  • Clones repositories and configures environment files
  • Runs docker-compose to start all services
  • Executes database migrations
  • Seeds initial data

🎉 Success! When complete, the Mesrai Web App and backend services (API, worker, webhooks, MCP manager) should be running on your machine.

You can verify your installation by visiting http://localhost:3000 - you should see the Mesrai Web Application interface.

Code Review features will not work yet unless you complete the reverse proxy setup. Without this configuration, external Git providers cannot send webhooks to your instance.

Set Up Reverse Proxy (For Production)

For webhooks and external access, configure Nginx:

# Web App (port 3000)
server {
    listen 80;
    server_name mesrai-web.yourdomain.com;
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
 
# API (port 3001)  
server {
    listen 80;
    server_name mesrai-api.yourdomain.com;
    location ~ ^/(github|gitlab|bitbucket|azure-repos)/webhook {
        proxy_pass http://localhost:3332;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
 
    location / {
        proxy_pass http://localhost:3001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Verify Together AI Integration

In addition to the basic installation verification, confirm that Together AI is working:

# Verify Together AI API connection specifically
docker-compose logs api worker | grep -i together

For detailed information about SSL setup, monitoring, and advanced configurations, see our complete deployment guide.

Troubleshooting

API Key Issues
  • Verify your API key is correct and active in Together AI Console
  • Check if you have sufficient credits in your Together AI account
  • Ensure there are no extra spaces in your .env file
  • New accounts receive $1 in free credits
Model Not Found
  • Check if the model name is correctly spelled in your configuration
  • Verify the model is available in Together AI’s current model library
  • Try with a different model from our recommended list
  • Check the Together AI models documentation
Connection Errors
  • Verify your server has internet access to reach api.together.xyz
  • Check if there are any firewall restrictions
  • Review the API/worker logs for detailed error messages
  • Ensure you’re using the correct API endpoint
Rate Limiting
  • Together AI provides generous rate limits (up to 6000 requests/min for LLMs)
  • Check your current usage in the Together AI dashboard
  • Consider upgrading to a higher tier for increased limits
  • Monitor your usage patterns to optimize API calls