Skip to content

Anthropic Messages API

POST
/v1/messages
curl --request POST \
--url https://api.mirapi.ai/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'anthropic-version: ' \
--header 'x-api-key: ' \
--data '{ "model": "claude-3-opus-20240229", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "example", "source": { "type": "base64", "media_type": "example", "data": "example", "url": "example" }, "id": "example", "name": "example", "input": {}, "tool_use_id": "example", "content": "example" } ] } ], "system": [ {} ], "max_tokens": 1, "temperature": 1, "top_p": 1, "top_k": 1, "stream": true, "stop_sequences": [ "example" ], "tools": [ { "name": "example", "description": "example", "input_schema": {} } ], "tool_choice": { "type": "auto", "name": "example" }, "thinking": { "type": "enabled", "budget_tokens": 1 }, "metadata": { "user_id": "example" } }'

Request in the Anthropic Claude Messages API format. The anthropic-version header is required.

anthropic-version
required
string

Anthropic API version

Example
x-api-key
string

Anthropic API key (optional — a Bearer token also works)

Example
Media typeapplication/json
object
model
required
string
messages
required
Array<object>
object
role
required
string
Allowed values: user assistant
content
required
One of:
string
system
One of:
string
max_tokens
required
integer
>= 1
temperature
number
<= 1
top_p
number
top_k
integer
stream
boolean
stop_sequences
Array<string>
tools
Array<object>
object
name
string
description
string
input_schema
object
tool_choice
One of:
object
type
string
Allowed values: auto any tool
name
string
thinking
object
type
string
Allowed values: enabled disabled
budget_tokens
integer
metadata
object
user_id
string
Examples

Response created

Media typeapplication/json
object
id
string
type
string
role
string
content
Array<object>
object
type
string
text
string
model
string
stop_reason
string
Allowed values: end_turn max_tokens stop_sequence tool_use
usage
object
input_tokens
integer
output_tokens
integer
cache_creation_input_tokens
integer
cache_read_input_tokens
integer
Example
{
"type": "message",
"role": "assistant",
"stop_reason": "end_turn"
}