Skip to content

LLM 调用

One AI Gateway 的大部分配置都在 https://modelplane.dev 的 UI 中完成。开发者只需要 LLM base URL、应用 API key,以及产品或平台团队选定的 model group 名称。

基础 Chat 调用

bash
curl https://api.modelplane.dev/v1/chat/completions \
  -H "Authorization: Bearer YOUR_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "coding-agent",
    "messages": [
      { "role": "user", "content": "Review this function and suggest tests." }
    ]
  }'

使用 Model Group

model 值来自控制台里的 model group 名称。路由、Provider 选择、fallback、quota 处理和计费归因都由 One AI Gateway 处理。

json
{
  "model": "smart-llm",
  "messages": [
    { "role": "user", "content": "Summarize this incident report." }
  ]
}

请求 Reasoning

对支持 reasoning 的模型和路由,调用方可以请求 thinking budget:

json
{
  "model": "reasoning",
  "messages": [
    { "role": "user", "content": "Find the likely root cause." }
  ],
  "reasoning": {
    "enabled": true,
    "effort": "medium",
    "max_tokens": 2048
  }
}

返回格式

最终答案在 message.content。如果所选 Provider 和模型返回 reasoning,则会单独出现在 reasoning 字段中。

json
{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "最可能原因是数据库连接池耗尽。",
        "reasoning": "延迟峰值与连接等待一致,而不是 CPU 饱和。"
      }
    }
  ]
}

开发者不需要处理什么

  • Provider API keys。
  • Backend IDs。
  • Routing trees。
  • Plan quota thresholds。
  • Fallback policies。
  • Billing aggregation。

这些都在 One AI Gateway 控制台中管理。

面向多模型、多 Provider 和 Coding Plan 场景的统一 AI Gateway 文档。