Create message (Claude native API)
Create a message using Anthropic Claude’s native API format, supports streaming
Request
POST /messages
Request Body
| Field | Type | Required | Description |
|---|
| model | string | Yes | Claude model name |
| messages | Array<AnthropicMessageMessage> | Yes | Messages list, first message must be a user message |
| system | string | No | System prompt |
| max_tokens | integer | No | Maximum number of output tokens (optional).If not provided, the relay service or API may use a default value.Different models have different maximum values. |
| stop_sequences | Array | No | Stop sequences |
| stream | boolean | No | - |
| temperature | number | No | - |
| top_p | number | No | - |
| top_k | integer | No | Top-k sampling parameter. Only sample from the top K options for each subsequent token. |
| tools | Array<AnthropicTool> | No | - |
| tool_choice | string (none, auto, any) | No | - |
| metadata | object | No | An object describing metadata about the request. Can be used for tracking, identification, or filtering purposes.Common use cases: user_id, session_id, request_id, etc. |
| thinking | object | No | Configuration for extended thinking (Claude 3.7+). When enabled, the model will spend more time thinking before responding. |
| service_tier | string (auto, standard_only) | No | Service tier for request processing:- auto: Automatically select between standard and priority capacity- standard_only: Only use standard capacity (may have longer wait times during high load) |
Request Examples
Simple Claude message
{
"model": "claude-opus-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello, Claude!"
}
]
}
]
}
Message with system prompt
{
"model": "claude-sonnet-4.5",
"max_tokens": 2048,
"system": "You are a helpful coding assistant.",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "How do I write a Python function?"
}
]
}
],
"temperature": 0.7
}
Image understanding (Vision)
{
"model": "claude-sonnet-4.5",
"max_tokens": 2048,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What do you see in this image?"
},
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "/9j/4AAQSkZJRg..."
}
}
]
}
],
"temperature": 0.5
}
With tool calls
{
"model": "claude-opus-4.5",
"max_tokens": 4096,
"system": "You are a helpful assistant with access to tools.",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What's the weather in Paris and what time is it there?"
}
]
}
],
"tools": [
{
"name": "get_weather",
"description": "Get current weather information for a location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name"
},
"units": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "Temperature units"
}
},
"required": [
"location"
]
}
},
{
"name": "get_time",
"description": "Get current time for a location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City or timezone"
}
},
"required": [
"location"
]
}
}
],
"tool_choice": "auto"
}
Tool use result response
{
"model": "claude-sonnet-4.5",
"max_tokens": 2048,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What's the weather in Tokyo?"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_01A",
"name": "get_weather",
"input": {
"location": "Tokyo",
"units": "celsius"
}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01A",
"content": "{\"temperature\": 22, \"condition\": \"cloudy\", \"humidity\": 70}"
}
]
}
],
"tools": [
{
"name": "get_weather",
"description": "Get weather information",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string"
},
"units": {
"type": "string"
}
},
"required": [
"location"
]
}
}
]
}
Multi-turn conversation with tool calls
{
"model": "claude-opus-4.5",
"max_tokens": 4096,
"system": "You are a research assistant. Use tools when needed to provide accurate information.",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Find me information about the latest SpaceX launch"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_01B",
"name": "web_search",
"input": {
"query": "latest SpaceX launch",
"max_results": 5
}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01B",
"content": "{\"results\": [{\"title\": \"SpaceX Starship Launch\", \"date\": \"2024-12-15\", \"summary\": \"...\"}]}"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Based on the search results, the latest SpaceX launch was..."
}
]
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "What was the weather during that launch?"
}
]
}
],
"tools": [
{
"name": "web_search",
"description": "Search the web",
"input_schema": {
"type": "object",
"properties": {
"query": {
"type": "string"
},
"max_results": {
"type": "integer"
}
},
"required": [
"query"
]
}
},
{
"name": "get_weather",
"description": "Get weather information",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string"
},
"date": {
"type": "string"
}
},
"required": [
"location"
]
}
}
],
"temperature": 0.7
}
Streaming
{
"model": "claude-sonnet-4.5",
"max_tokens": 3000,
"stream": true,
"system": "You are a creative writing assistant.",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Write a short story about a robot learning to paint"
}
]
}
],
"temperature": 0.9
}
Specify specific tool
{
"model": "claude-opus-4.5",
"max_tokens": 2048,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Tell me about the weather"
}
]
}
],
"tools": [
{
"name": "get_weather",
"description": "Get weather information",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string"
}
},
"required": [
"location"
]
}
},
{
"name": "get_forecast",
"description": "Get weather forecast",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string"
},
"days": {
"type": "integer"
}
},
"required": [
"location"
]
}
}
],
"tool_choice": {
"type": "tool",
"name": "get_weather"
}
}
Complex multimodal conversation
{
"model": "claude-opus-4.5",
"max_tokens": 4096,
"system": "You are an AI assistant helping with data analysis and visualization.",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Analyze this chart and tell me the trends"
},
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": "iVBORw0KGgoAAAANS..."
}
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "I can see the chart shows a clear upward trend..."
}
]
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "Can you fetch the latest data to compare?"
}
]
}
],
"tools": [
{
"name": "fetch_data",
"description": "Fetch latest dataset",
"input_schema": {
"type": "object",
"properties": {
"dataset_id": {
"type": "string"
},
"date_range": {
"type": "string"
}
},
"required": [
"dataset_id"
]
}
}
],
"temperature": 0.5,
"top_p": 0.9,
"top_k": 40
}
Using stop sequences
{
"model": "claude-sonnet-4.5",
"max_tokens": 1500,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Generate a numbered list of programming tips"
}
]
}
],
"stop_sequences": [
"\n\n",
"Conclusion"
],
"temperature": 0.8
}
Successful response
Response Schema
| Field | Type | Required | Description |
|---|
| id | string | Yes | - |
| type | string | Yes | - |
| role | string | Yes | - |
| content | Array<AnthropicContent> | Yes | - |
| model | string | Yes | - |
| stop_reason | object | Yes | Reason why the model stopped:- end_turn: Natural completion- max_tokens: Hit max_tokens limit- stop_sequence: Hit a stop sequence- tool_use: Model wants to use a tool- pause_turn: Long-running task paused (extended thinking)- refusal: Content policy violation |
| stop_sequence | object | No | - |
| usage | object | Yes | - |
Response Example
{
"id": "msg_123",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! It's nice to meet you. How can I help you today?"
}
],
"model": "claude-opus-4.5",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 15
}
}
Code Examples
JavaScript (Fetch)
const response = await fetch('https://api.uuroute.ai/v1/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"model": "claude-opus-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello, Claude!"
}
]
}
]
})
});
const data = await response.json();
console.log(data);
Python (requests)
import requests
url = "https://api.uuroute.ai/v1/messages"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.post(url, json={
"model": "claude-opus-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello, Claude!"
}
]
}
]
}, headers=headers)
data = response.json()
print(data)
cURL
curl -X POST "https://api.uuroute.ai/v1/messages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"claude-opus-4.5","max_tokens":1024,"messages":[{"role":"user","content":[{"type":"text","text":"Hello, Claude!"}]}]}'
Schema Reference
AnthropicMessageRequest
| Field | Type | Required | Description |
|---|
| model | string | Yes | Claude model name |
| messages | Array<AnthropicMessageMessage> | Yes | Messages list, first message must be a user message |
| system | string | No | System prompt |
| max_tokens | integer | No | Maximum number of output tokens (optional).If not provided, the relay service or API may use a default value.Different models have different maximum values. |
| stop_sequences | Array | No | Stop sequences |
| stream | boolean | No | - |
| temperature | number | No | - |
| top_p | number | No | - |
| top_k | integer | No | Top-k sampling parameter. Only sample from the top K options for each subsequent token. |
| tools | Array<AnthropicTool> | No | - |
| tool_choice | string (none, auto, any) | No | - |
| metadata | object | No | An object describing metadata about the request. Can be used for tracking, identification, or filtering purposes.Common use cases: user_id, session_id, request_id, etc. |
| thinking | object | No | Configuration for extended thinking (Claude 3.7+). When enabled, the model will spend more time thinking before responding. |
| service_tier | string (auto, standard_only) | No | Service tier for request processing:- auto: Automatically select between standard and priority capacity- standard_only: Only use standard capacity (may have longer wait times during high load) |
AnthropicMessageMessage
| Field | Type | Required | Description |
|---|
| role | string (user, assistant) | Yes | Role of the message sender (user or assistant) |
| content | Array<AnthropicContent> | Yes | Message content - can be array of content blocks or string |
AnthropicContent
AnthropicTextContent
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| text | string | Yes | - |
AnthropicImageContent
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| source | object | Yes | - |
AnthropicImageSource
AnthropicImageSourceBase64
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| media_type | string (image/jpeg, image/png, image/gif, image/webp) | Yes | MIME type of the image |
| data | string | Yes | Base64-encoded image data |
AnthropicImageSourceUrl
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| url | string | Yes | URL of the image to fetch |
AnthropicDocumentContent
| Field | Type | Required | Description |
|---|
| type | string | Yes | Document content type (PDFs, text files, etc.) |
| source | object | Yes | - |
AnthropicDocumentSource
AnthropicDocumentSourceBase64
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| media_type | string (application/pdf, text/plain) | Yes | Document MIME type |
| data | string | Yes | Base64-encoded document data |
AnthropicDocumentSourceUrl
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| url | string | Yes | URL of the document to fetch |
AnthropicThinkingContent
| Field | Type | Required | Description |
|---|
| type | string | Yes | Extended thinking output content |
| thinking | string | Yes | The model’s thinking process/reasoning |
| signature | string | No | Cryptographic signature for thinking content verification |
AnthropicToolContent
AnthropicToolUseContent
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| id | string | Yes | Unique identifier for this tool use |
| name | string | Yes | Name of the tool being called |
| input | object | Yes | Input parameters for the tool |
AnthropicToolResultContent
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| tool_use_id | string | Yes | ID of the tool use this result corresponds to |
| content | string | Yes | Result of the tool execution |
AnthropicTool
| Field | Type | Required | Description |
|---|
| name | string | Yes | - |
| description | string | No | - |
| input_schema | object | Yes | - |
AnthropicInputSchema
| Field | Type | Required | Description |
|---|
| type | string | Yes | - |
| properties | object | No | - |
| required | Array | No | - |
AnthropicMessageResponse
| Field | Type | Required | Description |
|---|
| id | string | Yes | - |
| type | string | Yes | - |
| role | string | Yes | - |
| content | Array<AnthropicContent> | Yes | - |
| model | string | Yes | - |
| stop_reason | object | Yes | Reason why the model stopped:- end_turn: Natural completion- max_tokens: Hit max_tokens limit- stop_sequence: Hit a stop sequence- tool_use: Model wants to use a tool- pause_turn: Long-running task paused (extended thinking)- refusal: Content policy violation |
| stop_sequence | object | No | - |
| usage | object | Yes | - |
Related APIs