Anthropic Messages
Generate text using the Anthropic Messages format with the Anthropic SDK or Claude Code.
POSThttps://api.outerlane.app/v1/messages
This endpoint follows the Anthropic Messages format. You can call any supported text model with it, including models from other providers.
Example request
curl https://api.outerlane.app/v1/messages \
-H "x-api-key: $OUTERLANE_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5-5",
"max_tokens": 1024,
"output_config": { "effort": "medium" },
"messages": [
{ "role": "user", "content": "Why does idempotency matter in REST APIs?" }
]
}'Request body
modelstringRequired
Text model ID. Models from other providers are also supported.
max_tokensintegerRequired
Maximum output tokens, at least 1
messagesobject[]Required
systemstring | object[]
System prompt. Only text blocks are accepted.
output_config.effortstring
output_config.formatobject
Structured outputs using
{ "type": "json_schema", "schema": {...} }toolsobject[]
tool_choiceobject
auto, any, none, or tool with a required name. Also accepts disable_parallel_tool_use.streamboolean
Set to
true to receive Anthropic SSE events.thinkingobject
Accepted for compatibility. Use
output_config.effort to control reasoning.temperature, top_p, stop_sequences, and metadata.user_id are forwarded with their Anthropic semantics.
Content blocks
- Use
textandimageblocks. Send images ashttp(s)URLs or base64-encoded PNG, JPEG, GIF, or WebP. - Use an
assistanttool_useblock followed by ausertool_resultblock. Thecontentoftool_resultmust be a string or text blocks. - PDF and document blocks and images inside
tool_resultreturn400 invalid_request_error. - The gateway removes
thinkingandredacted_thinkingblocks from prior responses. You can resend the receivedcontentarray as-is. cache_controlinsystemis ignored.
Response
{
"id": "msg_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-sonnet-5-5",
"content": [{ "type": "text", "text": "..." }],
"stop_reason": "end_turn",
"usage": { "input_tokens": 32, "output_tokens": 140, "cache_read_input_tokens": 0 },
"x_outerlane": {
"request_id": "req_a1b2c3d4e5f6a1b2c3d4e5f6",
"input": 32,
"cached": 0,
"output": 140,
"costUsd": 0.000732,
"chargedUsd": 0.000732,
"reasoning_effort": "medium"
}
}contentincludesthinking,tool_use, andtextblocks in that order when present.stop_reasonisend_turn,max_tokens,tool_use, orrefusal.usage.input_tokensexcludes cache hits. Look for them incache_read_input_tokens.
Streaming
With stream: true, the endpoint sends standard Anthropic events in this order.
message_start: Starts a message with emptycontentcontent_block_start→content_block_delta→content_block_stop: Repeats for each content block. The delta isthinking_delta,text_delta, orinput_json_delta.message_delta:stop_reasonand token counts (usage)message_stop
For a tool call, one input_json_delta contains the complete JSON arguments. Streaming responses omit x_outerlane. Check Request logs for cost.
Errors
This endpoint uses the Anthropic error format. See Error response formats for error.type by HTTP status.