DINGJIAI
DINGJIAI
Quick start in 5 minutesWhat is DINGJIAI?

Popular Agents

Codex SetupClaude Code SetupOne-Click Setup

API Reference

Billing

Model pricing

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.

settings.json
{
  "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_MODEL sets the main conversation model.
  • ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_DEFAULT_OPUS_MODEL control what the haiku, sonnet, and opus aliases 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_MODEL has the highest priority; otherwise Claude Code checks the Agent invocation's model parameter, the agent definition's model, and finally the main conversation model. An omitted model or model: inherit uses normal inheritance. On current releases, setting CLAUDE_CODE_SUBAGENT_MODEL=inherit is 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

  1. Fully quit and restart Claude Code.
  2. If the login screen still appears, Claude Code did not load these local credentials; slash commands such as /config are not available there. Quit the client, verify the settings.json path, 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.
  3. 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.
  4. Run /status and 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.
  5. 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

Codex SetupOne-Click Setup

On this page

Minimal configurationModel listFirst use and verificationVerify the endpoint