Anthropic Messages
Behavior
Use a Messages deployment. Native clients send anthropic-version: 2023-06-01. XHub also accepts its key in x-api-key. Tool use/results are content blocks.
Endpoint and authentication
POST /v1/messagesUse an XHub API key: Authorization: Bearer . Do not use upstream provider credentials as gateway keys.
Use the gateway root Base URL shown in the playground, without appending /v1; send requests to the full endpoint path above.
Request example
curl "$XHUB_BASE_URL/v1/messages" \
-H "Authorization: Bearer $XHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_NAME","max_tokens":256,"messages":[{"role":"user","content":"Hello, introduce yourself."}]}'Request parameters
| Field | Type | Description |
|---|---|---|
| model | string · required | Public model name; deployment must support this protocol. |
| max_tokens | integer · required | Maximum output tokens. |
| messages | object[] · required | User/assistant content blocks. |
| system | string or array | Top-level system instructions. |
| tools / stream | array / boolean | Anthropic tool schema / event stream. |
Success response
{
"id": "msg-example",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello!"
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 10,
"output_tokens": 5
}
}| Field | Type |
|---|---|
| id | string |
| type | string |
| role | string |
| content | object[] |
| content[].type | string |
| content[].text | string |
| stop_reason | string |
| usage | object |
| usage.input_tokens | number |
| usage.output_tokens | number |
Errors and troubleshooting
| HTTP | Meaning |
|---|---|
| 400 | Invalid request. Check JSON, parameters and query. |
| 401 | Missing or invalid XHub credential. |
| 403 | Permission denied. Check model scope or policy. |
| 429 | Limit exceeded. Inspect response details and Retry-After. |