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-compatible
POSThttps://api.lazu.ai/v1/chat/completions

Chat 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。

rolestring
system、user、assistant 或 tool。
contentstring | content_part[]
純文字,或多模態 content parts。
tool_call_idstring
tool message 用於關聯先前的 tool call。
streambooleannullable

為 true 時返回 Server-Sent Events stream,最後以 data: [DONE] 結束。

toolsobject[]nullable

Function/tool 定義。送出前先檢查模型 catalog 中的 parameters.tools。

type"function"
目前支援 function tools。
function.namestring
模型可呼叫的工具名稱。
function.parametersobject
描述參數的 JSON Schema。
tool_choicestring | objectnullable

OpenAI-compatible tool choice 控制,例如 auto、 none 或指定工具物件。

response_formatobjectnullable

Structured output 控制,例如 {"type":"json_object"}。

temperaturenumbernullable

取樣溫度,多數模型接受 0 到 2。

max_tokensintegernullable

產生 token 上限,仍受模型 context 和 output limit 限制。

Vision input

圖片輸入使用 OpenAI-compatible content parts。可以傳 HTTPS 圖片 URL 或 data URL:

Image 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。

Response

idstring

Lazu 或 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。

完整對帳請使用 請求詳情。

相關頁面

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

僅為範例,不是報價,也不是你這次請求的結果。送出上方請求即可看到你自己的回執。

查看真實請求回執 →