Claude
Claude Messages protocol model overview
Claude models use the Anthropic Claude Messages-compatible endpoint instead of the OpenAI choices[].message response structure. This page describes the common Messages protocol and frequent differences.
Endpoint Path
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/messages | Create a Claude Messages conversation |
Request Structure
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Introduce Routescope API in one sentence."
}
]
}curl -X POST "https://api.routescope.ai/v1/messages" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [ { "role": "user", "content": "Hello, please introduce yourself in one sentence." } ], "max_tokens": 1024 }'{
"id": "task_01JZ8M9Q4R7V2K8N9P0Q",
"type": "text",
"role": "user",
"content": "Hello, please introduce yourself in one sentence.",
"model": "gpt-4o-mini",
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1,
"input_tokens": 1,
"output_tokens": 1
},
"stop_reason": "string"
}Authorization
BearerAuth
Model relay interface recognition. Request heading: Autoration: Bearer .
In: header
Request Body
application/json
Claude Model Name.
Message arrays, usually containing only _FD_PROTECT_0 _ and _FD_PROTECT_1 __. Dialogue message list. Scope: At least 1 message.
System tip. Can be a string or block array. system string fields. Scope: Non-empty string or verification by business configuration.
Max output Token. Maximum output number of Tokens. Scope: 1 to the maximum of the context of the model.
1 <= valueSample temperature. Sample temperature. Range: 0 to 2; the larger the value, the more random.
0 <= value <= 2Enables flowback. Whether or not to enable flow output. Scope: True or false.
Claude Tool Definition. . Scope: The length of arrays and the complexity of schema are based on upstream limits.
Response Body
application/json
Model Selection
| Model ID | Typical Use |
|---|---|
claude-haiku-4-5-20251001 | Lightweight conversation |
claude-sonnet-4-20250514, claude-sonnet-4-5-20250929, claude-sonnet-4-6 | General conversation, code, and complex tasks |
claude-opus-4-20250514, claude-opus-4-1-20250805, claude-opus-4-5-20251101, claude-opus-4-6, claude-opus-4-7 | Advanced complex tasks |
Common Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Claude model name. |
messages | array | Yes | Claude Messages message array. |
max_tokens | integer | Yes | Maximum output tokens. |
system | string/array | No | System prompt. |
temperature | number | No | Sampling temperature. |
stream | boolean | No | Whether to stream output. |
tools | array | No | Claude tool definitions. |
Model-Specific Notes
| Field | Applicable Models | Description |
|---|---|---|
model | All Claude models | Pass the concrete model ID in the request body. |
max_tokens | All Claude Messages requests | The OpenAPI schema marks this field as required. Do not omit it. |
Model capability and context | All Claude models | Per-model context, price, and dedicated fields are not normalized here. Follow API responses or the actual console display. |
Example Code
curl https://api.routescope.ai/v1/messages \
-H "Authorization: Bearer $ROUTESCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{ "role": "user", "content": "Introduce Routescope API in one sentence." }
]
}'const response = await fetch("https://api.routescope.ai/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ROUTESCOPE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [
{ role: "user", content: "Introduce Routescope API in one sentence." },
],
}),
});
console.log(await response.json());Response Structure
Claude Messages responses contain Claude content blocks and usage fields. Do not treat them as OpenAI Chat Completions choices[].message responses.
How is this guide?
Last updated on