Anthropic Chat
Official Documentation
Introduction
Given a list of structured input messages containing text and/or image content, the model will generate the next message in the conversation. The Messages API can be used for single queries or stateless multi-turn conversations.
Supported Models
Currently supported models include:
| Model | Description |
|---|---|
| claude-haiku-4-5 | The fastest model with near-frontier intelligence |
| claude-sonnet-4-5 | Claude Sonnet 4.5 chat model (previous generation) |
| claude-sonnet-4-6 | Claude Sonnet 4.6 chat model (previous generation) |
| claude-sonnet-5 | Claude Sonnet 5 chat model (previous generation) |
| claude-sonnet-5.5 | The best combination of speed and intelligence |
| claude-opus-4-5 | Claude Opus 4.5 chat model (previous generation) |
| claude-opus-4-6 | Claude Opus 4.6 chat model (previous generation) |
| claude-opus-4-7 | Claude Opus 4.7 chat model (previous generation) |
| claude-opus-4-8 | Claude Opus 4.8 chat model (previous generation) |
| claude-opus-5 | Claude Opus 5 chat model (previous generation) |
| claude-opus-5.5 | For long-running agentic coding and knowledge work |
| claude-fable-5 | Claude Fable 5 chat model (previous generation) |
| claude-fable-5.1 | For demanding reasoning and long-horizon agentic work |
Request Examples
curl https://www.unodetech.xyz/v1/messages \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--header "x-api-key: $API_KEY" \
--data \
'{
"model": "claude-opus-4-6",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, world"}
]
}'Response Example:
{
"content": [
{
"text": "Hi! My name is Claude.",
"type": "text"
}
],
"id": "msg_013Zva2CMHLNnXjNJKqJ2EF",
"model": "claude-opus-4-6",
"role": "assistant",
"stop_reason": "end_turn",
"stop_sequence": null,
"type": "message",
"usage": {
"input_tokens": 2095,
"output_tokens": 503
}
}curl https://www.unodetech.xyz/v1/messages \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--header "x-api-key: $API_KEY" \
--data \
'{
"model": "claude-opus-4-6",
"messages": [
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "/9j/4AAQSkZJRg..."
}
},
{
"type": "text",
"text": "What's in this image?"
}
]
}
]
}'Response Example:
{
"content": [
{
"text": "This image shows an orange cat sunbathing on a windowsill. The cat looks very relaxed, squinting its eyes while enjoying the sunlight. Some green plants can be seen outside the window.",
"type": "text"
}
],
"id": "msg_013Zva2CMHLNnXjNJKqJ2EF",
"model": "claude-opus-4-6",
"role": "assistant",
"stop_reason": "end_turn",
"stop_sequence": null,
"type": "message",
"usage": {
"input_tokens": 3050,
"output_tokens": 892
}
}curl https://www.unodetech.xyz/v1/messages \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--header "x-api-key: $API_KEY" \
--data \
'{
"model": "claude-opus-4-6",
"messages": [
{
"role": "user",
"content": "What's the weather like in Beijing today?"
}
],
"tools": [
{
"name": "get_weather",
"description": "Get the current weather for a specified location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name, e.g.: Beijing"
}
},
"required": ["location"]
}
}
]
}'Response Example:
{
"content": [
{
"type": "tool_use",
"id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
"name": "get_weather",
"input": { "location": "Beijing" }
}
],
"id": "msg_013Zva2CMHLNnXjNJKqJ2EF",
"model": "claude-opus-4-6",
"role": "assistant",
"stop_reason": "tool_use",
"stop_sequence": null,
"type": "message",
"usage": {
"input_tokens": 2156,
"output_tokens": 468
}
}curl https://www.unodetech.xyz/v1/messages \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--header "x-api-key: $API_KEY" \
--data \
'{
"model": "claude-opus-4-6",
"messages": [
{
"role": "user",
"content": "Tell me a story"
}
],
"stream": true
}'Response Example:
{
"type": "message_start",
"message": {
"id": "msg_013Zva2CMHLNnXjNJKqJ2EF",
"model": "claude-opus-4-6",
"role": "assistant",
"type": "message"
}
}
{
"type": "content_block_start",
"index": 0,
"content_block": {
"type": "text"
}
}
{
"type": "content_block_delta",
"index": 0,
"delta": {
"text": "从前"
}
}
{
"type": "content_block_delta",
"index": 0,
"delta": {
"text": "有一只"
}
}
{
"type": "content_block_delta",
"index": 0,
"delta": {
"text": "小兔子..."
}
}
{
"type": "content_block_stop",
"index": 0
}
{
"type": "message_delta",
"delta": {
"stop_reason": "end_turn",
"usage": {
"input_tokens": 2045,
"output_tokens": 628
}
}
}
{
"type": "message_stop"
}Request
Endpoints
POST /v1/messagesAuthentication Method
Include the following in the request headers for API key authentication:
x-api-key: $API_KEYWhere $API_KEY is your API key. You can obtain an API key from the console, and each key is limited to one workspace.
Request Headers
Request Body Parameters
Response
Successful Response
Returns a chat completion object, containing the following fields:
Error Response
When a request encounters an issue, the API will return an error response object, with HTTP status codes in the 4XX-5XX range.
Common Error Status Codes
401 Unauthorized: Invalid API key or not provided400 Bad Request: Invalid request parameters429 Too Many Requests: Exceeded API call limit500 Internal Server Error: Server internal error
Error response example:
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API key provided",
"code": "invalid_api_key"
}
}Main error types:
invalid_request_error: Request parameter errorauthentication_error: Authentication related errorrate_limit_error: Request frequency exceededserver_error: Server internal error
Last updated on
