Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content
接口 / OpenAI 兼容
POSThttps://api.lazu.ai/v1/chat/completions

Chat completions

通过 Lazu 发送 OpenAI 兼容的对话请求。本页直接包含 base URL、鉴权、请求字段、响应 usage、流式输出、工具调用和请求详情查询,不需要跳到单独的 OpenAPI Explorer 页面。

计费按所选模型与线路的价格计算 token 用量;可能包含其他计费维度。 价格与线路 ↗

基础配置

SDK base_url

OpenAI SDK 使用 https://api.lazu.ai/v1。

模型发现

生产代码应先读取 GET /api/models/catalog,筛选 supported_endpoint_types 包含 chat 的模型。

请求 Body

modelstringrequired

模型 ID,来自 GET /api/models/catalog。后续也可以承载 auto 或 route policy 名称。

messagesobject[]required

对话消息数组。role 使用 OpenAI 兼容格式: system、user、assistant、 tool。

streambooleannullable

设置为 true 时返回 SSE 流式响应,结尾为 data: [DONE]。

toolsobject[]nullable

工具/函数定义。发送前建议检查模型目录里的 parameters.tools。

response_formatobjectnullable

结构化输出控制,例如 {"type":"json_object"}。

temperaturenumbernullable

采样温度。不同 provider 的有效范围可能不同。

max_tokensintegernullable

最大输出 token,仍受模型上下文和输出限制约束。

消息格式

rolestringrequired

消息角色。

systemuserassistanttool
contentstring | content_part[]required

文本消息可直接传字符串;多模态请求可传 content parts。

tool_callsobject[]nullable

assistant 消息里的工具调用。

tool_call_idstringnullable

tool 消息需要带这个字段,用来对应上一轮 tool call。

图片输入

Vision inputjson
{
"model": "gpt-6-luna",
"messages": [
  {
    "role": "user",
    "content": [
      {"type": "text", "text": "What's in this image?"},
      {
        "type": "image_url",
        "image_url": {"url": "data:image/png;base64,..."}
      }
    ]
  }
]
}

PDF 和大文件应该使用 Files + Responses。Chat completions 不会自动读取

file_id。

响应 usage 和 cache 字段

usage.prompt_tokensinteger

输入 token。

usage.completion_tokensinteger

输出 token。

usage.prompt_tokens_details.cached_tokensintegernullable

cache read tokens。

usage.prompt_tokens_details.cache_write_tokensintegernullable

provider 上报时返回的 cache write tokens。

usage.prompt_tokens_details.cache_miss_tokensintegernullable

provider 明确上报 cache miss 时返回,例如 DeepSeek 兼容字段。

完整对账信息使用请求详情 API:

Request detailbash
curl https://api.lazu.ai/api/usage/requests/req_lazu_01ABCDEF \
-H "Authorization: Bearer $LAZU_API_KEY"

相关页面

Sent from your browser to api.lazu.ai · key stays in this tab
RequestPOST /v1/chat/completions
curl https://api.lazu.ai/v1/chat/completions \
  -H "Authorization: Bearer $LAZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-luna",
    "messages": [
      {"role": "user", "content": "Say hello from Lazu"}
    ]
  }'
ResponseExample
{
  "id": "chatcmpl-9aZx",
  "model": "gpt-6-luna",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hello!" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 11, "completion_tokens": 3 }
}
请求回执示例回执
$0.00028200 · 842 ms
Request ID
req_demo_01
模型 · 线路
gpt-6-luna · stable
Token · 输入 / 输出
1,200 / 320
Key
demo-key

仅为示例,不是报价,也不是你这次请求的结果。发送上方请求即可看到你自己的回执。

查看真实请求回执 →