Claude Code
Claude Code speaks the Anthropic Messages API (POST /v1/messages). Openference accepts Bearer authentication.
Use ANTHROPIC_AUTH_TOKEN — not ANTHROPIC_API_KEY, which sends an x-api-key header that Anthropic’s API expects directly.
Quick setup (shell)
/v1/messages to the base URL itself, so do not include /v1 in ANTHROPIC_BASE_URL (otherwise requests go to /v1/v1/messages and fail). The settings.json example below follows the same convention.
Then run claude as usual.
Persistent configuration (settings.json)
For a config that survives new shells, edit ~/.claude/settings.json:
GET /v1/models. The haiku / sonnet / opus env vars map Claude Code’s tier picker (/model) to Openference model IDs.
Set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY to 1 so Claude Code discovers models from your gateway instead of Anthropic’s catalog.
Model tiers
Claude Code labels models as haiku, sonnet, or opus. Map each tier to an Openference model:
Use the matching
*_MODEL_NAME vars for display names in the UI.
Chinese models
GLM, DeepSeek, Kimi, and Qwen work through/v1/messages — use exact IDs from the catalog. See Chinese LLM Models.