aimldocs
Integrations

Claude Code

Run Claude Code on ai.ml through its Anthropic base URL setting.

Claude Code speaks the Anthropic Messages API, which ai.ml serves at /v1/messages.

With the CLI

npx @aiml/cli setup claude-code

By hand

Add an env block to ~/.claude/settings.json (or $CLAUDE_CONFIG_DIR/settings.json). Keep the file readable only by you, since it holds the key.

cookbook/integrations/claude-code/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.ai.ml",
    "ANTHROPIC_AUTH_TOKEN": "aiml-live-…",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-sonnet-4-6",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5"
  }
}
  • Use ANTHROPIC_AUTH_TOKEN, which Claude Code sends as a bearer token and uses straight away. With ANTHROPIC_API_KEY, Claude Code asks once whether to trust the key, and if you decline it ignores the key from then on without saying so.
  • The model variables use the vendor's aliases (claude-sonnet-4-6). Claude Code recognises those names and turns on the features it associates with them.
  • Claude Code's "Opus" choice is mapped to the main model, because the catalog may not carry Opus.
  • ANTHROPIC_DEFAULT_HAIKU_MODEL is the model for background calls such as titles and summaries. Point it at a small model the catalog has, or at the main model.
  • To use any other catalog model, set ANTHROPIC_MODEL to its id. The gateway translates between dialects, so ANTHROPIC_MODEL=openai/gpt-5 works too.

What to expect

  • Claude Code 2.1 asks for adaptive thinking with an effort level (output_config.effort). The gateway passes that to every provider as a reasoning effort.
  • Claude Code also sends two fields ai.ml does not act on, context_management and safeguards. They are dropped, and each drop is noted in x-aiml-warnings.
  • Token counting (/v1/messages/count_tokens) is served and spends nothing.
  • A few checks still go directly to Anthropic, such as the fast-mode probe. Set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 in the same env block to turn off telemetry, error reporting and update checks as well.

Verified with Claude Code 2.1.285, including a tool-use round trip.

On this page