Skip to content

API 参考

文档完善中

此页面内容正在编写中,敬请期待。

基础信息

项目
Base URLhttps://api.mindrouter.ai/v1
认证方式Bearer Token
兼容协议OpenAI API

Chat Completions

请求

bash
POST /v1/chat/completions

请求体

json
{
  "model": "auto",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 1000,
  "stream": false
}

参数说明

参数类型必填说明
modelstring模型标识,支持 autoauto:costauto:quality 或具体模型名
messagesarray对话消息数组
temperaturenumber采样温度,0-2,默认 1
max_tokensinteger最大生成 token 数
streamboolean是否流式输出,默认 false

响应

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699000000,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 10,
    "total_tokens": 30
  },
  "mindrouter": {
    "requested_model": "auto",
    "routed_model": "gpt-4o-mini",
    "route_reason": "simple_query",
    "estimated_cost": "$0.000018",
    "latency_ms": 320
  }
}

错误码

状态码说明
400请求参数错误
401认证失败,检查 API Key
429请求过于频繁或超出预算
500服务器内部错误
503上游模型服务不可用