> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scandrix.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Together AI Integration

> Learn how to connect Together AI's open-source inference infrastructure to ScanDrix for automated code reviews.

Together AI enables engineering teams to run top open-source coding models using an OpenAI-compatible API. The platform provides fast token generation, competitive per-token pricing, and access to leading architectures such as Llama 3.3, DeepSeek V3, and Qwen 2.5 Coder.

## Recommended models

We recommend high-performance coding models with expansive context windows:

| Model | Context Window | Speed | Best For |
| - | - | - | - |
| **`meta-llama/Llama-3.3-70B-Instruct-Turbo`** `recommended` | 128k tokens | 130+ tps | Standard PR diff analysis, syntax reviews & AST linting |
| **`deepseek-ai/DeepSeek-V3`** | 128k tokens | 110+ tps | Full architectural verification & taint analysis |
| **`deepseek-ai/DeepSeek-R1`** | 128k tokens | 70+ tps | Deep mathematical correctness, crypto & invariants |
| **`Qwen/Qwen2.5-Coder-32B-Instruct`** | 128k tokens | 160+ tps | Fast multi-language code quality inspection |

> [!NOTE]
>
> For the most up-to-date model identifiers and context limits, consult the [Together AI Models Directory](https://www.together.ai/models).

***

## Creating an API Key

> [!WARNING]
>
> A verified Together AI account is required to generate API credentials.

1. Navigate to the [Together AI Console](https://api.together.ai).
2. Sign in or create an account.
3. In the sidebar or dashboard settings, select **API Keys**.
4. Click **Create API Key**, label it `scandrix-code-review`, and copy the secret key.

> [!NOTE]
>
> New Together AI accounts receive \$1 in initial credits to test inference endpoints.

***

## Configuration options

You can configure Together AI either via the ScanDrix dashboard, in your repository's `.scandrix.yaml`, or in self-hosted backend environment variables.

### Option 1: Via the ScanDrix Dashboard (Recommended for SaaS)

1. Open the ScanDrix dashboard and navigate to **Settings → AI Providers**.
2. Click **Add Provider** and select **Together AI** (or Generic OpenAI-Compatible).
3. Set Base URL to `https://api.together.xyz/v1`.
4. Paste your Together AI API Key.
5. Select `meta-llama/Llama-3.3-70B-Instruct-Turbo` as your default review model.
6. Click **Test Connection** to send a synthetic health verification ping.

***

### Option 2: Via Repository Config (`.scandrix.yaml`)

To enforce Together AI as the review engine for a specific repository:

```yaml theme={null}
# .scandrix.yaml
version: 1

ai:
  provider: together
  endpoint: "https://api.together.xyz/v1"
  model: "meta-llama/Llama-3.3-70B-Instruct-Turbo"
  api_key: "env:TOGETHER_API_KEY"
  temperature: 0.1
  max_tokens: 4096

review:
  severity_threshold: warning
  patch_suggestions: true
```

***

### Option 3: Via Self-Hosted Backend (.env)

If deploying the self-hosted ScanDrix Go backend, configure your environment file:

```env theme={null}
# ScanDrix Core Service Configuration
PORT=8080
SCANDRIX_API_URL=https://api.scandrix.yourdomain.com
SCANDRIX_WEB_URL=https://scandrix.yourdomain.com

# Database Connection (PostgreSQL 16+)
DATABASE_URL=postgres://scandrix:yourpassword@postgres:5432/scandrix?sslmode=require

# Together AI LLM Configuration
SCANDRIX_LLM_PROVIDER=together
OPENAI_BASE_URL=https://api.together.xyz/v1
OPENAI_API_KEY=your_together_api_key_here
SCANDRIX_DEFAULT_MODEL=meta-llama/Llama-3.3-70B-Instruct-Turbo

# Webhook Secret for HMAC verification
GITHUB_WEBHOOK_SECRET=your_github_webhook_secret
```

***

## Production Reverse Proxy Setup

For self-hosted instances with external Git webhooks, configure Nginx to forward requests to the Next.js frontend (port 3000) and the Go backend API (port 8080):

```nginx theme={null}
# ScanDrix Web Dashboard (port 3000)
server {
    listen 443 ssl http2;
    server_name scandrix.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/scandrix.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/scandrix.yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1: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;
    }
}

# ScanDrix Go API & Webhooks (port 8080)
server {
    listen 443 ssl http2;
    server_name api.scandrix.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/api.scandrix.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/api.scandrix.yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8080;
        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;
    }
}
```

***

## Verifying Together AI integration

Verify that Together AI is successfully processing reviews:

```bash theme={null}
# Test local review via CLI
scandrix review --staged

# Or inspect worker container logs
docker logs scandrix-worker | grep -i "together"
```

Expected log output:

```
[INFO] provider=together model=meta-llama/Llama-3.3-70B-Instruct-Turbo latency=980ms tokens=2100 status=200
```

***

## Troubleshooting

> [accordion] Invalid API Key (HTTP 401)
>
> * Verify your API key in the [Together AI Console](https://api.together.ai).
> * Ensure your billing account or credits are active.
> * Check that no whitespace or quotation marks were accidentally appended.

> [accordion] Model Not Found (HTTP 404)
>
> * Ensure you use the exact model namespace (e.g. `meta-llama/Llama-3.3-70B-Instruct-Turbo` rather than `llama-3.3-70b`).
> * Verify that the model is enabled on Together AI's serverless endpoints.

> [accordion] Rate Limiting (HTTP 429)
>
> * Together AI provides generous default rate limits (up to several thousand requests per minute depending on tier).
> * Review active rate limits on the Together AI dashboard.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.