# Create message (/docs/reference/anthropic-compatible/createMessage)

> For AI agents, the [documentation index](https://bitrouter-docs-staging.up.railway.app/llms.txt) lists all pages. Append .md to a documentation URL to read its Markdown.

`POST /v1/messages`

Creates a message using the Anthropic Messages API format. Drop-in replacement for the Anthropic API.

When `stream: true`, the response is sent as Server-Sent Events (SSE). Each event has a `type` field indicating the event kind (`message_start`, `content_block_delta`, `message_delta`, `message_stop`).

## Authentication

header parameter `x-api-key` or `Authorization: Bearer <token>`.

Base URL: `https://api.bitrouter.ai`

## Request body

Anthropic Messages request.

Media types: `application/json`.

* `max_tokens`: integer | null
* `messages` (required): array
* `model` (required): string
* `output_config`
* `stop_sequences`: array | null
* `stream`: boolean
* `system`
* `temperature`: number | null
* `tools`: array
* `top_k`: integer | null
* `top_p`: number | null

## Responses

* `200` Messages response (non-streaming). Streamed Messages response — Server-Sent Events. Each event has a `type` field (`message_start`, `content_block_delta`, …). (application/json, text/event-stream)
* `400` Bad request — invalid model or malformed request body. (application/json)
* `402` Payment required — insufficient balance or missing payment proof. (application/json)
* `404` No route found for the requested model. (application/json)
* `429` Rate limited by BitRouter or by every usable upstream route. Inspect error.code to distinguish rate\_limit\_exceeded from upstream\_rate\_limited; Retry-After is included when known. (application/json)
* `500` BitRouter internal error. (application/json)
* `502` Upstream returned an invalid response. (application/json)
* `503` The usable upstream route set is temporarily unavailable. (application/json)
* `504` Every usable upstream route timed out. (application/json)

[Full OpenAPI schema](https://bitrouter-docs-staging.up.railway.app/openapi.json)