跳到正文
SeedAudio

DEVELOPER DOCUMENTATION

音频 API 接入文档

创建任务、查询状态,再从本站鉴权下载。请在服务器使用密钥。

需要实付购买过积分包或持有当期付费订阅;赠送积分本身不解锁API。请求返回503时,表示服务尚未开放或暂时不可用。

1. 快速接入

以下命令在服务端终端执行。首次安装Python示例依赖:pip install requests;JavaScript示例使用Node.js 22或更新版本。

cURL

export SEEDAUDIO_ORIGIN='https://seedaudio.now'
export SEEDAUDIO_API_KEY='YOUR_API_KEY'

curl --fail-with-body "$SEEDAUDIO_ORIGIN/api/v1/audio/generations" \
  -H "Authorization: Bearer $SEEDAUDIO_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: rain-scene-001' \
  -d '{"model":"seed-audio-1.0","prompt":"Gentle rain against a window.","output_format":"mp3"}'

# Replace TASK_ID with the returned id. Poll every 5 seconds until terminal.
curl --fail-with-body "$SEEDAUDIO_ORIGIN/api/v1/audio/generations/TASK_ID" \
  -H "Authorization: Bearer $SEEDAUDIO_API_KEY"

# After status is succeeded, download using the same account's active key.
curl --fail-with-body "$SEEDAUDIO_ORIGIN/api/v1/audio/generations/TASK_ID/content" \
  -H "Authorization: Bearer $SEEDAUDIO_API_KEY" -o audio.mp3

JavaScript (Node.js)

const origin = "https://seedaudio.now";
const headers = { Authorization: 'Bearer ' + process.env.SEEDAUDIO_API_KEY };
async function json(response) {
  const data = await response.json();
  if (!response.ok) throw new Error(data.error?.message || 'Request failed');
  return data;
}
// Persist this key with your request; reuse it if the POST response is lost.
const idempotencyKey = 'rain-scene-001';
let task = await json(await fetch(origin + '/api/v1/audio/generations', {
  method: 'POST',
  headers: { ...headers, 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey },
  body: JSON.stringify({ prompt: 'Gentle rain against a window.' })
}));
const deadline = Date.now() + 65 * 60 * 1000;
while (['queued', 'processing'].includes(task.status) && Date.now() < deadline) {
  await new Promise(resolve => setTimeout(resolve, 5000));
  task = await json(await fetch(origin + '/api/v1/audio/generations/' + task.id, { headers }));
}
if (task.status !== 'succeeded') throw new Error(task.error?.message || 'Poll deadline reached; keep the task id.');
const response = await fetch(task.output.url, { headers });
if (!response.ok) throw new Error('Download failed');
const { writeFile } = await import('node:fs/promises');
await writeFile('audio.mp3', new Uint8Array(await response.arrayBuffer()));

Python

import os, time, requests

origin = "https://seedaudio.now"
headers = {"Authorization": "Bearer " + os.environ["SEEDAUDIO_API_KEY"]}
# Keep this key with your request; a new scene needs a new key.
response = requests.post(origin + "/api/v1/audio/generations", timeout=45,
    headers={**headers, "Idempotency-Key": "rain-scene-001"},
    json={"prompt": "Gentle rain against a window."})
response.raise_for_status()
task = response.json()
deadline = time.monotonic() + 65 * 60
while task["status"] in ("queued", "processing") and time.monotonic() < deadline:
    time.sleep(5)
    response = requests.get(origin + "/api/v1/audio/generations/" + task["id"], headers=headers, timeout=90)
    response.raise_for_status()
    task = response.json()
if task["status"] != "succeeded":
    raise RuntimeError(task.get("error") or "Poll deadline reached; keep the task id.")
with requests.get(task["output"]["url"], headers=headers, stream=True, timeout=60) as response:
    response.raise_for_status()
    with open("audio.mp3", "wb") as audio:
        for chunk in response.iter_content(65536):
            audio.write(chunk)

2. 地址与身份

https://seedaudio.now

  • POST /api/v1/audio/generations → 202
  • GET /api/v1/audio/generations/{id} → 200
  • GET / HEAD /api/v1/audio/generations/{id}/content → 200 / 206

三类请求均使用Authorization: Bearer。任务属于账户;可使用该账户的其他有效密钥。下载URL稳定但不公开,不能把密钥放入URL。登录后的历史记录使用会话身份播放。

3. 请求参数

Content-Type: application/json;最大32KiB;未知字段直接拒绝。只支持公开HTTPS参考地址,不接受内网地址。

参数取值说明
modelseed-audio-1.0默认且唯一模型。
promptstring必填,1–2048个Unicode字符,不能全为空白;保留换行。
audio_referencesstring[]最多3个公开HTTPS音频URL;依顺序使用@Audio1/2/3。每段最多10MB、30秒,由生成服务校验。
voicestring使用下方音色ID,占用1个音频参考名额。
image_urlstring一个公开HTTPS图片URL,不能与voice或音频参考组合。
output_formatmp3 / wav / pcm / ogg_opus默认mp3;PCM为原始文件,不保证浏览器可播放。
sample_rate8000 / 16000 / 24000 / 32000 / 44100 / 48000默认24000 Hz。
speed / volume0.5–2默认均为1;必须是有限数。
pitch-12–12整数,默认0。
multilingualboolean默认false;本站扩展参数,不随页面语言自动改变。
支持的音色ID

stokie_en · vivi_mixed_en_zh_ja_es_id · mindy_en_es_id_pt_zh · kian_en_zh · cedric_en_zh · sophie_en_zh · jean_en_zh · magnus_en_zh · mabel_en_zh · nadia_en_zh · opal_en_zh · pearl_en_zh · quentin_en_zh · corinne_mixed_en_zh · esther_mixed_en_zh · lyla_mixed_en_zh · tracy_es_zh · sandy_es_mixed_en_zh · felix_zh · celeste_zh · monkey_king_zh

4. 计费与任务状态

每分钟75积分,按秒向上取整,每任务最低10、最高150。创建时预留150,成功退差额,失败全额退回;退款仍保留原批次有效期。

8 / 30 / 60 / 120秒分别收费10 / 38 / 75 / 150积分。被退款或发生争议的购买不再解锁新API任务(订阅以当期付款为准,到下一期付款成功为止);其他有效的已付购买不受影响。

queued → processing → succeeded / failed

仅音频保存和结算都成功后才返回succeeded。最长恢复窗口60分钟;无法可靠交付或确认时长则失败退款。error仅提供本站错误信息。

成功响应示例

{
  "id": "TASK_ID",
  "object": "audio.generation",
  "model": "seed-audio-1.0",
  "status": "succeeded",
  "billing": {
    "reserved_credits": 150,
    "charged_credits": 38,
    "refunded_credits": 112
  },
  "output": {
    "url": "https://seedaudio.now/api/v1/audio/generations/TASK_ID/content",
    "format": "mp3",
    "sample_rate": 24000,
    "duration": 30
  },
  "usage": {
    "audio_seconds": 30
  },
  "error": null
}

5. 重试与限额

Idempotency-Key必填:1–128个英文字母、数字或._:-。每个新任务使用新键;同一请求重试保留原键和原内容。键在同一账户和接口版本内唯一,记录留存期间不得重复使用;同键同体返回原任务,同键异体409。网络超时不表示未创建,请勿换键盲目重发。

每账户每分钟创建6次,查询与下载合计60次;最多2个进行中任务。所有密钥共用限额;全站繁忙也会429。建议每5秒查询一次。

6. 错误与下载

HTTPcode处理
400invalid_request缺少幂等键、无效参数或未知字段。
401invalid_api_key密钥缺失、无效或已撤销。
402insufficient_credits不足150可用积分。
403purchase_required没有可解锁的实付积分包或当期付费订阅,例如相关付款已被退款或发生争议。
404not_found不存在或不属于当前账户。
409idempotency_conflict / not_ready同键异体,或文件尚未完成。
413request_too_largeJSON超过32KiB。
416Range下载范围无效;不支持多段Range。
429rate_limit / concurrency_limit等待Retry-After后重试。
503api_unavailable / temporarily_unavailable服务未启用、配置未就绪或暂时故障。保留原任务ID和幂等键。

下载支持单段Range、后缀Range及HEAD;响应不缓存,也不重定向到外部音源。示例默认MP3,其他格式应使用匹配的文件扩展名。未提供客户端取消或客户自定义回调,使用查询接口获取结果。