https://api.lazu.ai/v1/chat/completionsChat completions
透過 Lazu 發送 OpenAI-compatible chat 請求。Base URL、認證、必要 body 欄位、stream、tools、response usage 和排障入口都在這一頁。
計費依所選模型與線路的價格計算 token 用量;可能包含其他計費維度。 價格與線路 ↗
基本設定
Base URL
使用 https://api.lazu.ai/v1 搭配 OpenAI SDK,或直接呼叫完整
path https://api.lazu.ai/v1/chat/completions。
模型發現
執行時讀取 GET /api/models/catalog,並篩選
supported_endpoint_types 包含 chat 的模型。
請求 Body
modelstringrequired模型 ID、route alias 或未來的 route policy 名稱。建議從
GET /api/models/catalog 讀取。
messagesobject[]required有序對話訊息。角色遵循 OpenAI shape。
rolestringcontentstring | content_part[]tool_call_idstringstreambooleannullable為 true 時返回 Server-Sent Events stream,最後以
data: [DONE] 結束。
toolsobject[]nullableFunction/tool 定義。送出前先檢查模型 catalog 中的
parameters.tools。
type"function"function.namestringfunction.parametersobjecttool_choicestring | objectnullableOpenAI-compatible tool choice 控制,例如 auto、
none
或指定工具物件。
response_formatobjectnullableStructured output 控制,例如 {"type":"json_object"}。
temperaturenumbernullable取樣溫度,多數模型接受 0 到 2。
max_tokensintegernullable產生 token 上限,仍受模型 context 和 output limit 限制。
Vision input
圖片輸入使用 OpenAI-compatible content parts。可以傳 HTTPS 圖片 URL 或 data URL:
{
"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。
Response
idstringLazu 或 provider response ID。
choicesobject[]Assistant output choices。Streaming response 會送出增量 delta。
usage.prompt_tokensinteger輸入 token 數。
usage.completion_tokensinteger輸出 token 數。
usage.prompt_tokens_details.cached_tokensintegernullable上游回報時的 cache read token。
完整對帳請使用 請求詳情。
相關頁面
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
僅為範例,不是報價,也不是你這次請求的結果。送出上方請求即可看到你自己的回執。
查看真實請求回執 →