Create message
Anthropic Messages API: the native protocol for Claude models, also available for DeepSeek, Qwen, and US-region models; the Base URL has no /v1, and the Anthropic SDK and Claude Code work directly.
/v1/messagesClaude models use the Anthropic protocol; DeepSeek, Qwen, and US-region (-us) models support it too, and for any other model its own page is authoritative. Set the SDK Base URL to https://api.hop-base.com (without /v1); the request path is still /v1/messages. POST /v1/messages/count_tokens is also supported.
The table lists only the parts the gateway fills in or handles specially; other Messages API fields are forwarded as-is, with ranges per Anthropic's official spec. Claude models can also be called through the OpenAI-compatible /v1/chat/completions, but this endpoint is the most complete: it preserves thinking between tool calls and supports prompt-caching controls and Anthropic-native parameters. /v1/responses does not support Claude models and returns 404 "This API path is not supported by the current platform".
Charged non-streaming responses return the actual charge for this request: the X-HopBase-Cost / X-HopBase-Cost-USD / X-HopBase-Currency headers, plus cost / cost_usd / currency in the top-level usage object of the body (existing usage fields are kept). cost_usd is the USD amount actually deducted from your balance; cost is the same charge in CNY, and currency is always CNY. Streaming (SSE) responses do not carry it; check Usage in the console. Uncharged responses, such as errors, carry neither. See Account API · Charges.
Headers
Bearer sk-…; or send x-api-key: sk-… instead — either works
Added automatically by the SDK and forwarded as-is, e.g. 2023-06-01
Beta feature flags, forwarded as-is
Body parametersJSON
A model ID in the current key's group (Claude, or a model that supports this protocol, such as DeepSeek or Qwen); if the group does not include the model, returns 404 model_not_found
No gateway cap; the maximum follows the model's official spec. The official API requires it; HopBase fills in 4096 when it is missing, so long outputs are cut off at 4096 (stop_reason: "max_tokens"). Set it explicitly
Default4096
In Anthropic's official format, forwarded as-is
Items≥ 1
user or assistant
A string, or an array of content blocks (text, image, tool_use, tool_result, etc.)
System prompt, forwarded as-is
true returns an Anthropic SSE event stream
Defaultfalse
Anthropic tool definitions (name, description, input_schema), forwarded as-is
Extended thinking config, forwarded as-is; values per Anthropic's official spec
Forwarded as-is; range per Anthropic's official spec
Returns
200Success. Non-streaming returns message JSON; with stream: true it returns Anthropic SSE
Response headers
The charge for this request in CNY (the same charge as X-HopBase-Cost-USD), up to 6 decimal places, such as 0.0816. Sent only when the request is charged; not sent on streaming (SSE) responses. When image generation takes longer than about 40 seconds the headers have already been sent, so read usage.cost in the body instead
The USD amount actually deducted from your balance for this request, the same amount as its usage record, up to 8 decimal places, such as 0.012; sent only together with X-HopBase-Cost
The currency of X-HopBase-Cost, always CNY
Message ID
Model ID
Content blocks
text / thinking / tool_use
Text of a text block
tool_use: tool name
tool_use: tool input
end_turn / max_tokens / tool_use / stop_sequence
Token usage
Input tokens
Output tokens
Input tokens written to the cache
Input tokens read from the cache
Added by the gateway: the charge for this request in CNY (the same charge as cost_usd), the same as the X-HopBase-Cost header; not returned when streaming
Added by the gateway: the USD amount actually deducted from your balance, the same as the X-HopBase-Cost-USD header and your usage record; not returned when streaming
Added by the gateway: the currency of cost, always CNY
Errors
{"type":"error","error":{"type":"invalid_request_error","message":"…"}}, with no code. Key-validation errors (401, 402, 403) still use the OpenAI shapemissing_api_key / invalid_api_key / api_key_expired)insufficient_quota)model_not_found), or the path does not belong to the group (route_not_found)request_too_large)user_concurrency_limit / apikey_concurrency_limit), with Retry-After