Claude Code Setup
Connect Claude Code or another Anthropic-compatible tool to DINGJIAI.
Claude Code uses Anthropic Messages
DINGJIAI does not convert Anthropic requests into OpenAI requests. Claude Code calls /v1/messages and sends the DINGJIAI user API Key through x-api-key.
Minimal configuration
Set the environment values in Claude Code's user-level settings.json. The usual path is %USERPROFILE%\.claude\settings.json on Windows and ~/.claude/settings.json on macOS or Linux.
{
"env": {
"ANTHROPIC_BASE_URL": "https://dingjiai.com",
"ANTHROPIC_API_KEY": "sk-your-DINGJIAI-user-api-key",
"ANTHROPIC_MODEL": "a public model id copied from the Anthropic model list",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "the same or a matching Anthropic public model id",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "the same or a matching Anthropic public model id",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "the same or a matching Anthropic public model id"
}
}If only one Anthropic public model id is published, you can initially map all four variables to it. When several models are published, map the Haiku, Sonnet, and Opus slots separately.
ANTHROPIC_MODELsets the main conversation model.ANTHROPIC_DEFAULT_HAIKU_MODEL,ANTHROPIC_DEFAULT_SONNET_MODEL, andANTHROPIC_DEFAULT_OPUS_MODELcontrol what thehaiku,sonnet, andopusaliases resolve to. They do not force every request onto one model. The Haiku slot is also used by lightweight background functionality in Claude Code.- Subagents resolve their model separately. A model name or alias in
CLAUDE_CODE_SUBAGENT_MODELhas the highest priority; otherwise Claude Code checks the Agent invocation'smodelparameter, the agent definition'smodel, and finally the main conversation model. An omittedmodelormodel: inherituses normal inheritance. On current releases, settingCLAUDE_CODE_SUBAGENT_MODEL=inheritis also equivalent to leaving it unset.
The four ANTHROPIC_*MODEL mappings in the JSON example must be public model ids published by the gateway's Anthropic model list. CLAUDE_CODE_SUBAGENT_MODEL follows a separate rule: it may use a gateway-supported full model ID, a Claude Code alias, or inherit to resume normal layered resolution.
Do not replace it with ANTHROPIC_AUTH_TOKEN
ANTHROPIC_API_KEY is sent as x-api-key, which matches the gateway contract. An Authorization: Bearer header by itself cannot authenticate against the Anthropic endpoints.
Model list
curl https://dingjiai.com/anthropic/v1/models \
-H "x-api-key: YOUR_USER_API_KEY" \
-H "anthropic-version: 2023-06-01"Use a returned public model id as ANTHROPIC_MODEL. A same-named model on an OpenAI or Gemini list does not automatically work with Anthropic Messages.
First use and verification
- Fully quit and restart Claude Code.
- If the login screen still appears, Claude Code did not load these local credentials; slash commands such as
/configare not available there. Quit the client, verify thesettings.jsonpath, JSON syntax, file permissions, and key, then restart. Use only Claude Code's current supported sign-in flow if it asks you to choose credentials. - Only when you are already inside a session but the custom key is unapproved, rejected, or an old account remains active, run
/config, choose Use custom API key, and restart. Do not rely on undocumented credential hacks. - Run
/statusand confirm that the Base URL, authentication mode, and model match this page. If an old account or endpoint remains active, sign out through Claude Code's current supported login flow, then select the custom API key again. - Send one minimal request using a public model id returned by the Anthropic model list.
Claude Code releases can change login interactions. Follow Claude Code model configuration, subagents, and LLM gateway configuration for the current client behavior.
Verify the endpoint
curl https://dingjiai.com/v1/messages \
-H "x-api-key: YOUR_USER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "a public model id copied from the Anthropic model list",
"max_tokens": 256,
"messages": [{"role":"user","content":"Hello"}]
}'- Give every user a separate DINGJIAI user API Key; never enter an upstream provider key.
- The API Key is stored locally. Do not commit or share it.
- Keep the client's default
anthropic-version; it is not an upstream version selector.
Last updated on