Skip to content

Create message

Anthropic Messages API: for Claude models only; the Base URL has no /v1, and the Anthropic SDK and Claude Code work directly.

POST/v1/messages

Claude models use the Anthropic protocol. 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. A Claude key calling an OpenAI protocol path returns 404 "The current platform does not support this API path".

Headers

Authorization:optionalstring

Bearer sk-…; or send x-api-key: sk-… instead — either works

anthropic-version:optionalstring

Added automatically by the SDK and forwarded as-is, e.g. 2023-06-01

anthropic-beta:optionalstring

Beta feature flags, forwarded as-is

Body parametersJSON

model:requiredstring

A Claude model ID in the current key's group; if the group does not include the model, returns 404 model_not_found

max_tokens:optionalinteger

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

messages:requiredarray of object

In Anthropic's official format, forwarded as-is

Items≥ 1

system:optionalstring or array

System prompt, forwarded as-is

stream:optionalboolean

true returns an Anthropic SSE event stream

Defaultfalse

tools:optionalarray of object

Anthropic tool definitions (name, description, input_schema), forwarded as-is

thinking:optionalobject

Extended thinking config, forwarded as-is; values per Anthropic's official spec

temperature:optionalnumber

Forwarded as-is; range per Anthropic's official spec

Returns

200Success. Non-streaming returns message JSON; with stream: true it returns Anthropic SSE

id:optionalstring

Message ID

type:optional"message"
role:optional"assistant"
model:optionalstring

Model ID

content:optionalarray of object

Content blocks

stop_reason:optionalstring

end_turn / max_tokens / tool_use / stop_sequence

usage:optionalobject

Token usage

Errors

400Anthropic shape: {"type":"error","error":{"type":"invalid_request_error","message":"…"}}, with no code. Key-validation errors (401, 402, 403) still use the OpenAI shape
401Missing, invalid or expired API key (missing_api_key / invalid_api_key / api_key_expired)
402Balance, or key / member / department quota, exhausted (insufficient_quota)
404The model is not in this key's group (model_not_found), or the path does not belong to the group (route_not_found)
413Request body over 60 MB (request_too_large)
429Account or key concurrency cap reached (user_concurrency_limit / apikey_concurrency_limit), with Retry-After

Related