Create a message
Anthropic Messages format, for Anthropic SDKs and Claude Code.
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.
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.
Messages request body (https://docs.anthropic.com/en/api/messages).
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?