Messages
/v1/messages is the Anthropic Messages compatible entrypoint for Claude Code and Anthropic protocol clients. The server selects the upstream or conversion path from the API key group platform, model mapping, and account capabilities.
Interface
| Item | Value |
|---|---|
| Method | POST |
| Path | /v1/messages |
| Content-Type | application/json |
| Authentication | Authorization: Bearer YOUR_API_KEY |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Requested model. The gateway applies group model mapping and platform routing. |
messages | array | Yes | Anthropic Messages style message array. |
max_tokens | integer | Usually | Maximum output tokens. |
system | string or array | No | System prompt. |
stream | boolean | No | Whether to stream the response. |
thinking | object | No | Reasoning configuration, applied by model and platform capability. |
metadata.user_id | string | No | Can be used for sticky sessions and request tracking. |
Request Example
bash
curl https://llmapi.site/v1/messages \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 512,
"messages": [
{ "role": "user", "content": "Summarize this request." }
]
}'The response is returned as an Anthropic Messages compatible payload according to the upstream and conversion path.
Token Count
/v1/messages/count_tokens provides Anthropic token counting. It checks subscription and balance, but does not acquire concurrency or record usage.
| Item | Value |
|---|---|
| Method | POST |
| Path | /v1/messages/count_tokens |
| Content-Type | application/json |
| Restriction | Not supported for OpenAI platform groups |
Request example:
bash
curl https://llmapi.site/v1/messages/count_tokens \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4-5",
"messages": [
{ "role": "user", "content": "Hello" }
]
}'OpenAI group response example:
json
{
"type": "error",
"error": {
"type": "not_found_error",
"message": "Token counting is not supported for this platform"
}
}