Music generation API (audio/music)

Make music and short songs with POST /v1/audio/music: style and mood, an inspiration image, automatic model picking, the file link and per-track price.

Updated: 4 Oct 2026

POST /v1/audio/music makes one track and, like images, answers synchronously: the request stays open until the track is ready (usually under a minute). This route is not in the official OpenAI SDK, so call it with a plain HTTP request.

curl

curl https://api.uttapen.ir/v1/audio/music \
  -H "Authorization: Bearer sk-up-..." -H "Content-Type: application/json" \
  -d '{"model": "uttapen/auto-music", "prompt": "calm piano, rainy evening, instrumental, about a minute"}'

Python (httpx)

import httpx

r = httpx.post(
    "https://api.uttapen.ir/v1/audio/music",
    headers={"Authorization": "Bearer sk-up-..."},
    json={"model": "uttapen/auto-music", "prompt": "upbeat jingle for a coffee shop ad, 20 seconds"},
    timeout=360,
)
r.raise_for_status()
track = r.json()
print(track["data"][0]["url"], track["uttapen"]["cost_toman"])

Fields

FieldMeaning
modela model id or uttapen/auto-music; automatic picking chooses the short variant for a "short" or "jingle" request
promptstyle, instruments, mood, tempo and rough length; up to 4,000 characters
imageoptional inspiration image (an https URL or data:image/…;base64) for models with image input
seeda fixed number for repeatable output
response_formaturl (default) or b64_json

Answer

{
  "created": 1791071431,
  "model": "google/lyria-3-pro-preview",
  "data": [{ "url": "https://api.uttapen.ir/v1/files/…/content?exp=…&sig=…", "mime_type": "audio/mpeg", "expires_at": "…" }],
  "uttapen": { "id": "01a1044a-…", "status": "completed", "cost_toman": "…", "hold_toman": "…" }
}

The link is valid for 24 hours and the file is kept for 30 days; get a fresh link from GET /v1/uttapen/media/{id}. If a run takes more than a few minutes, you get 202 with the job object and fetch the result later by its id.

Price

Music is priced per track; each model's approximate figure is under music models. An amount is held first and only the real reported cost is charged afterwards. A track that breaks off midway, or a file that never arrives, costs nothing. More in the media overview.

No API key yet?

Sign up with a phone number, top up your wallet from 100,000 toman and create a key. Free models work without a top-up — up to 50 requests a day. Create an API key →