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

# Claude Code

> Point Claude Code at RunInfra's Anthropic-compatible Messages API with one hosted model id.

Claude Code can use RunInfra through the Anthropic-compatible Messages API. Set the API host, your workspace key, and one RunInfra model id before you start `claude`.

<Note>
  This integration uses RunInfra hosted models. It does not make those models identical to Anthropic models.
</Note>

## Configure the environment

Use a model whose page lists tool calling. This example uses `deepseek-v4-flash` for the main session, model aliases, and subagents.

<CodeGroup>
  ```bash macOS and Linux theme={"dark"}
  export RUNINFRA_GATEWAY_KEY="rp_your_key_here"
  export ANTHROPIC_BASE_URL="https://api.runinfra.ai"
  export ANTHROPIC_AUTH_TOKEN="$RUNINFRA_GATEWAY_KEY"

  export ANTHROPIC_MODEL="deepseek-v4-flash"
  export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-flash"
  export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-flash"
  export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
  export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"

  claude
  ```

  ```powershell PowerShell theme={"dark"}
  $env:RUNINFRA_GATEWAY_KEY = "rp_your_key_here"
  $env:ANTHROPIC_BASE_URL = "https://api.runinfra.ai"
  $env:ANTHROPIC_AUTH_TOKEN = $env:RUNINFRA_GATEWAY_KEY

  $env:ANTHROPIC_MODEL = "deepseek-v4-flash"
  $env:ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek-v4-flash"
  $env:ANTHROPIC_DEFAULT_OPUS_MODEL = "deepseek-v4-flash"
  $env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "deepseek-v4-flash"
  $env:CLAUDE_CODE_SUBAGENT_MODEL = "deepseek-v4-flash"

  claude
  ```
</CodeGroup>

`ANTHROPIC_BASE_URL` must be the bare host. Claude Code and the Anthropic SDK append `/v1`.

`ANTHROPIC_AUTH_TOKEN` sends Bearer authentication and does not trigger the API-key approval prompt. You can set `ANTHROPIC_API_KEY` instead. It sends `x-api-key`, which works on the Messages routes, but Claude Code prompts once to approve the custom key.

## Optional controls

| Variable                | When to set it                                                                       |
| ----------------------- | ------------------------------------------------------------------------------------ |
| `API_TIMEOUT_MS`        | Increase the request timeout for long tasks. Choose a value that fits your workload. |
| `MAX_THINKING_TOKENS=0` | Make Claude Code omit the `thinking` field when you do not want it sent.             |

You do not need `DISABLE_PROMPT_CACHING`. Claude Code may send `cache_control`, and the Messages API accepts and ignores it. Prefix caching remains automatic on models with cached-input pricing.

## What works

* Multi-tool sessions using client tools that Claude Code executes.
* Subagents using the model selected by `CLAUDE_CODE_SUBAGENT_MODEL`.
* Streaming through the official Anthropic SDK helpers.
* Thinking display when the selected model returns reasoning.

Anthropic server tools are not available. RunInfra supports the client-tool loop used by Claude Code, not hosted bash, text editor, web search, or computer-use tools supplied by an API provider.

## What to expect

Claude Code can print a diagnostic line that it does not recognize the RunInfra model id. The line is harmless when requests continue successfully.

Set model ids through the environment variables above. Do not use `/model` to select a RunInfra id because that picker knows Anthropic's model catalog, not the ids available from RunInfra.

If you need to discover model ids, use Bearer authentication. `x-api-key` is limited to `/v1/messages` and `/v1/messages/count_tokens`.

```bash theme={"dark"}
curl https://api.runinfra.ai/v1/models \
  -H "Authorization: Bearer $RUNINFRA_GATEWAY_KEY"
```

## Check usage and credits

See settled usage in the dashboard's usage page. Read the current workspace balance from `GET /v1/credits`:

```bash theme={"dark"}
curl https://api.runinfra.ai/v1/credits \
  -H "Authorization: Bearer $RUNINFRA_GATEWAY_KEY"
```

## Related

<Columns cols={3}>
  <Card title="Anthropic Messages" icon="messages-square" href="/docs/api-reference/anthropic-messages">
    Read the request, tool, thinking, stream, and error contract.
  </Card>

  <Card title="Authentication" icon="key" href="/docs/api-reference/authentication">
    Understand Bearer and `x-api-key` scope.
  </Card>

  <Card title="Models" icon="list" href="/docs/api-reference/models">
    List the model ids available to your key.
  </Card>
</Columns>
