Chat completion (Anthropic format)
Anthropic-compatible messages endpoint. The gateway internally translates requests to the upstream format (OpenAI or native Anthropic), and translates responses back to standard Anthropic format before returning to the caller.
Supports streaming: when stream: true, returns a standard Anthropic SSE event stream containing
message_start, content_block_start, content_block_delta, message_stop, and other events.
The anthropic-version: 2023-06-01 header is required.
Authorization
ApiKeyAuth API key authentication (Anthropic format). Pass in the x-api-key header:
x-api-key: tr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
In: header
Header Parameters
Anthropic API version, fixed value 2023-06-01
"2023-06-01"Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X post "https://api.xrtoken.ai/v1/messages" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-3-5-sonnet-20241022", "max_tokens": 1024, "messages": [ { "role": "user", "content": "string" } ] }'{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "string"
}
],
"model": "string",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 0,
"output_tokens": 0
}
}{
"error": "model field is required",
"type": "invalid_request_error"
}{
"error": "invalid or missing API key",
"type": "auth_error"
}{
"error": "insufficient balance -- please top up or upgrade your plan",
"type": "billing_error"
}{
"error": "rate limit exceeded",
"type": "rate_limit_error"
}{
"error": "upstream provider error",
"type": "server_error"
}