接口地址
https://www.qiweiban.com/api认证方式
Authorization: Bearer <token>返回格式
{ success, data, error }获取 Token
方式一:登录 Token。用企微瓣账号(手机号 + 密码,或手机号 + 验证码)调用登录接口换取 JWT Token,expiresIn 可选 1d、7d(默认)、30d,最长 30 天。
方式二:API Key。长期服务端集成可使用 qwb_sk_ 开头的 API Key,支持 IP 白名单。 API Key 目前由我们为您开通,请联系我们申请。
两种凭证的用法相同,都放在请求头 Authorization: Bearer ... 中。
cURL
curl -X POST https://www.qiweiban.com/api/auth/token-password \
-H "Content-Type: application/json" \
-d '{"phoneNumber": "13800138000", "password": "your_password", "expiresIn": "7d"}'
# 返回
{
"success": true,
"data": {
"token": "eyJhbGciOi...",
"tokenType": "Bearer",
"expiresAt": "2026-12-05T08:00:00.000Z",
"user": { "id": "...", "name": "...", "phoneNumber": "..." }
}
}常用接口
认证
POST
手机号 + 密码换取 Token/auth/token-passwordPOST
发送短信验证码/auth/send-verification-codePOST
手机号 + 验证码换取 Token/auth/tokenGET
查看当前 Token 信息/auth/token-info语音
GET
音色列表(系统音色 + 我的克隆声音)/voice/modelsPOST
语音合成/voice/synthesizeGET
语音作品列表/voice/worksGET
我的克隆声音列表/voice-clone/list数字人
GET
可用数字人列表/digital-human/listPOST
创建数字人视频任务/digital-human/video/createGET
查询视频任务状态/digital-human/video/{videoJobId}/statusAI 能力
GET
可用大模型列表/ai-modelsPOST
AI 对话/ai-models/chatPOST
AI 生成图片/image/generate账户
GET
瓣值余额与会员概览/petals/overviewGET
瓣值消费记录/petals/history请求参数
语音合成
POST /voice/synthesize| 参数 | 类型 | 说明 |
|---|---|---|
| text | string,必填 | 要合成的文本,最长 9999 字 |
| voiceId | string | 系统音色 id(/voice/models 中 type 为 system 的 id) |
| voiceCloneSampleId | string | 克隆声音 id(type 为 cloned 的 id),与 voiceId 二选一 |
| speed | number | 语速 0.5–2.0,默认 1.0 |
| volume | number | 音量 0.1–2.0,默认 1.0 |
| pitch | number | 音调 -1.0–1.0,默认 0 |
| emotion | string | auto / happy / sad / angry / fearful / disgusted / surprised / calm / fluent,默认 auto |
| format | string | mp3 / wav / pcm,默认 mp3 |
| subtitleEnable | boolean | 是否返回字幕时间轴,默认 false |
| title | string | 作品标题 |
数字人视频
POST /digital-human/video/create| 参数 | 类型 | 说明 |
|---|---|---|
| digitalHumanId | string,必填 | 数字人 id(/digital-human/list) |
| script | string | 口播文本,文本模式必填 |
| audioUrl | string | 已有音频地址,传入后按音频驱动,不再合成语音 |
| voiceId / voiceCloneSampleId | string | 指定配音音色,不传则使用数字人绑定的默认声音 |
| aspectRatio | string | '9:16' 或 '16:9' |
| speed | number | 语速 |
| isRemoveBg | boolean | 是否去除数字人背景(需数字人支持) |
AI 对话
POST /ai-models/chat| 参数 | 类型 | 说明 |
|---|---|---|
| userInput | string,必填 | 用户输入 |
| modelId | string | 模型 id(/ai-models),不传使用默认模型 |
| systemPrompt | string | 系统提示词 |
| temperature | number | 0–2,默认 0.7 |
| maxTokens | number | 1–8192,默认 2048 |
图片生成
POST /image/generate| 参数 | 类型 | 说明 |
|---|---|---|
| prompt | string,必填 | 图片描述 |
| image | string | string[] | 参考图 URL(http/https),用于图生图 |
| size | string | '2k'、'3k' 或 '1024x1024' 这样的宽x高,默认 2k |
| watermark | boolean | 是否添加水印,默认 true |
代码示例
语音合成
cURL
curl -X POST https://www.qiweiban.com/api/voice/synthesize \
-H "Authorization: Bearer $QWB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "大家好,欢迎使用企微瓣。",
"voiceId": "<系统音色 id,来自 /voice/models>",
"speed": 1.0,
"format": "mp3"
}'
# 使用自己的克隆声音:把 voiceId 换成 "voiceCloneSampleId": "<克隆声音 id>"
# 返回 data.audioUrl(音频地址)、data.costInPetals(消耗瓣值)、data.remainingBalance生成数字人视频并等待完成
JavaScript (fetch)
const BASE_URL = 'https://www.qiweiban.com/api';
const headers = {
'Authorization': `Bearer ${process.env.QWB_TOKEN}`,
'Content-Type': 'application/json',
};
// 1. 创建数字人视频任务(digitalHumanId 来自 GET /digital-human/list)
const createRes = await fetch(`${BASE_URL}/digital-human/video/create`, {
method: 'POST',
headers,
body: JSON.stringify({
digitalHumanId: '<数字人 id>',
script: '大家好,欢迎使用企微瓣。',
aspectRatio: '9:16', // 或 '16:9'
}),
});
const { data } = await createRes.json();
const videoJobId = data.videoJobId;
// 2. 轮询任务状态:PENDING / PROCESSING / COMPLETED / FAILED
while (true) {
const res = await fetch(`${BASE_URL}/digital-human/video/${videoJobId}/status`, { headers });
const { data: job } = await res.json();
if (job.status === 'COMPLETED') { console.log(job.videoUrl); break; }
if (job.status === 'FAILED') throw new Error(job.errorMessage);
await new Promise((r) => setTimeout(r, 10_000));
}Python (requests)
import os, time, requests
BASE_URL = "https://www.qiweiban.com/api"
headers = {"Authorization": f"Bearer {os.environ['QWB_TOKEN']}"}
res = requests.post(f"{BASE_URL}/digital-human/video/create", headers=headers, json={
"digitalHumanId": "<数字人 id>",
"script": "大家好,欢迎使用企微瓣。",
"aspectRatio": "9:16",
})
video_job_id = res.json()["data"]["videoJobId"]
while True:
job = requests.get(f"{BASE_URL}/digital-human/video/{video_job_id}/status", headers=headers).json()["data"]
if job["status"] == "COMPLETED":
print(job["videoUrl"]); break
if job["status"] == "FAILED":
raise RuntimeError(job["errorMessage"])
time.sleep(10)计费与错误
- 接口调用按账户瓣值扣费,与网页端价格一致;余额可通过
GET /petals/overview查询。 - 401:Token 缺失、无效或已过期;400:参数错误;429:登录请求过于频繁;瓣值不足时请求会失败并在 error 中说明。
- 出错时响应体为
{ "success": false, "error": "错误说明" }。