认证
所有请求带 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 结构及字段完全标准,不影响解析。