Anthropic CompatibleCreate message

Create message

1 min readEdit this page
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).

Authorization

x-api-key<token>

Anthropic-style API key header.

In: header

Request Body

application/json

Anthropic Messages request.

TypeScript Definitions

Use the request body type in TypeScript.

Messages request body (https://docs.anthropic.com/en/api/messages).

pub so downstream crates (notably bitrouter-cloud) can derive an OpenAPI schema from the canonical wire shape without redeclaring it.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/v1/messages" \  -H "Content-Type: application/json" \  -d '{    "messages": [      {        "content": null,        "role": "string"      }    ],    "model": "string"  }'
{  "content": [    {      "text": "string",      "type": "string"    }  ],  "id": "string",  "model": "string",  "role": "string",  "stop_reason": "string",  "stop_sequence": "string",  "type": "string",  "usage": {    "cache_creation_input_tokens": 0,    "cache_read_input_tokens": 0,    "input_tokens": 0,    "output_tokens": 0  }}
{  "error": {    "code": "string",    "message": "string"  }}
{  "error": {    "code": "string",    "message": "string"  }}
{  "error": {    "code": "string",    "message": "string"  }}

How is this guide?