# Anthropic Messages Format

## Create Message (Anthropic 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/messages\\`\\>
> \- \`POST <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.

```json
{"openapi":"3.1.0","info":{"title":"FastRouter API Reference","version":"1.0.0"},"tags":[{"name":"Anthropic Messages","description":"Anthropic-native Messages API. Send requests in Anthropic's native format with FastRouter authentication. Supports streaming, tool use, extended thinking, and all Claude model features."}],"servers":[{"url":"https://api.fastrouter.ai","description":"Production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"FastRouter API Key. Get yours at https://fastrouter.ai\n\nFormat: `Authorization: Bearer YOUR_API_KEY`"}},"responses":{"BadRequestError":{"description":"Bad Request - The request is malformed. This could be due to missing parameters, invalid formats, or CORS issues.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}},"UnauthorizedError":{"description":"Invalid Credentials - Your API key is invalid, disabled, or your OAuth session has expired. Check your credentials.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}},"RateLimitError":{"description":"Rate Limited - You have exceeded your request limits (TPM/RPM). Slow down or increase your limits.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}},"InternalServerError":{"description":"Internal Error - Something went wrong on our side. Retry the request, and contact support if the issue persists.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}}}},"paths":{"/api/v1/messages":{"post":{"operationId":"createAnthropicMessage","tags":["Anthropic Messages"],"summary":"Create Message (Anthropic Format)","description":"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.\n\n**Available at both:**\n- `POST https://api.fastrouter.ai/api/v1/messages`\n- `POST https://api.fastrouter.ai/v1/messages`\n\n**Authentication:** Use your FastRouter API key via either:\n- `x-api-key: YOUR_API_KEY` (Anthropic style)\n- `Authorization: Bearer YOUR_API_KEY` (OpenAI style)\n\n**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.).\n\n**Cost tracking:** The response `usage` object includes a `cost` field showing credits consumed.\n\n**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.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages","max_tokens"],"properties":{"model":{"type":"string","description":"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`"},"messages":{"type":"array","description":"Array of input messages. Each message has a role (user or assistant) and content.","minItems":1,"items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["user","assistant"],"description":"The role of the message author. System messages are passed via the top-level system parameter."},"content":{"description":"Message content. Can be a string or an array of content blocks.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text","image","tool_use","tool_result"]},"text":{"type":"string"}}}}]}}}},"max_tokens":{"type":"integer","description":"The maximum number of tokens to generate. Required for all requests."},"system":{"type":"string","description":"System prompt. Provides instructions or context to the model."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Randomness. Ranges from 0.0 to 1.0."},"top_p":{"type":"number","description":"Nucleus sampling parameter."},"top_k":{"type":"integer","description":"Only sample from the top K options for each subsequent token."},"stop_sequences":{"type":"array","items":{"type":"string"},"description":"Custom text sequences that will cause the model to stop generating."},"stream":{"type":"boolean","default":false,"description":"Whether to stream the response using SSE."},"tools":{"type":"array","description":"Definitions of tools that the model may use.","items":{"type":"object","properties":{"name":{"type":"string","description":"Name of the tool."},"description":{"type":"string","description":"Description of what the tool does."},"input_schema":{"type":"object","description":"JSON Schema for the tool input."}}}},"tool_choice":{"type":"object","description":"How the model should use the provided tools.","properties":{"type":{"type":"string","enum":["auto","any","tool"]},"name":{"type":"string","description":"Tool name (when type is tool)."}}},"thinking":{"type":"object","description":"Extended thinking configuration for Claude models.","properties":{"type":{"type":"string","enum":["enabled","disabled"]},"budget_tokens":{"type":"integer","description":"Max tokens for thinking."}}}}}}}},"responses":{"200":{"description":"Message created successfully","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Unique message identifier"},"type":{"type":"string","enum":["message"]},"role":{"type":"string","enum":["assistant"]},"content":{"type":"array","description":"Response content blocks (text, tool_use, thinking).","items":{"type":"object","properties":{"type":{"type":"string","enum":["text","tool_use","thinking"]},"text":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"input":{"type":"object"}}}},"model":{"type":"string"},"stop_reason":{"type":"string","enum":["end_turn","max_tokens","stop_sequence","tool_use"]},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer"},"output_tokens":{"type":"integer"},"cost":{"type":"number","description":"Credits consumed"}}}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"429":{"$ref":"#/components/responses/RateLimitError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fastrouter.ai/api-reference/anthropic-messages-format.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
