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

# Claude Code

> Use AnyAPI models in Claude Code — Anthropic's terminal-native AI coding agent

# Use AnyAPI in Claude Code

[Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) is Anthropic's terminal-native AI coding agent — it edits files, runs commands, and handles multi-step refactors from your terminal. Claude Code speaks the Anthropic Messages API, and AnyAPI serves that API at `https://api.anyapi.ai`, so you can point it at AnyAPI with no local proxy.

## Install Claude Code

**macOS / Linux / WSL:**

```bash theme={"system"}
curl -fsSL https://claude.ai/install.sh | bash
```

**Windows PowerShell:**

```powershell theme={"system"}
irm https://claude.ai/install.ps1 | iex
```

## Get Your API Key

Go to [API Keys](https://dash.anyapi.ai/?page=api-keys) in the AnyAPI Dashboard and create a new key.

## Configure Claude Code

Run this in your terminal to write the AnyAPI settings into `~/.claude/settings.json`. Replace `sk-your-anyapi-key` with your own key.

```bash theme={"system"}
mkdir -p ~/.claude
cat << 'EOF' > ~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.anyapi.ai",
    "ANTHROPIC_API_KEY": "sk-your-anyapi-key",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-anyapi-key",
    "ANTHROPIC_MODEL": "anthropic/claude-sonnet-4.6",
    "CLAUDE_CODE_SKIP_FAST_MODE_ORG_CHECK": "1",
    "CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"
  }
}
EOF
```

| Variable | Value |
| - | - |
| `ANTHROPIC_BASE_URL` | `https://api.anyapi.ai` |
| `ANTHROPIC_API_KEY` | Your AnyAPI key |
| `ANTHROPIC_AUTH_TOKEN` | Your AnyAPI key (same value) |
| `ANTHROPIC_MODEL` | e.g. `anthropic/claude-sonnet-4.6` |
| `CLAUDE_CODE_SKIP_FAST_MODE_ORG_CHECK` | `1` — skips the org check that expects a first-party Anthropic account |
| `CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING` | `1` — keeps thinking settings fixed instead of negotiated with Anthropic |

> [!WARNING]
>
> `~/.claude/settings.json` stores your key in plain text. The command above overwrites the file — if you already have settings there, add the `env` block by hand instead.

## Start Claude Code

```bash theme={"system"}
cd /path/to/your/project
claude
```

Check the connection inside Claude Code:

```
/status
```

The base URL should read `https://api.anyapi.ai`.

## Recommended Models

| Model | Best for |
| - | - |
| `anthropic/claude-sonnet-4.6` | Fast edits, everyday coding |
| `anthropic/claude-opus-4.6` | Complex architecture, deep reasoning |
| `moonshotai/kimi-k2.6` | Long agentic sessions |
| `deepseek/deepseek-r1` | Algorithms, math |

> [!NOTE]
>
> AnyAPI uses `provider/model` format for model IDs. Bare names like `claude-sonnet-4.6` without the vendor prefix won't work.

Browse all models at [anyapi.ai/ai-models](https://anyapi.ai/ai-models), or list them from the API:

```bash theme={"system"}
curl -sS -H "Authorization: Bearer sk-your-anyapi-key" \
  https://api.anyapi.ai/v1/models
```

## Troubleshooting

> [accordion] Claude Code asks you to log in
>
> A cached Anthropic session takes priority over your settings. Run `/logout` inside Claude Code, quit, and relaunch `claude`.

> [accordion] 403 access denied
>
> Your key has no access to that model, or the model ID is wrong. Check your balance and plan at [dash.anyapi.ai](https://dash.anyapi.ai), and verify the ID against `/v1/models`.

> [accordion] Settings seem to be ignored
>
> Claude Code reads `~/.claude/settings.json`, not a project `.env` file. Confirm the file is valid JSON — a trailing comma silently breaks it.

## Next Steps

> [card] [CC Switch](https://docs.anyapi.ai/use-cases/cc-switch)
>
> Switch models in Claude Code from a GUI

> [card] [All Integrations](https://docs.anyapi.ai/integrations/overview.md)
>
> Browse all supported tools


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