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

# Claude Code

> Connect Claude Code to PipeLLM with Anthropic-compatible routing

For routing rules, see [Routing & Protocols](/guides/routing-protocols). For
available model IDs, see [List Models](/api-reference/list-models).

Claude Code works with Anthropic Messages-compatible gateways. PipeLLM supports
that in two ways:

| Use case                             | Base URL                           | Why                                             |
| ------------------------------------ | ---------------------------------- | ----------------------------------------------- |
| Call Claude models                   | `https://api.pipellm.ai`           | Use PipeLLM's native Anthropic-compatible route |
| Keep Claude Code, call GPT or Gemini | `https://api.pipellm.ai/anthropic` | Use the Anthropic converter route               |

## Config File

Claude Code reads configuration from `~/.claude/settings.json`.

<Warning>
  Remove conflicting shell variables before testing a new setup, especially
  `ANTHROPIC_BASE_URL`, `ANTHROPIC_API_KEY`, and `ANTHROPIC_AUTH_TOKEN`.
</Warning>

## Recommended Setup

<Tabs>
  <Tab title="Claude Models">
    ```json theme={null}
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.pipellm.ai",
        "ANTHROPIC_AUTH_TOKEN": "your-pipellm-api-key",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-latest"
      }
    }
    ```
  </Tab>

  <Tab title="GPT or Gemini Models">
    ```json theme={null}
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.pipellm.ai/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "your-pipellm-api-key",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-4o",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-4o-mini"
      }
    }
    ```

    You can swap the model IDs for other PipeLLM models such as
    `gemini-2.5-pro` or `gemini-2.5-flash`.
  </Tab>
</Tabs>

## Run Claude Code

```bash theme={null}
claude
```

If you want to keep a checked-in project config instead of editing your global
settings, keep the same `env` block in the settings file that Claude Code reads
for your environment.

## Notes

* Claude Code expects Anthropic Messages-compatible endpoints such as
  `/v1/messages`.
* PipeLLM's native route is the cleanest choice for Claude models.
* PipeLLM's `/anthropic` converter route is the safest way to keep Claude Code's
  protocol while switching to OpenAI or Gemini models.

## Related Docs

<Columns cols={3}>
  <Card title="Developer Tools" icon="terminal" href="/integrations/overview">
    Compare Claude Code, OpenCode, and OpenClaw
  </Card>

  <Card title="Anthropic Converter" icon="shuffle" href="/converter/anthropic-format">
    Keep Anthropic format across providers
  </Card>

  <Card title="Claude Code Gateway Docs" icon="book" href="https://code.claude.com/docs/en/llm-gateway">
    Official Claude Code gateway requirements
  </Card>
</Columns>
