Skip to main content
POST
Create a message (Anthropic Messages API)

Authorizations

Authorization
string
header
required

A workspace API key in an Authorization: Bearer header. A missing header, a scheme other than Bearer, a key of the wrong shape, and a key we reject are all 401.

Headers

x-api-key
string

Your Hopscotch API key, as an alternative to Authorization: Bearer. If you send both, they must carry the same key.

Body

application/json

An Anthropic Messages request. Fields beyond the ones named here are forwarded to the provider unchanged, so Anthropic's own documentation describes them.

model
string
required

A model id in provider/model form, or profile/{identifier} for one of your workspace's routing profiles. A bare model id is refused with 400 and the code model_id_not_pinned. The catalog must list the model for messages. List what you can call with GET /v1/models.

Example:

"anthropic/claude-sonnet-4-5"

messages
object[]
required

The conversation turns, in Anthropic message form.

max_tokens
integer
required

The most output tokens you will accept. Required, and passed to the provider as sent. The provider owns the ceiling for the model you name.

Required range: x >= 1
stream
boolean
default:false

Return the reply as Anthropic's own event stream instead of one JSON body.

system

A system prompt, as Anthropic's API takes it: a string or an array of content blocks.

tools
object[]

Tool definitions, in Anthropic's form.

tool_choice
object

How the model may use the tools, in Anthropic's form.

Response

The message, in Anthropic's format as the provider produced it: a content array, a stop_reason, and a usage object with input_tokens and output_tokens.

When stream is true the body is text/event-stream instead, passed through in Anthropic's own event format.

An Anthropic message, as the provider produced it.

id
string
type
string
Example:

"message"

role
string
Example:

"assistant"

model
string
content
object[]
stop_reason
string | null
stop_sequence
string | null
usage
object