Claude Code with a custom endpoint
Claude Code talks to the Anthropic Messages API, which 666 AI supports at /v1/messages. We installed Claude Code and ran it against our live API, including tool calls, before writing this page.
YOUR-ENDPOINT with the endpoint shown on your API Key page after you sign up, and YOUR-KEY with your key. One key works for every model on 666 AI — Claude, GPT, Gemini, DeepSeek, Qwen and 200+ more.1. Set the environment variables
# macOS / Linux (bash / zsh)
export ANTHROPIC_BASE_URL="https://YOUR-ENDPOINT" # no /v1
export ANTHROPIC_AUTH_TOKEN="YOUR-KEY"
export ANTHROPIC_MODEL="anthropic/claude-sonnet-5.5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic/claude-haiku-5.5"
claude2. Or put them in settings.json
// ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json)
{
"env": {
"ANTHROPIC_BASE_URL": "https://YOUR-ENDPOINT",
"ANTHROPIC_AUTH_TOKEN": "YOUR-KEY",
"ANTHROPIC_MODEL": "anthropic/claude-sonnet-5.5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-5.5"
}
}Use your user settings file. Don't put keys in a project's .claude/settings.json — that file is usually committed to git.
3. Check it
claude -p "Reply with exactly the word OK."In an interactive session, /status shows the base URL and which variable your token came from.
Which models work
Use Claude models: anthropic/claude-sonnet-5.5 (recommended for coding), anthropic/claude-opus-5.5, anthropic/claude-haiku-5.5. Anthropic does not support running Claude Code on non-Claude models through gateways, so don't point it at GPT or Gemini.
In our test Sonnet 5.5 ran shell tools first time; the small Haiku model sometimes needed a retry on its first tool call — use Sonnet for agentic work.
If you get a 400 error
context_managementor Extra inputs are not permitted: setCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1.- Context-length errors in long sessions: set
CLAUDE_CODE_AUTO_COMPACT_WINDOWandCLAUDE_CODE_MAX_OUTPUT_TOKENSto the model's real limits. - 401: the key is wrong.
ANTHROPIC_BASE_URLgoes in without/v1.
FAQ
Do I need an Anthropic account?
No. Your 666 AI key is enough; usage is billed per token from your 666 AI balance.
ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY?
Either works with 666 AI. AUTH_TOKEN sends a Bearer header and avoids the one-time key confirmation prompt.
Does the VS Code extension work too?
Yes — set the same variables in the extension's environment settings (claudeCode.environmentVariables).