Model Rover

Anthropic Messages

Create Anthropic-compatible messages with native response and streaming event shapes.

POST /v1/messages

Creates a message using the Anthropic protocol. The incoming protocol controls the request, response, stream, and error shapes; it does not restrict routing to Anthropic-owned models.

POST /v1/messages
x-api-key: $API_KEY
anthropic-version: 2023-06-01
Content-Type: application/json

Authorization: Bearer $API_KEY is also accepted. The platform controls the protocol version used for the selected upstream endpoint.

Request body

FieldTypeRequiredDescription
modelstringYesComplete public model ID.
messagesarrayYesNon-empty sequence of user and assistant messages.
max_tokensintegerYesMaximum tokens to generate.
systemstring or arrayNoSystem prompt or system content blocks.
streambooleanNoReturn Anthropic SSE events when true.
temperaturenumberNoSampling temperature supported by the model.
top_pnumberNoNucleus sampling value.
top_kintegerNoModel-specific top-k sampling value.
stop_sequencesstring[]NoCustom stop sequences.
toolsarrayNoAnthropic function tool declarations.
tool_choiceobjectNoauto, any, none, or a named tool choice.
metadataobjectNoProvider-compatible request metadata.

Message content can be a string or an array of content blocks. Common block types are text, image, tool_use, and tool_result. URL and base64 image sources are accepted when the selected model supports vision.

Sampling on current Claude models

Claude 4.7 and later models, and Claude Mythos Preview, reject non-default temperature, top_p, and top_k. Omit all three for those models and use prompting to control behavior.

Request example

curl "http://127.0.0.1:11113/v1/messages" -H "x-api-key: $API_KEY" -H "anthropic-version: 2023-06-01" -H "Content-Type: application/json" -d '{
  "model": "anthropic/claude-sonnet-4-5",
  "max_tokens": 256,
  "system": "Answer concisely.",
  "messages": [
    {"role": "user", "content": "What is a model gateway?"}
  ]
}'

Synchronous response

{
  "id": "msg_01J...",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-4-5",
  "content": [
    {
      "type": "text",
      "text": "A model gateway provides one API over multiple AI models."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 12,
    "output_tokens": 13
  }
}

The content field is always an array. Tool requests use tool_use blocks. Reasoning-capable responses can include thinking blocks when the selected model and route expose them. Native refusal responses use stop_reason: "refusal" and can include stop_details with the policy category.

Streaming response

Set stream: true to receive Anthropic event names and payloads. A normal stream follows this lifecycle:

  1. message_start
  2. One or more content_block_start, content_block_delta, and content_block_stop groups
  3. message_delta with the stop reason and final usage
  4. message_stop
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}

event: message_stop
data: {"type":"message_stop"}

Compatibility and restrictions

Same-protocol routes preserve Anthropic fields such as thinking, cache controls, metadata, and provider extensions. Cross-protocol conversion maps system instructions, text and image blocks, tool use and results, function tools, tool choice, output limits, temperature, top_p, stop sequences, stream events, and usage. Nonportable fields can be omitted and reported in x-dropped-params.

Anthropic content blocks have no compatible field for Gemini thought signatures. Multi-turn Gemini function calling through the Messages dialect can therefore fail when the upstream requires that signature; use Gemini Generate Content or another native-compatible route for that workflow.

Missing model, empty messages, or missing max_tokens returns 400 invalid_request. /v1/messages/count_tokens is not exposed. Client routing fields and paid service-tier selections are rejected.

Help us improve this page

Found something unclear, outdated, or incorrect?

Last updated on