Create a message (Anthropic shape)
Anthropic-compatible Messages endpoint. Internally translates to the upstream OpenAI-compatible inference path.
Streaming. When stream: true is set, the response content type switches to text/event-stream and Anthropic-shaped events are emitted. Event types:
message_start— message envelope with id, model, role, usage.content_block_start— start of a content block (text, tool_use, thinking).content_block_delta— incremental content (text delta, input_json_delta, thinking_delta).content_block_stop— end of a content block.message_delta— running stop_reason / usage updates.message_stop— terminal event.ping— keep-alive.error— terminal error event (see error type mapping below).
Model ID aliasing. Slashes in upstream model IDs are aliased with -- — pass anthropic--claude-3-5-sonnet to target anthropic/claude-3-5-sonnet.
Error response shape. All non-2xx responses use { type: "error", error: { type, message } }. Status → error.type mapping:
| Status | error.type |
|---|---|
400 | invalid_request_error |
401 | authentication_error |
403 | permission_error |
404 | not_found_error |
413 | request_too_large |
429 | rate_limit_error (response includes Retry-After header) |
500 | api_error |
503 / 529 | overloaded_error |
Authorization
BearerAuth API key passed as Bearer token
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/anthropic/v1/messages" \ -H "Content-Type: application/json" \ -d '{ "model": "string", "messages": [ {} ], "max_tokens": 0 }'{
"id": "string",
"type": "message",
"role": "assistant",
"content": [
{}
],
"model": "string",
"stop_reason": null,
"stop_sequence": null,
"usage": {
"input_tokens": 0,
"output_tokens": 0
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "string"
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "string"
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "string"
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "string"
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "string"
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "string"
}
}