Messages
An Anthropic Messages API endpoint, for code written against the Anthropic SDK. The gateway translates to the model's native protocol and back, so any chat model in the catalog can be called this way, not only Anthropic’s.
/v1/messagesRequest#
curl https://api.ahurasense.com/v1/messages \
-H "x-api-key: $AHURA_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"max_tokens": 256,
"system": "You are a terse assistant.",
"messages": [
{"role": "user", "content": "Explain rate limiting in two sentences."}
]
}'modelstringrequired- A catalog id. Any chat model works, not only Anthropic’s.
max_tokensintegerrequired- Upper bound on generated tokens, reasoning included on models that reason.
messagesarrayrequired- Alternating
userandassistantturns.contentis a string or an array of blocks:text,image(base64 source),tool_useandtool_result. systemstring or arrayoptional- The system prompt, as a string or text blocks.
streambooleanoptionaldefault false- Anthropic-style event stream. See below.
temperaturenumber, 0 to 1optional- Anthropic’s range. Mapped onto the model unchanged.
top_pnumber, 0 to 1optional- Nucleus sampling.
top_kintegeroptional- Passed through where the model supports it.
stop_sequencesarray of stringsoptional- Sequences at which generation stops.
toolsarrayoptional- Accepted but not translated, so tool calling does not work on this route. See below.
tool_choiceobjectoptional- Accepted but not translated. See below.
metadata.user_idstringoptional- Your identifier for the end user.
Response#
A native Anthropic message object:
{
"id": "msg_…",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-sonnet-5",
"content": [{ "type": "text", "text": "Rate limiting caps how many requests …" }],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 31,
"output_tokens": 48,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}Errors use Anthropic’s envelope, {"type":"error","error":{"type":"…","message":"…"}}, with the same status codes as the rest of the API. X-Ahura-Request-Id is on every response.
Streaming#
With stream: true the response is a stream of named events in Anthropic’s order:
| Event | Carries |
|---|---|
message_start | The message envelope with empty content and the input token count. |
content_block_start | The opening of the text block. |
content_block_delta | A text_delta with the next piece of text. Repeated. |
content_block_stop | The block is complete. |
message_delta | The stop_reason and the output token count. |
message_stop | End of the message. |
The Anthropic SDKs’ streaming helpers consume this without changes.
Differences from Anthropic’s API#
- Tool use does not work on this route. Anthropic tool definitions are forwarded without being converted to the wire format the backends expect: hosted models reject the request with
400, and partner models answer as though no tool were offered. A tool call the model does make is not returned as atool_useblock either. Use Chat completions for anything agentic; tool calling there is complete, on every model. thinkingandoutput_config.effortare honoured on hosted models:{"type": "disabled"}turns reasoning off,budget_tokenscaps it, andeffortpicks a level. See Reasoning effort. On partner-served models these fields are not forwarded.cache_controlhints on content blocks are accepted and ignored.- Images must be base64 sources; URL sources are not translated.
- Container and code-execution tools are not available.
For new integrations, Chat completions is the fuller endpoint. This route exists so that existing Anthropic code can move without a rewrite.
Something missing or wrong on this page? Tell us, and quote the page title.