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