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

# Coding Agent Model Selection

> Choose the right model for each coding task — comparison table, recommendations, and configuration

## Model Comparison for Coding

| Model                    | Speed     | Code Quality | Cost     | Context Window | Best For                          |
| ------------------------ | --------- | ------------ | -------- | -------------- | --------------------------------- |
| `claude-opus-4-6`        | Moderate  | Excellent    | \$\$\$\$ | 200K           | Architecture, complex refactoring |
| `gpt-5.4`                | Moderate  | Excellent    | \$\$\$\$ | 200K           | Complex reasoning, planning       |
| `claude-sonnet-4-6`      | Fast      | Very Good    | \$\$\$   | 200K           | General coding, reviews           |
| `gemini-3.1-pro-preview` | Fast      | Very Good    | \$\$\$   | 1M             | Large codebase analysis           |
| `gpt-5-mini`             | Very Fast | Good         | \$\$     | 128K           | Quick edits, completions          |
| `gemini-3.5-flash`       | Very Fast | Good         | \$\$     | 1M             | Fast iteration, search            |
| `deepseek-v4-pro`        | Moderate  | Very Good    | \$       | 1M             | Reasoning-heavy tasks             |
| `deepseek-v4-flash`      | Fast      | Good         | \$       | 1M             | Bulk generation, boilerplate      |

For the newer coding-oriented pool, also consider `qwen-long-latest` for very large repositories, `minimax-m3` for large-context agent work, `kimi-k2.7-code-highspeed` for fast coding loops, and `deepseek-v4-pro` / `deepseek-v4-flash`, `glm-5.2`, `step-3.7-flash`, and `mimo-v2.5-pro` for OpenAI-compatible chat requests.

## Task-Specific Recommendations

<AccordionGroup>
  <Accordion title="Code Generation / Scaffolding">
    **Recommended**: `claude-sonnet-4-6`, `gemini-3.1-pro-preview`

    These models produce clean, well-structured code with good naming conventions. For complex multi-file scaffolding, consider `claude-opus-4-6`.

    Budget alternative: `deepseek-v4-flash` handles boilerplate well at a fraction of the cost.
  </Accordion>

  <Accordion title="Code Review / Refactoring">
    **Recommended**: `claude-sonnet-4-6`, `deepseek-v4-pro`

    Code review benefits from reasoning ability. `deepseek-v4-pro` is particularly cost-effective here — its chain-of-thought approach catches subtle issues.

    For security-focused reviews: `claude-opus-4-6` or `gpt-5.4`.
  </Accordion>

  <Accordion title="Bug Fixing / Debugging">
    **Recommended**: `claude-sonnet-4-6`, `gpt-5-mini`

    Bug fixing is usually well-scoped — you know what's broken. Standard-tier models handle this well. Use premium models only for complex, multi-file bugs.
  </Accordion>

  <Accordion title="Architecture Design">
    **Recommended**: `claude-opus-4-6`, `gpt-5.4`

    Architecture decisions benefit from the strongest reasoning. Worth the premium cost since these decisions are infrequent but high-impact.
  </Accordion>

  <Accordion title="Quick Edits / Tab Completion">
    **Recommended**: `gpt-5-mini`, `gemini-3.5-flash`

    Speed is critical for interactive use. Budget models with fast response times provide the best experience. Don't waste premium tokens on autocomplete.
  </Accordion>
</AccordionGroup>

## Provider Selection

TokenLab selects an available provider for the requested model automatically.

### Selection Strategies

| Strategy     | Behavior                                     | Best For            |
| ------------ | -------------------------------------------- | ------------------- |
| **PRIORITY** | Uses the highest-priority available provider | Reliability-focused |
| **COST**     | Uses the lowest-cost available provider      | Cost-focused        |

You can set your preferred strategy in the dashboard.

### Automatic Retry

If a provider is unavailable or returns an error, TokenLab automatically retries with another available provider:

```
Request: claude-sonnet-4-6
  → Provider A (primary): 503 error
  → Provider B (retry): ✓ Success
```

This happens transparently — your coding agent sees a normal response.

### Native API Formats

When the selected model supports a native API format, TokenLab can use that format for better compatibility:

| Model Family | API Format         | Base URL                                                                               |
| ------------ | ------------------ | -------------------------------------------------------------------------------------- |
| Claude       | Anthropic Messages | `https://api.tokenlab.sh`                                                              |
| GPT          | OpenAI Responses   | `https://api.tokenlab.sh/v1`                                                           |
| Gemini       | Gemini Native API  | `https://api.tokenlab.sh` or `https://api.tokenlab.sh/v1beta` depending on client path |
| DeepSeek     | OpenAI Chat        | `https://api.tokenlab.sh/v1`                                                           |

Claude Code is a strong native Anthropic path. Gemini-native APIs exist too, but Gemini CLI itself remains a best-effort compatibility path rather than a guaranteed long-term workflow.

## Configuration per Tool

<AccordionGroup>
  <Accordion title="Claude Code">
    ```bash theme={null}
    export ANTHROPIC_API_KEY="sk-your-tokenlab-key"
    export ANTHROPIC_BASE_URL="https://api.tokenlab.sh"
    ```

    Select model: `claude --model claude-sonnet-4-6`

    [Full guide →](/integrations/claude-code)
  </Accordion>

  <Accordion title="Cursor">
    In Settings → Models:

    * API Key: `sk-your-tokenlab-key`
    * Base URL: `https://api.tokenlab.sh/v1`
    * Model: `claude-sonnet-4-6` or `gpt-5-mini`

    [Full guide →](/integrations/cursor)
  </Accordion>

  <Accordion title="Codex CLI">
    ```bash theme={null}
    export OPENAI_API_KEY="sk-your-tokenlab-key"
    export OPENAI_BASE_URL="https://api.tokenlab.sh/v1"
    ```

    [Full guide →](/integrations/codex-cli)
  </Accordion>

  <Accordion title="Gemini CLI">
    ```bash theme={null}
    export GEMINI_API_KEY="sk-your-tokenlab-key"
    export GOOGLE_GEMINI_BASE_URL="https://api.tokenlab.sh"
    ```

    Treat this as best-effort compatibility rather than an official Gemini CLI integration.

    [Full guide →](/integrations/gemini-cli)
  </Accordion>

  <Accordion title="OpenCode">
    ```json theme={null}
    {
      "provider": "openai",
      "apiKey": "sk-your-tokenlab-key",
      "baseURL": "https://api.tokenlab.sh/v1"
    }
    ```

    [Full guide →](/integrations/opencode)
  </Accordion>
</AccordionGroup>
