Completions
Create a message
The Anthropic Messages format, on the same models and prices. The Anthropic SDKs and Claude Code use it. Errors come in the Anthropic shape.
/ v1 / messagesAuthorizations
AuthorizationstringheaderrequiredBearer authentication header of the form Bearer <token>, where <token> is your API key. This endpoint also takes the key in x-api-key, as the Anthropic SDKs send it.
Body
application/jsonmodelstringrequiredA Libremodel model ID, from Models or
GET /v1/models.messagesobject[]requiredThe conversation:
role(userorassistant) andcontent, text or blocks (text,image,document,tool_use,tool_result).max_tokensintegerCap on output tokens, thinking included. The Anthropic SDKs require it.
Example:
1024systemstring | object[]The system prompt.
streambooleandefault: falseSend the answer as Server-Sent Events, as it is generated. See Streaming.
thinkingobject{"type": "enabled"}oradaptiveto get the thinking text inthinkingblocks.output_configobjecteffort(the reasoning level) andformat(structured outputs).toolsobject[]Tools the model can use, with
tool_choice. See Tool calling.stop_sequencesstring[]Text that ends the answer.
temperaturenumberSampling temperature.
top_pnumberNucleus sampling.
Response
The message. With stream, Anthropic’s text/event-stream instead.
idstringrequiredThe ID of the message.
typestringrequiredAlways
"message".contentobject[]requiredBlocks:
thinking(with thinking on),textandtool_use. Read thetextones for the answer.stop_reasonstringrequiredWhy it stopped.
Allowed values:
"end_turn""max_tokens""stop_sequence""tool_use"usageobjectrequiredinput_tokens,cache_read_input_tokens,output_tokensandcost.Show child attributesHide child attributes
costnumberrequiredWhat the request cost, in dollars.
Example:
0.0001605
The body is not valid: a required field is missing or one has the wrong type.
typestringrequiredAlways
"error".errorobjectrequiredThe error.
Show child attributesHide child attributes
typestringrequiredThe error type, as in the Anthropic API.
Example:
"authentication_error"messagestringrequiredWhat went wrong, for a person to read.
The key is missing, wrong, revoked or expired.
typestringrequiredAlways
"error".errorobjectrequiredThe error.
Show child attributesHide child attributes
typestringrequiredThe error type, as in the Anthropic API.
Example:
"authentication_error"messagestringrequiredWhat went wrong, for a person to read.
The balance does not cover the request.
typestringrequiredAlways
"error".errorobjectrequiredThe error.
Show child attributesHide child attributes
typestringrequiredThe error type, as in the Anthropic API.
Example:
"authentication_error"messagestringrequiredWhat went wrong, for a person to read.
The key is valid but cannot do this: the model is not among the ones the key allows, its spending limit is reached or the account is suspended.
typestringrequiredAlways
"error".errorobjectrequiredThe error.
Show child attributesHide child attributes
typestringrequiredThe error type, as in the Anthropic API.
Example:
"authentication_error"messagestringrequiredWhat went wrong, for a person to read.
The model ID does not exist. The valid ones come from GET /v1/models.
typestringrequiredAlways
"error".errorobjectrequiredThe error.
Show child attributesHide child attributes
typestringrequiredThe error type, as in the Anthropic API.
Example:
"authentication_error"messagestringrequiredWhat went wrong, for a person to read.
Too many requests at once. Wait for the seconds in the Retry-After header and retry.
typestringrequiredAlways
"error".errorobjectrequiredThe error.
Show child attributesHide child attributes
typestringrequiredThe error type, as in the Anthropic API.
Example:
"authentication_error"messagestringrequiredWhat went wrong, for a person to read.
Temporarily unavailable. Retry after a short wait.
typestringrequiredAlways
"error".errorobjectrequiredThe error.
Show child attributesHide child attributes
typestringrequiredThe error type, as in the Anthropic API.
Example:
"authentication_error"messagestringrequiredWhat went wrong, for a person to read.