# Claude Code

Run Claude Code on open models: point it at the API with your key, and pick a model in /model.

The API speaks Anthropic's Messages API on `/v1/messages`, which is all Claude Code needs. It runs the same; the model behind it is one of ours.

## Set it up

```bash
# The API speaks Anthropic's Messages API, so Claude Code needs only its address and your key
export ANTHROPIC_BASE_URL=https://api.vultrinference.com
export ANTHROPIC_AUTH_TOKEN=$VULTR_INFERENCE_API_KEY

# Fill Claude Code's /model picker from the API (each chat model as vultr/claude-code/<id>)
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1

# Claude Code does not read a model's context window from the list: set it for the model you use
export ANTHROPIC_MODEL=vultr/claude-code/deepseek-v4.1-flash
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1048576

claude
```

| Variable | What it does |
| --- | --- |
| `ANTHROPIC_BASE_URL` | The API's address, without `/v1`: Claude Code adds `/v1/messages` itself |
| `ANTHROPIC_AUTH_TOKEN` | Your key, sent as a bearer token. `ANTHROPIC_API_KEY` works too. |
| `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY` | Set to 1, fills the `/model` picker from the API's model list |
| `CLAUDE_CODE_MAX_CONTEXT_TOKENS` | The model's context window, which Claude Code cannot read from the list |

Each model's context window is on [its page](/docs/models#text): 1048576 for deepseek-v4.1-flash, 262144 for qwen3.8-flash-next. Start Claude Code again after you switch to a model with a different window.

## Pick a model

Claude Code lists only models whose id mentions Claude, so every chat model is listed a second time as `vultr/claude-code/<id>`. Use that form: an unknown plain id is quietly answered by the default model, while an unknown prefixed id is a 404 you will notice.

```bash
# What Claude Code's model discovery reads: Anthropic's model list, each chat model under two ids
curl "https://api.vultrinference.com/v1/models?limit=1000" \
  -H "anthropic-version: 2023-06-01"
```

If you start Claude Code from a script, leave `ANTHROPIC_MODEL` out of it when you want a model chosen in `/model` to stick.

## What works

- Streaming, tool use, images, documents and system prompts, as in Anthropic's API.
- Thinking, whose blocks Claude Code sends back on the next turn. A model that cannot hold to a thinking budget refuses one rather than ignore it.
- Effort, from minimal to ultra, where the model takes it.

## What differs from Anthropic's API

- The models are open models, not Claude. Their skill at a long agentic task varies; try a few.
- Prompt caching is not offered: `cache_control` is accepted and ignored, so a long session pays for its whole context on every turn.
- There is no token counting route.
- Anthropic's own server tools (web search, code execution) and the MCP connector are not offered: tools are passed to the model as plain function tools.
- Thinking is the model's own text, not a summary of it.
