Skip to navigation

Create a message

Anthropic-compatible Messages endpoint. Accepts the Anthropic Messages request shape and routes to any catalogued model.

Also served at /v1/anthropic/v1/messages; both paths accept the same requests. This bare path is what the Anthropic SDK builds from a bare-host base URL, so pointing the SDK at https://api-gateway.merge.dev works with no other changes.

Supports Anthropic message threads through the thread field, so a long conversation can continue without resending earlier turns. See Multi-turn conversations.

Authentication

AuthorizationBearer
Your production key sent as a bearer token.

Request

This endpoint expects an object.
modelstringRequired
max_tokensintegerRequired
messageslist of objectsRequired
systemstring or list of objects or nullOptional
streambooleanOptionalDefaults to false
temperaturedouble or nullOptional
top_pdouble or nullOptional
top_kinteger or nullOptional
stop_sequenceslist of strings or nullOptional
toolslist of objects or nullOptional
tool_choicemap from strings to any or nullOptional
metadatamap from strings to any or nullOptional
service_tierstring or nullOptional
cache_controlmap from strings to any or nullOptional

Top-level prompt-caching setting.

thinkingobject or nullOptional
Extended thinking settings for models that support it.
output_configobject or nullOptional

Anthropic output settings; only effort is applied.

customerstring or nullOptional

Customer ID (UUID) to scope this request to, applying that customer’s routing policy, provider keys, budget, and usage attribution.

routing_policy_idstring or nullOptional

Routing policy ID for this request: an org-level policy, or a project or customer policy when the request carries that scope.

priority_orderlist of strings or objects or nullOptional

Ordered list of models to try, first success wins, with the same rules as priority_order on POST /v1/responses.

vendorstring or nullOptional

Restrict routing to one vendor (hosting platform).

vendorslist of strings or nullOptional

Ordered list of acceptable vendors; the first available one wins.

provider_optionsmap from strings to any or nullOptional

Provider-specific options, keyed by provider family.

include_routing_metadatabooleanOptionalDefaults to false
Return routing metadata for this request.
include_guardrails_metadatabooleanOptionalDefaults to false

Return prompt-injection and DLP results in a top-level guardrails object.

service_tier_fallbackbooleanOptionalDefaults to false

Retry once at the standard tier, billed at standard rates, if the requested tier is throttled (429 or 503).

threadobject or nullOptional

Anthropic message threads (beta). {"type": "create"} sends the full conversation and asks Anthropic to hold it. {"type": "continue", "previous_message_id": "msg_..."} sends only the new turn and continues from a previous response’s id. A continue can’t carry system or tools. Threads need a model Gateway serves through Anthropic directly. If the thread can’t be continued, Gateway returns 404 with error.details.error_code: "thread_not_found": resend the full conversation with type: "create". See Multi-turn conversations.

Response

Successful Response
idstring
type"message"
role"assistant"
modelstring
contentlist of objects
usageobject
stop_reasonenum or nullOptional
Allowed values:
stop_sequencestring or nullOptional

Errors

422
Unprocessable Entity Error