Skip to content

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

ItemValue
MethodPOST
Path/v1/messages
Content-Typeapplication/json
AuthenticationAuthorization: Bearer YOUR_API_KEY

Request Parameters

ParameterTypeRequiredDescription
modelstringYesRequested model. The gateway applies group model mapping and platform routing.
messagesarrayYesAnthropic Messages style message array.
max_tokensintegerUsuallyMaximum output tokens.
systemstring or arrayNoSystem prompt.
streambooleanNoWhether to stream the response.
thinkingobjectNoReasoning configuration, applied by model and platform capability.
metadata.user_idstringNoCan 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.

ItemValue
MethodPOST
Path/v1/messages/count_tokens
Content-Typeapplication/json
RestrictionNot 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"
  }
}