認證
所有請求帶 header x-lala-key: <你的 API key>(或標準 Authorization: Bearer <key>)。
申請 key:電郵 [email protected]或經 WhatsApp 聯絡我們。
模型列表
curl https://lala.buddylala.ai/v1/models -H "x-lala-key: $LALA_KEY"
| 模型 | 類型 | Endpoint | 說明 |
|---|---|---|---|
lala-6 | chat | /chat/completions | 高效全模態對話(1M context) |
lala-6-pro | chat | /chat/completions | 旗艦全模態對話(1M context) |
lala-ultrafast | chat | /chat/completions | 極速推理對話(1M context) |
lala-super | chat | /chat/completions | 頂級旗艦推理 |
lala-rag | embedding | /embeddings | 文本向量化(RAG 檢索) |
lala-image | image | /images/generations | 圖像生成(質量優先) |
lala-video | video | /responses | 視頻生成(任務式,4–30 秒) |
lala-video-get | video | /responses | 查詢視頻任務結果 |
lala-speech | tts | /responses | 高清語音合成 |
lala-music | music | /responses | 音樂生成 |
lala-lyric | lyric | /responses | 歌詞生成 |
lala-decision | decision | /typesafe/systemone | 結構化判研(不生成文本) |
對話 Chat Completions
OpenAI-compatible。支援 stream: true 串流輸出。
curl
curl https://lala.buddylala.ai/v1/chat/completions \
-H "x-lala-key: $LALA_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "lala-6",
"messages": [{"role": "user", "content": "你好,介紹下自己"}],
"max_tokens": 500
}'
Python(openai SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://lala.buddylala.ai/v1",
api_key="***", # 你的 lala key
)
resp = client.chat.completions.create(
model="lala-super",
messages=[{"role": "user", "content": "寫一首關於秋天的詩"}],
)
print(resp.choices[0].message.content)
Node.js
const res = await fetch("https://lala.buddylala.ai/v1/chat/completions", {
method: "POST",
headers: {
"x-lala-key": process.env.LALA_KEY,
"content-type": "application/json",
},
body: JSON.stringify({
model: "lala-ultrafast",
messages: [{ role: "user", content: "1+1=?" }],
stream: false,
}),
});
const data = await res.json();
console.log(data.choices[0].message.content);
向量 Embeddings
curl https://lala.buddylala.ai/v1/embeddings \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{"model": "lala-rag", "input": "寵物食品零售自動化"}'
回傳標準 OpenAI embeddings 格式(data[].embedding 向量陣列),可直接入向量資料庫做 RAG。
圖像生成 Image
curl https://lala.buddylala.ai/v1/images/generations \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{"model": "lala-image", "prompt": "a cute corgi puppy, studio photo", "n": 1}'
回傳 data[].url(圖片 CDN 連結)。計費:每張固定價,見價格頁。
視頻生成 Video(任務式)
視頻生成是兩段式:先提交任務取得 task id,再輪詢取得結果。
步驟 1:提交任務
curl https://lala.buddylala.ai/v1/responses \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{
"model": "lala-video",
"input": [{"type": "text", "text": "a cat yawning in sunlight"}],
"duration": 5,
"resolution": "720p",
"ratio": "16:9",
"generate_audio": true
}'
# → {"id": "cgt-xxxx", ...} ← 保存此任務識別碼!
參數:duration 4–30 秒(或 -1 智能選擇)、resolution 480p/720p/1080p、ratio 16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9 / adaptive、generate_audio 默認 true(自動配人聲/音效/背景樂)。
步驟 2:輪詢結果
curl https://lala.buddylala.ai/v1/responses \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{"model": "lala-video-get", "input": "cgt-xxxx"}'
# status: succeeded 時 output[].content[].text = 視頻下載 URL
語音合成 Speech (TTS)
curl https://lala.buddylala.ai/v1/responses \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{
"model": "lala-speech",
"input": "你好,歡迎致電 Buddylala",
"output_format": "hex",
"voice_setting": {"voice_id": "male-qn-qingse", "speed": 1, "vol": 1, "pitch": 0}
}'
# → {"data": {"audio": "<hex 編碼音頻>"}}
hex 轉 mp3:python3 -c "import binascii,sys; open('out.mp3','wb').write(binascii.unhexlify(sys.argv[1]))" "<hex>"。80+ 預置音色、9 種情緒。
音樂生成 Music
curl https://lala.buddylala.ai/v1/responses \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{
"model": "lala-music",
"input": "upbeat jingle for a pet shop",
"lyrics": "la la la happy day with you"
}'
# → {"data": {"audio": "<hex>"}}
lyrics 必填(可先用 lala-lyric 生成)。
歌詞生成 Lyric
curl https://lala.buddylala.ai/v1/responses \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{
"model": "lala-lyric",
"mode": "write_full_song",
"input": "一首關於貓的輕快廣東歌"
}'
# → {"song_title": "...", "style_tags": "...", "lyrics": "[Verse]..."}
mode:write_full_song(完整歌曲)或 edit(續寫/修改,需帶 lyrics 現有內容)。
結構化判研 Decision(非文本生成)
lala-decision不生成文本,只做結構化判斷:提供一段狀態(工單/對話/日誌)+一組問題,並行回傳 Choice / Score / Noul 三類答案附校準概率。支援圖像判斷:可附最多 4 張圖(PNG/JPEG/WebP,每張 ≤4MiB,base64 內嵌,不收 remote URL)一併分析。典型回應 1–5 秒,適合工單分派、意圖識別、內容風控。
curl https://lala.buddylala.ai/typesafe/systemone \
-H "x-lala-key: $LALA_KEY" -H "Content-Type: application/json" \
-d '{
"model": "lala-decision",
"state": "Customer: my order is 5 days late and I want a refund!",
"questions": {
"urgency": {
"type": "choice",
"instructions": "判斷工單緊急程度",
"criteria": {"低": "語氣平和", "中": "有不满但无期限", "高": "情绪激动或提退款"}
},
"refund_requested": {
"type": "noul",
"instructions": "客戶是否明確要求退款?"
}
}
}'
# → {"answers": {"refund_requested": {"noul": 0.99, "type": "noul"}}, "model": "lala-decision", ...}
問題類型:choice(criteria 係 object:選項名→判定標準)、score(criteria 係 array:由低到高檔位)、noul(true/false 判斷,不需 criteria)。
圖像判斷(可選):在 body 加"images": ["<base64 圖片>"](最多 4 張;每張 ≤4MiB、16 megapixels;整個 request body ≤13MiB;只收 base64 內嵌,不收 URL)。示例:
{
"model": "lala-decision",
"images": ["iVBORw0KGgo...(base64 PNG)"],
"state": "客人傳送了一張收據相片,要求我們查看",
"questions": {
"is_valid_receipt": {"type": "noul", "instructions": "圖片是否為一張有效收據?"}
}
}
錯誤處理
| HTTP | 含義 | 處理 |
|---|---|---|
| 401 | API key 無效或缺失 | 檢查 x-lala-key header |
| 400 | model 名不存在 / body 格式錯誤 | 對照模型列表同各 endpoint 示例 |
| 5xx | 上游偶發錯誤 | 指數退避重試(建議最多 3 次) |
Response 文字經 brand normalization(供應商相關字樣會統一為 lala/buddylala 品牌稱呼),JSON 結構及欄位完全標準,不影響解析。