Skip to main content
POST
https://console.mixroute.io
/
v1
/
chat
/
completions
curl --request POST \
  --url https://console.mixroute.io/v1/chat/completions \
  --header 'Authorization: Bearer sk-xxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "glm-5",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Briefly introduce artificial intelligence"}
    ],
    "temperature": 0.7
  }'
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "glm-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Artificial intelligence is a new technical science that researches and develops theories, methods, techniques, and application systems for simulating, extending, and expanding human intelligence..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 100,
    "total_tokens": 125
  }
}

Introduction

Universal text chat interface supporting OpenAI-compatible large language models. Through a unified API, you can access OpenAI, Claude, DeepSeek, Grok, Qwen, and many other mainstream models via Mixroute Api.

Authentication

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

Request Parameters

model
string
required
Model identifier. Supported models include:
  • OpenAI series: gpt-4o, gpt-4o-mini, o3-mini, o4-mini, etc.
  • Claude series: claude-opus-4-6, claude-sonnet-4-5-20250929, etc.
  • DeepSeek series: deepseek-v3, deepseek-r1, etc.
  • Gemini series: gemini-3-pro-preview, gemini-3-flash-preview, etc.
  • Chinese models: glm-5, kimi-k2.5, doubao-seed-1-8-251228, etc.
messages
array
required
Array of conversation messages, each containing role (user/system/assistant) and content
temperature
number
Randomness control, 0-2. Higher values produce more random responses
stream
boolean
Enable streaming output, returns SSE format chunked data
max_tokens
integer
Maximum tokens to generate, controls response length

Basic Examples

curl -X POST "https://console.mixroute.io/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -d '{
    "model": "glm-5",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Please briefly introduce artificial intelligence"}
    ],
    "temperature": 0.7
  }'

Advanced Features

Supports OpenAI-compatible tool calling format:
curl -X POST "https://console.mixroute.io/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "What is the weather in Shanghai?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get weather information by city",
          "parameters": {
            "type": "object",
            "properties": {
              "city": {"type": "string"}
            },
            "required": ["city"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'

Response Format

{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Response content..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 100,
    "total_tokens": 125
  }
}

Error Handling

Error TypeTrigger Scenario
AuthenticationErrorInvalid API key or unauthorized
NotFoundErrorModel does not exist or is not supported
APIConnectionErrorNetwork interruption or server not responding
RateLimitErrorRequest rate limit exceeded
curl --request POST \
  --url https://console.mixroute.io/v1/chat/completions \
  --header 'Authorization: Bearer sk-xxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "glm-5",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Briefly introduce artificial intelligence"}
    ],
    "temperature": 0.7
  }'
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "glm-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Artificial intelligence is a new technical science that researches and develops theories, methods, techniques, and application systems for simulating, extending, and expanding human intelligence..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 100,
    "total_tokens": 125
  }
}