Messages API
Send prompts to Claude Opus 5.5, Fable 5.1, Sonnet 4.6 and Haiku 4.5 via the Messages API. Code examples, request/response format, streaming support.
LLMsRelay is an independently operated API gateway. It is not affiliated with or endorsed by Anthropic, PBC. Product and model names are used only to describe compatibility.
Method: POST. URL: https://api.llmsrelay.com/v1/messages. Required fields: model, max_tokens, messages. Streaming: Set stream: true (SSE). Anthropic SDK: 100% compatible.
Endpoint
POST https://api.llmsrelay.com/v1/messages
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID (e.g., claude-opus-5-5) |
| messages | array | Yes | Array of message objects with role and content |
| max_tokens | integer | Yes | Maximum tokens to generate |
| system | string | No | System prompt |
| stream | boolean | No | Enable streaming (default: false) |
| top_p | number | No | Nucleus sampling parameter |
| top_k | integer | No | Top-k sampling parameter |
| stop_sequences | array | No | Custom stop sequences |
Example Request
Messages API Requestbash
curl https://api.llmsrelay.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"system": "You are a helpful assistant.",
"messages": [
{"role": "user", "content": "Explain quantum computing in one paragraph."}
]
}'Response
Example Responsejson
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Quantum computing leverages quantum mechanical phenomena..."
}
],
"model": "claude-opus-5-5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 150
}
}Streaming
Set "stream": true in the request body to receive Server-Sent Events. See the Streaming page for details.