# Claude Code (/docs/guides/claude-code)

Run Claude Code on your cheapaimodel balance.



<Callout type="warn">
  **Not available yet.** No model in the [catalog](/models) currently lists the Anthropic Messages endpoint (`/v1/messages`), so Claude Code has no model to run on. For a coding agent today, use [Codex CLI](/docs/guides/codex-cli), [Cursor](/docs/guides/cursor) or [Cline](/docs/guides/cline). This guide applies once a model's catalog page lists `/v1/messages`.
</Callout>

Claude Code talks to the Anthropic Messages API, so it only needs a base URL and a key.

## Set it up [#set-it-up]

Add these to your shell profile (`~/.zshrc`, `~/.bashrc`), then open a new terminal and run `claude`:

```bash title="~/.zshrc"
export ANTHROPIC_BASE_URL="https://api.cheapaimodel.ai"
export ANTHROPIC_AUTH_TOKEN="sk-..."
```

`ANTHROPIC_AUTH_TOKEN` is sent as `Authorization: Bearer`. If you are signed in to a Claude subscription, run `/logout` inside Claude Code first so it uses the key.

## Use settings.json instead [#use-settingsjson-instead]

To keep the configuration with Claude Code rather than your shell, put it in `~/.claude/settings.json`:

```json title="~/.claude/settings.json"
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.cheapaimodel.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-..."
  }
}
```

## Choosing models [#choosing-models]

Claude Code resolves its `sonnet`, `opus` and `haiku` aliases to model IDs; `haiku` also runs background tasks. Point the aliases at model IDs from the [catalog](/models) that list `/v1/messages`:

```bash title="~/.zshrc"
export ANTHROPIC_DEFAULT_SONNET_MODEL="<model-id>"
export ANTHROPIC_DEFAULT_OPUS_MODEL="<model-id>"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="<model-id>"
```

`ANTHROPIC_MODEL` sets the starting model; `/model` switches during a session.

<Callout>
  Give Claude Code its own API key with a [budget](/docs/concepts/authentication#key-options) so an agent run can never spend more than you planned.
</Callout>
