inference

Anthropic Messages API. The request is translated into a /v1/chat/completions request, served by the chat route with all of its limits, and the answer is translated back. Buffered and streaming answers are supported. POST /v1/messages/count_tokens is not served.

post/v1/messages

Request

  • The document declares no server URL.
  • Auth
    • HTTP bearer
    • or API key in header x-api-key

Headers

anthropic-versionstring nullable

Absent or 2023-06-01

anthropic-betastring nullable

Accepted and ignored

X-SIE-MACHINE-PROFILEstring nullable

Preferred GPU or machine profile

X-SIE-Poolstring nullable

Explicit pool routing override

X-SIE-Remote'forbid'

Require local serving through a current worker execution fence. A selected remote profile returns 400; no verified local worker returns retryable 503. Duplicate or other values return 400.

Request body

cache_controlunknown
max_tokensinteger required

Output token limit, at least 1 and at most the serving profile's max_output_tokens.

messagesunknown required
metadataunknown
modelstring required

The model id, used as on /v1/chat/completions (model or model:profile, or an operator alias).

output_configEmptyOutputConfig

An output_config with no fields, the only one accepted.

stop_sequencesstring[] nullable
streamboolean nullable

Server-sent events: message_start, content block events, message_delta with the final usage, message_stop, and ping whenever no other event was sent for 10 seconds. A failure after the stream opened is an error event, and the stream then ends without message_stop.

systemunknown
temperaturenumber double nullable

In [0, 1].

thinkingunknown
tool_choiceunknown
toolsunknown
top_kinteger nullable

At least 1.

top_pnumber double nullable

In (0, 1].

Response

Message, or a text/event-stream of Messages events when stream is true

contentunknown required
idstring required

msg_ followed by the gateway request id.

modelstring required
rolestring required

Always assistant.

stop_reasonstring required

end_turn, tool_use, max_tokens or refusal.

stop_sequencestring nullable

Always null.

typestring required

Always message.

Changes