Messages
The Messages API is the primary way to interact with Claude models through Claudexia. Send a structured list of messages and receive a model-generated response.
Endpoint
POST https://api.claudexia.tech/v1/messagesAuthentication
Include your API key in the x-api-key header:
x-api-key: sk_cdx_YOUR_KEYRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model ID to use (e.g. claude-sonnet-4-20250514). |
max_tokens | integer | Yes | Maximum number of tokens to generate. |
messages | array | Yes | Array of message objects with role ("user" or "assistant") and content (string or array of content blocks). |
system | string | No | System prompt to guide the model's behavior. |
temperature | number | No | Sampling temperature between 0 and 1. Default: 1. |
top_p | number | No | Nucleus sampling parameter. Default: 0.999. |
stream | boolean | No | If true, returns a stream of Server-Sent Events. Default: false. |
thinking | object | No | Enable extended thinking. See Thinking below. |
Response
| Field | Type | Description |
|---|---|---|
id | string | Unique message ID (e.g. msg_01XFDUDYJgAACzvnptvVoYEL). |
type | string | Always "message". |
role | string | Always "assistant". |
content | array | Array of content blocks. Each block has type ("text") and text. |
model | string | The model that generated the response. |
stop_reason | string | Why the model stopped: "end_turn", "max_tokens", or "stop_sequence". |
usage | object | Token usage with input_tokens and output_tokens. |
Example
Request
curl https://api.claudexia.tech/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk_cdx_YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'Response
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"model": "claude-sonnet-4.5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 12,
"output_tokens": 10
}
}Streaming
Set stream: true in the request body to receive the response as a stream of Server-Sent Events (SSE). See the Streaming page for details on the event format.
curl --no-buffer https://api.claudexia.tech/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk_cdx_<YOUR_KEY>" \
-H "anthropic-version: 2023-06-01" \
-H "accept: text/event-stream" \
-d '{
"model": "claude-opus-4.7",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Hello"}]
}'Vision (image blocks)
When using vision-capable models, send multimodal content: mix text with image blocks (URL source shown below).
{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{
"type": "image",
"source": {"type": "url", "url": "https://example.com/picture.jpg"}
}
]
}
]
}Thinking (Extended Thinking)
Enable extended thinking to let the model reason through complex problems before responding. Pass a thinking object in the request body:
{
"model": "claude-sonnet-4.5",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{"role": "user", "content": "What is the derivative of x^3 * sin(x)?"}
]
}When thinking is enabled, the response content array may include a block with type: "thinking" containing the model's reasoning, followed by the final type: "text" response. The budget_tokens parameter controls the maximum tokens allocated for the thinking process.