Messages
Create messages using the Anthropic-compatible API format.Endpoint
Examples
- Python
- JavaScript
- cURL
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (e.g., claude-sonnet-4.5) |
messages | array | Yes | Array of message objects |
max_tokens | integer | Yes | Maximum tokens to generate |
system | string | No | System prompt |
temperature | number | No | Sampling temperature (0-1) |
top_p | number | No | Nucleus sampling parameter |
top_k | integer | No | Top-k sampling parameter |
stream | boolean | No | Enable streaming responses |
stop_sequences | array | No | Custom stop sequences |
Message Object
| Field | Type | Description |
|---|---|---|
role | string | Either user or assistant |
content | string or array | Text content or content blocks |
Response
Response Fields
| Field | Type | Description |
|---|---|---|
id | string | Unique message ID |
type | string | Always message |
role | string | Always assistant |
content | array | Array of content blocks |
model | string | Model used |
stop_reason | string | Why generation stopped (end_turn, max_tokens, stop_sequence) |
usage | object | Token usage statistics |
System Prompts
- Python
- JavaScript
- cURL
Multi-turn Conversations
- Python
- JavaScript
- cURL
Streaming
- Python
- JavaScript
- cURL
Available Models
| Model | Description |
|---|---|
claude-opus-4.5 | Most capable, best for complex tasks |
claude-sonnet-4.5 | Balanced performance and speed |
claude-haiku-4.5 | Fastest, best for simple tasks |
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer sk_your_key |
Content-Type | Yes | application/json |
anthropic-version | Recommended | API version (e.g., 2023-06-01) |