UdioAPI · Python SDK
Generate AI music through the
udioapi.pro
REST API: start a task with /api/v2/generate, then poll
/api/v2/feed until both clips finish.
Python 3.9+. Zero third-party dependencies (stdlib only).
git clone https://github.com/UdioAPI/udioapi.git
cd udioapi
# no pip install required for the first version
Prefer a one-liner later? A PyPI package named udioapi is planned;
until then clone the repo and import udioapi from the project root.
Every authenticated request needs a Bearer token from your udioapi.pro dashboard.
Authorization: Bearer YOUR_API_KEY
Accept: application/json
Content-Type: application/json # for POST bodies
Base URL:
https://udioapi.pro/api
import os
from udioapi import UdioClient
client = UdioClient(os.environ["UDIOAPI_API_KEY"])
# or paste into generate.py → API_KEY = "..."
Never commit a real key. Keep keys on the server — not in browser code or public repos.
from udioapi import UdioClient
from udioapi.client import tracks
client = UdioClient("YOUR_API_KEY")
work_id = client.generate(
gpt_description_prompt="an upbeat pop song about summer, catchy chorus",
model="chirp-v5-5",
)
print("workId:", work_id)
result = client.wait(work_id, interval=8, timeout=300)
for i, clip in enumerate(tracks(result), 1):
print(i, clip.get("title"), clip.get("audio_url"))
work_id = client.generate(
prompt="Verse 1: Walking down the street\\nChorus: Summer dreams",
style="pop, upbeat, electronic",
title="Summer Dreams",
model="chirp-v5-5",
)
result = client.wait(work_id)
export UDIOAPI_API_KEY="YOUR_API_KEY"
python3 generate.py --prompt "lofi chill beat for late night coding"
python3 generate.py --work-id gen2xxxxxxxx
# start
curl -s -X POST https://udioapi.pro/api/v2/generate \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"gpt_description_prompt":"dreamy ambient pad","model":"chirp-v5-5"}'
# poll every 5–10s with the returned workId
curl -s "https://udioapi.pro/api/v2/feed?workId=WORK_ID" \\
-H "Authorization: Bearer YOUR_API_KEY"
Done when a clip’s extra_message is
All generated successfully.
Failed when fail_message is set.
The SDK raises UdioAPIError with .code and
.payload. HTTP status and JSON code / message
from the API are preserved when present.
| Code / signal | Meaning | What to do |
|---|---|---|
400 |
Invalid body (missing prompt / bad fields) | Pass gpt_description_prompt or prompt; check field names against the generate docs. |
401 |
Missing or invalid API key | Create or rotate a key at udioapi.pro. |
402 / insufficient credits |
Not enough account credits | Top up on pricing. |
429 |
Rate limited | Back off and retry; keep poll interval at 5–10s. |
5xx |
Upstream / server error | Retry with jitter; if persistent, contact support@udioapi.pro. |
fail_message on feed |
Task failed after accept | Read the message on the clip; start a new generate with adjusted inputs. |
| SDK timeout | wait() exceeded timeout |
Increase timeout or keep polling the same workId. |
Always use the public workId returned by create endpoints for polling,
logs, and webhooks — do not invent undocumented IDs.
Default in this SDK: chirp-v5-5. Model list, credit costs, extend / cover /
WAV / MiniMax endpoints live in the product docs:
Need a key to try the examples? Get a free API key →