For AI agents, the documentation index lists all pages. Append .md to a documentation URL for Markdown, or request text/markdown.

Skip to Content
spare inference

Create a message

Anthropic Messages format, for Anthropic SDKs and Claude Code.

1 min readEdit this page
POST
/v1/messages

Anthropic Messages format, so Anthropic SDKs and Claude Code work unchanged. Send stream: true for Server-Sent Events (message_start, content_block_delta, message_delta, message_stop). Errors use Anthropic's error shape.

Authorization

x-api-key<token>

x-api-key: <key>. Anthropic SDKs send this.

In: header

Request Body

application/json

Anthropic Messages request.

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

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  }}

How is this guide?