Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

快速開始

1. 建立 API Key

登入 Lazu 控制台,進入 API Keys,點擊 Create key。複製產生的 key,它通常以 sk-lazu- 開頭。

2. 選擇 Base URL

https://api.lazu.ai

自部署 Lazu 時,請把這個地址替換成你自己的 API 網域。

3. 發起請求

cURL

curl https://api.lazu.ai/v1/chat/completions \
  -H "Authorization: Bearer $LAZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "user", "content": "Say hello from Lazu"}
    ]
  }'

Python

from openai import OpenAI
 
client = OpenAI(
    base_url="https://api.lazu.ai/v1",
    api_key="YOUR_LAZU_KEY",
)
 
resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Say hello from Lazu"}],
)
print(resp.choices[0].message.content)

TypeScript

import OpenAI from "openai";
 
const client = new OpenAI({
  baseURL: "https://api.lazu.ai/v1",
  apiKey: process.env.LAZU_API_KEY,
});
 
const resp = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Say hello from Lazu" }],
});
console.log(resp.choices[0].message.content);

4. 下一步