https://api.lazu.ai/v1/chat/completionsChat 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消息角色。
systemuserassistanttoolcontentstring | content_part[]required文本消息可直接传字符串;多模态请求可传 content parts。
tool_callsobject[]nullableassistant 消息里的工具调用。
tool_call_idstringnullabletool 消息需要带这个字段,用来对应上一轮 tool call。
图片输入
{
"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_tokensintegernullablecache read tokens。
usage.prompt_tokens_details.cache_write_tokensintegernullableprovider 上报时返回的 cache write tokens。
usage.prompt_tokens_details.cache_miss_tokensintegernullableprovider 明确上报 cache miss 时返回,例如 DeepSeek 兼容字段。
完整对账信息使用请求详情 API:
curl https://api.lazu.ai/api/usage/requests/req_lazu_01ABCDEF \
-H "Authorization: Bearer $LAZU_API_KEY"相关页面
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"}
]
}'
{
"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 }
}
- Request ID
- req_demo_01
- 模型 · 线路
- gpt-6-luna · stable
- Token · 输入 / 输出
- 1,200 / 320
- Key
- demo-key
仅为示例,不是报价,也不是你这次请求的结果。发送上方请求即可看到你自己的回执。
查看真实请求回执 →