Anthropic Messages
The Anthropic Messages API entry, authentication headers, and usage settlement boundaries.
Anthropic uses x-api-key
Claude Code and Anthropic-compatible tools should use the Messages entry and put the DINGJIAI user API Key in x-api-key. Sending only Bearer authentication will not pass Anthropic authentication.
Paths
| Purpose | Method and path |
|---|---|
| Model request | POST /v1/messages |
| Compatible path | POST /anthropic/v1/messages |
| Model list | GET /anthropic/v1/models or GET /anthropic/v1/models/ |
Request example
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_MODEL_NAME_COPIED_FROM_THE_ANTHROPIC_MODEL_LIST",
"max_tokens": 256,
"messages": [
{ "role": "user", "content": "Introduce yourself in one sentence" }
]
}'Streaming request
curl -N 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_MODEL_NAME_COPIED_FROM_THE_ANTHROPIC_MODEL_LIST",
"max_tokens": 256,
"stream": true,
"messages": [
{ "role": "user", "content": "Explain the integration in three points" }
]
}'Headers and version
Prop
Type
Usage and billing
Settlement reads usage.input_tokens, usage.output_tokens, and the optional usage.cache_creation_input_tokens and usage.cache_read_input_tokens fields.
Trusted usage takes priority. When usage is missing or invalid, generated visible text, thinking, and tool_use.input may be used for estimation. For a valid non-stream success JSON object billed by tokens, missing or invalid usage incurs at least one output token even when no extractable output is available (including {}). Stream estimation requires extractable model output. A disconnect, cancellation, or delivery failure is not necessarily free; settlement does not require the client to have successfully received a chunk. For the complete estimation conditions, partial-usage rules, and failed-request settlement rules, see Usage and billing.
Anthropic requests are not automatically converted to OpenAI
Anthropic Messages selects the model products and upstream candidates exposed for the Anthropic entry. A model with the same name in the OpenAI Chat list does not automatically mean that it is available for Anthropic Messages; it must also be published for the Anthropic Messages entry.
Last updated on