Create a Message
POST/v1/messages
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our user guide
Headers
Body
Returns
Create a Message
curl https://api.anthropic.com/v1/messages \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" \
--max-time 600 \
-d '{
"max_tokens": 1024,
"messages": [
{
"content": "Hello, world",
"role": "user"
}
],
"model": "claude-opus-5",
"stream": false,
"system": [
{
"text": "Today'\''s date is 2024-06-01.",
"type": "text"
}
],
"temperature": 1,
"thinking": {
"type": "adaptive"
},
"tools": [
{
"input_schema": {
"type": "object",
"properties": {
"location": "bar",
"unit": "bar"
},
"required": [
"location"
]
},
"name": "name"
}
],
"top_k": 5,
"top_p": 0.7
}'{
"id": "msg_013Zva2CMHLNnXjNJJKqJ2EF",
"container": {
"id": "container_011CpZohnwH4vuy7gazohgSP",
"expires_at": "2019-12-27T18:11:19.117Z",
"skills": [
{
"skill_id": "pdf",
"type": "anthropic",
"version": "latest"
}
]
},
"content": [
{
"citations": [
{
"cited_text": "The grass is green. The sky is blue.",
"document_index": 0,
"document_title": "My Document",
"end_char_index": 0,
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
"start_char_index": 0,
"type": "char_location"
}
],
"text": "Hi! My name is Claude.",
"type": "text"
}
],
"model": "claude-opus-5",
"role": "assistant",
"stop_details": {
"category": "cyber",
"explanation": "This request was declined because it conflicts with Anthropic's Usage Policy.",
"type": "refusal"
},
"stop_reason": "end_turn",
"stop_sequence": null,
"type": "message",
"usage": {
"cache_creation": {
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 0
},
"cache_creation_input_tokens": 2051,
"cache_read_input_tokens": 2051,
"inference_geo": "global",
"input_tokens": 2095,
"output_tokens": 503,
"output_tokens_details": {
"thinking_tokens": 0
},
"server_tool_use": {
"web_fetch_requests": 2,
"web_search_requests": 0
},
"service_tier": "standard"
}
}Returns Examples
{
"id": "msg_013Zva2CMHLNnXjNJJKqJ2EF",
"container": {
"id": "container_011CpZohnwH4vuy7gazohgSP",
"expires_at": "2019-12-27T18:11:19.117Z",
"skills": [
{
"skill_id": "pdf",
"type": "anthropic",
"version": "latest"
}
]
},
"content": [
{
"citations": [
{
"cited_text": "The grass is green. The sky is blue.",
"document_index": 0,
"document_title": "My Document",
"end_char_index": 0,
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
"start_char_index": 0,
"type": "char_location"
}
],
"text": "Hi! My name is Claude.",
"type": "text"
}
],
"model": "claude-opus-5",
"role": "assistant",
"stop_details": {
"category": "cyber",
"explanation": "This request was declined because it conflicts with Anthropic's Usage Policy.",
"type": "refusal"
},
"stop_reason": "end_turn",
"stop_sequence": null,
"type": "message",
"usage": {
"cache_creation": {
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 0
},
"cache_creation_input_tokens": 2051,
"cache_read_input_tokens": 2051,
"inference_geo": "global",
"input_tokens": 2095,
"output_tokens": 503,
"output_tokens_details": {
"thinking_tokens": 0
},
"server_tool_use": {
"web_fetch_requests": 2,
"web_search_requests": 0
},
"service_tier": "standard"
}
}