Skip to main content
POST
https://console.mixroute.io
/
v1
/
messages
curl --request POST \
  --url https://console.mixroute.io/v1/messages \
  --header 'Authorization: Bearer sk-xxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --header 'anthropic-version: 2023-06-01' \
  --data '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Briefly explain artificial intelligence"}
    ]
  }'
{
  "id": "msg_xxx",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Artificial intelligence is a new technical science that researches and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence..."
    }
  ],
  "model": "claude-sonnet-4-5-20250929",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 25,
    "output_tokens": 100
  }
}

Introduction

The Messages API provides native Anthropic Claude interface compatibility through Mixroute Api, allowing direct use of Anthropic SDKs and tools like Claude Code. This interface follows Anthropic’s API specification and provides full Claude model functionality, including Extended Thinking, tool calling, and other advanced features. If you’re using OpenAI-compatible clients (like OpenAI SDK), we recommend using the /v1/chat/completions endpoint instead.

Authentication

Bearer Token, e.g., Bearer sk-xxxxxxxxxx

Request Parameters

model
string
required
Claude model identifier, e.g., claude-sonnet-4-5-20250929, claude-opus-4-5-20251101
messages
array
required
List of conversation messages, each containing role (user/assistant) and content
max_tokens
integer
required
Maximum tokens to generate, must be greater than 0
system
string | array
System prompt, supports string format or array format (for Prompt Caching)
stream
boolean
Enable streaming output
temperature
number
Sampling temperature, range 0-1
top_p
number
Nucleus sampling parameter, range 0-1
top_k
integer
Top-k sampling parameter
stop_sequences
array
Custom stop sequences
thinking
object
Extended thinking configuration, contains type and budget_tokens
tools
array
List of tool definitions

Basic Examples

curl -X POST "https://console.mixroute.io/v1/messages" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Briefly explain artificial intelligence"}
    ]
  }'

Advanced Features

System Prompt

curl -X POST "https://console.mixroute.io/v1/messages" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "system": "You are a professional programming assistant skilled at explaining complex technical concepts.",
    "messages": [
      {"role": "user", "content": "What is recursion?"}
    ]
  }'

Extended Thinking

curl -X POST "https://console.mixroute.io/v1/messages" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 16000,
    "thinking": {
      "type": "enabled",
      "budget_tokens": 10000
    },
    "messages": [
      {"role": "user", "content": "Provide a medium difficulty geometry problem and solve it step by step"}
    ]
  }'

Tools

curl -X POST "https://console.mixroute.io/v1/messages" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get weather information for a city",
        "input_schema": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string",
              "description": "City name"
            }
          },
          "required": ["city"]
        }
      }
    ],
    "messages": [
      {"role": "user", "content": "What is the weather like in Tokyo?"}
    ]
  }'

Multimodal Input (Images)

curl -X POST "https://console.mixroute.io/v1/messages" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/jpeg",
              "data": "base64_encoded_image_data"
            }
          },
          {
            "type": "text",
            "text": "Please describe this image"
          }
        ]
      }
    ]
  }'

Prompt Caching

By caching frequently used context content, you can significantly reduce costs and improve response speed. Cached content requires a minimum of 1024 tokens.
curl -X POST "https://console.mixroute.io/v1/messages" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "system": [
      {
        "type": "text",
        "text": "You are a professional document analysis assistant. Here is the document content to analyze: [long text content, at least 1024 tokens]",
        "cache_control": {"type": "ephemeral"}
      }
    ],
    "messages": [
      {"role": "user", "content": "Please summarize the main points of the document"}
    ]
  }'

Response Format

{
  "id": "msg_xxx",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Response content..."
    }
  ],
  "model": "claude-sonnet-4-5-20250929",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 25,
    "output_tokens": 100,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  }
}
curl --request POST \
  --url https://console.mixroute.io/v1/messages \
  --header 'Authorization: Bearer sk-xxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --header 'anthropic-version: 2023-06-01' \
  --data '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Briefly explain artificial intelligence"}
    ]
  }'
{
  "id": "msg_xxx",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Artificial intelligence is a new technical science that researches and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence..."
    }
  ],
  "model": "claude-sonnet-4-5-20250929",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 25,
    "output_tokens": 100
  }
}