Anthropic Messages Format
Creates a message using Anthropic's native Messages API format. Supports all Claude models through FastRouter with full feature parity including streaming, tool use, extended thinking, and vision.
Available at both:
POST https://api.fastrouter.ai/api/v1/messagesPOST https://api.fastrouter.ai/v1/messages
Authentication: Use your FastRouter API key via either:
x-api-key: YOUR_API_KEY(Anthropic style)Authorization: Bearer YOUR_API_KEY(OpenAI style)
Streaming: Set stream: true to receive Server-Sent Events (SSE) with Anthropic's native streaming format (message_start, content_block_start, content_block_delta, message_delta, etc.).
Cost tracking: The response usage object includes a cost field showing credits consumed.
Drop-in replacement: This endpoint is a drop-in replacement for Anthropic's /v1/messages API. Simply change the base URL to https://api.fastrouter.ai and use your FastRouter API key.
FastRouter API Key. Get yours at https://fastrouter.ai
Format: Authorization: Bearer YOUR_API_KEY
Model ID. Use anthropic/ prefix or bare Anthropic model name. Examples: anthropic/claude-sonnet-4-20250514, claude-sonnet-4-20250514, anthropic/claude-opus-4-20250514
anthropic/claude-sonnet-4-20250514The maximum number of tokens to generate. Required for all requests.
1024System prompt. Provides instructions or context to the model.
Randomness. Ranges from 0.0 to 1.0.
1Nucleus sampling parameter.
0.999Only sample from the top K options for each subsequent token.
Custom text sequences that will cause the model to stop generating.
Whether to stream the response using SSE.
falseExample: falseMessage created successfully
Unique message identifier
msg_01XFDUDYJgAACzvnptvVoYELmessagePossible values: assistantPossible values: claude-sonnet-4-20250514end_turnPossible values: Bad Request - The request is malformed. This could be due to missing parameters, invalid formats, or routing errors.
Note: the 400 body shape is not uniform. Validation errors return the structured object below, but routing/model errors may instead return a plain string: { "error": "<message>" }. A few endpoints (e.g. some file operations) may return a plain-text body rather than JSON.
Invalid Credentials - Your API key is invalid, missing, or disabled. Check your credentials.
Note: the 401 error body uses code, message, param, and type (there is no status field), and type is invalid_request_error.
Rate Limited - You have exceeded your request limits (TPM/RPM). Slow down or increase your limits.
Internal Error - Something went wrong on our side. Retry the request, and contact support if the issue persists.
POST /api/v1/messages HTTP/1.1
Host: api.fastrouter.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 125
{
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking."
}
],
"model": "claude-sonnet-4-20250514",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 14,
"output_tokens": 18,
"cost": 0.000234
}
}Last updated
