Claude API
This platform provides a chat endpoint compatible with the Anthropic Claude Messages API.
This document is intended for client-side integrators and focuses on the public request path, authentication method, request parameters, and example payloads. Field names and JSON structure are kept as close as possible to the native Claude Messages API.
Overview:
- Endpoint:
POST /v1/messages - Capability type: chat / text generation
- Response modes:
- When
stream = falseor omitted: standard JSON response - When
stream = true:text/event-streamSSE response
- When
- Protocol style: the request body follows the native Claude Messages API structure and does not wrap content in an extra
inputfield
1. API Overview
- HTTP method:
POST - Request path:
/v1/messages - Content-Type:
application/json - Response type:
- Non-streaming:
application/json - Streaming:
text/event-stream
- Non-streaming:
2. Authentication and Headers
Example headers:
Authorization: Bearer YOUR_REACH_API_KEY
anthropic-version: 2023-06-01
Content-Type: application/jsonAt least one of Authorization or x-api-key must be provided.
Header details:
| Header | Required | Description |
|---|---|---|
Authorization | No | Platform API key in the format Bearer sk-xxxxxx |
x-api-key | No | You can also pass the platform API key directly in this header |
anthropic-version | Recommended | For Claude Messages API client compatibility, 2023-06-01 is recommended |
Content-Type | Yes | Must be application/json |
3. Request Body
The request body follows the native Claude Messages API object structure:
{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Please introduce yourself in one sentence."
}
],
"max_tokens": 1024,
"temperature": 0.2,
"stream": false
}3.1 Top-Level Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID |
messages | array<object> | Yes | Chat message list |
system | string or array<object> | No | System prompt |
max_tokens | integer | Yes | Maximum number of output tokens, minimum value 1 |
temperature | number | No | Sampling temperature |
top_p | number | No | Nucleus sampling parameter |
top_k | integer | No | Top-k sampling parameter |
stream | boolean | No | Whether to return SSE streaming output |
stop_sequences | array<string> | No | Additional stop sequences |
tools | array<object> | No | Tool definitions |
tool_choice | object | No | Tool calling strategy |
thinking | object | No | Reasoning budget or thinking-mode configuration |
metadata | object | No | Invocation metadata |
3.2 messages Parameter
Each message uses the following structure:
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | Role. Common values: user, assistant |
content | string or array<object> | Yes | Message content. Can be plain text or an array of content blocks |
Text example:
{
"role": "user",
"content": "Write a short product introduction within 50 words."
}Content block example:
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please describe this image."
}
]
}Common content block types:
type | Typical fields | Description |
|---|---|---|
text | text | Text content |
image | source | Image input |
tool_use | id, name, input | Tool call initiated by the model |
tool_result | tool_use_id, content | Tool execution result returned to the model |
4. Request Examples
4.1 Standard Non-Streaming Request
curl -X POST "https://direct.reachapi.ai/v1/messages" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Introduce ReachAPI in one sentence."
}
],
"max_tokens": 512,
"temperature": 0.2
}'4.2 Streaming Request
curl -X POST "https://direct.reachapi.ai/v1/messages" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Summarize today'\''s priorities in three lines."
}
],
"max_tokens": 512,
"stream": true
}'4.3 Request with Tool Definitions
curl -X POST "https://direct.reachapi.ai/v1/messages" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Help me check the weather in Shanghai."
}
],
"max_tokens": 512,
"tools": [
{
"name": "get_weather",
"description": "Get weather information for a city",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": ["city"]
}
}
],
"tool_choice": {
"type": "auto"
}
}'5. Non-Streaming Response
On success, the API returns a standard message object:
{
"id": "msg_01ABCDEF",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "ReachAPI is a unified AI gateway platform."
}
],
"model": "YOUR_MODEL_ID",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 32,
"output_tokens": 18,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}6. Streaming Response
When stream = true, the endpoint returns text/event-stream. Typical events look like this:
event: message_start
data: {"type":"message_start","message":{"id":"msg_1","type":"message","role":"assistant","content":[],"model":"YOUR_MODEL_ID","stop_reason":null,"usage":{"input_tokens":7,"output_tokens":0}}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":13}}
event: message_stop
data: {"type":"message_stop"}7. Error Response
When a request fails, the API returns a JSON error object. Example:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Field `model` is required"
}
}Common scenarios:
- Missing or invalid API key
- Request body is not valid JSON
- Missing
model - Missing
messages
8. Compatibility Notes
- This document lists commonly used fields and example payloads. Actual field names and structures follow the Claude Messages API.
- If you use advanced features such as tool calling or thinking budgets, confirm that the target model actually supports them.
- If your client is built on top of the Anthropic or Claude SDK, passing
anthropic-versionis recommended.
9. Supported Models and Reference Pricing
The following prices are summarized from the unified pricing document and apply to the Claude text models currently listed. Pricing was checked on 2026-04-17. For detailed pricing rules, refer to claude.md.
| Model | Input | Cache write 5m | Cache read | Output |
|---|---|---|---|---|
claude-haiku-4-5 | $1 / 1M tokens | $1.25 / 1M tokens | $0.10 / 1M tokens | $5 / 1M tokens |
claude-sonnet-4-5 | $3 / 1M tokens | $3.75 / 1M tokens | $0.30 / 1M tokens | $15 / 1M tokens |
claude-sonnet-4-6 | $3 / 1M tokens | $3.75 / 1M tokens | $0.30 / 1M tokens | $15 / 1M tokens |
claude-opus-4-5-20251101 | $5 / 1M tokens | $6.25 / 1M tokens | $0.50 / 1M tokens | $25 / 1M tokens |
claude-opus-4-6 | $5 / 1M tokens | $6.25 / 1M tokens | $0.50 / 1M tokens | $25 / 1M tokens |
Notes:
Cache write 5mrefers to the prompt cache write price for the 5-minute tierclaude-opus-4-5-20251101is a snapshot model ID and can be used for version-pinned requests- For longer cache durations or extended context pricing, refer to the detailed pricing document
10. References
- Anthropic Messages API: https://docs.anthropic.com/en/api/messages
- Anthropic Messages examples: https://docs.anthropic.com/en/api/messages-examples
- Unified platform pricing document:
claude.md