The library / Music APIAPI REFERENCE / V1
API V1 · 13 SECTIONS
API REFERENCE / V1

Taan Music API

Create music from text, video, scripts, or MIDI. Refine a saved result with a written instruction, and download your music as WAV or MP3.

Choose your API

Choose the task you want to perform:

Task Endpoint Start with
Text → music POST /api/v1/music/text A prompt and optional duration
Input → music POST /api/v1/music/input A video, script, or combination of inputs
Refinement POST /api/v1/music/refine A saved music version and a change to make
MIDI → music POST /api/v1/music/midi A MIDI file and a description of the desired sound

All four return a job ID. Check the job until it finishes, then download the result. Generation can take a few minutes; a successful submission does not mean the audio is ready yet.

Before you start

Base URL: https://api.taan.ai

Create an API key on your Taan API keys page. Include it in Taan API requests:

http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Keep the key in your application's server-side configuration. Do not expose it in browser code, mobile app bundles, shared examples, or logs. Upload and download URLs do not need this header.

Requests and responses use JSON. Durations are in seconds, file sizes are in bytes, and timestamps include a timezone. The IDs and file sizes shown below are examples: use the values returned for your own requests and the exact sizes of your files.

For the shell examples, use Bash, curl, and jq. Set TAAN_API_KEY privately in your environment, then run:

bash
export TAAN_API_BASE_URL='https://api.taan.ai'
: "${TAAN_API_KEY:?Set TAAN_API_KEY in your environment}"

Creating music uses credits. Check your available balance before starting. API projects are separate from Studio projects. Save the project, job, and music-version IDs your application receives; the public API does not provide a project-history listing.

Text → music

Describe the music you want. A text request starts generation directly; there is no separate upload or project-creation step.

POST /api/v1/music/text

Field Required Description
prompt Yes Musical direction, up to 8,000 characters.
duration_sec No 10–240 seconds. Defaults to 30.
audio_format No wav or mp3. Defaults to wav.

An Idempotency-Key header is required. This is your identifier for one request, not your API key. Choose a unique value, save it with the request, and reuse both if a response is lost. A UUID is a suitable value.

Save this body as text.json:

json
{
  "prompt": "Gentle solo piano with a hopeful ending. No vocals or percussion.",
  "duration_sec": 10,
  "audio_format": "wav"
}

Set TAAN_REQUEST_ID to your saved request identifier, then submit:

bash
: "${TAAN_REQUEST_ID:?Set a unique request identifier; retain it for retries}"
curl --fail-with-body --silent --show-error \
  "$TAAN_API_BASE_URL/api/v1/music/text" \
  -H "Authorization: Bearer $TAAN_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $TAAN_REQUEST_ID" \
  --data-binary @text.json \
  -o accepted.json

A successful submission returns 202 Accepted:

json
{
  "project_id": "11111111-1111-4111-8111-111111111111",
  "job_id": "22222222-2222-4222-8222-222222222222",
  "status": "queued",
  "status_url": "/api/v1/jobs/22222222-2222-4222-8222-222222222222"
}

Continue to progress and downloads. Repeating the same key and request returns the same job. Use a new key when you intentionally want a new composition.

Input → music

Use a video, script, or combination of inputs. Add musical direction to describe the mood, instruments, or moments you want to emphasize.

1. Register your inputs

POST /api/v1/music/intents

An intent describes the complete set of inputs for one composition. Registration returns a project_id and upload instructions; it does not start generation. Include an Idempotency-Key so you can recover the same registration if its response is lost.

This example combines a video with written direction:

json
{
  "name": "Travel film",
  "inputs": [
    {
      "kind": "video",
      "representation": "file",
      "file": {
        "filename": "clip.mp4",
        "content_type": "video/mp4",
        "size_bytes": 123456
      }
    },
    {
      "kind": "musical_direction",
      "representation": "text",
      "text_content": "Warm piano and strings, building toward the final reveal."
    }
  ]
}

Replace size_bytes with the file's actual byte count. name is optional. With video, omit duration_sec; the video determines the duration. Without video, you may set duration_sec to 10–240 seconds; it defaults to 30.

Supported inputs:

kind representation What to supply
video file One video at most.
script text or file One script at most; use text_content for inline text.
musical_direction text Written direction accompanying other inputs.
text_prompt text A standalone prompt; it must be the only input. For a simpler request, use /music/text.

File inputs need filename, content_type, and size_bytes. Text inputs need nonblank text_content. See formats and limits.

2. Upload each file

The 201 Created response contains project_id and an uploads array. Each upload includes input_id, method, url, headers, and expires_at. Entries follow the order of the file inputs; text inputs have no upload entry.

Send the file's raw bytes to its returned url, using the returned method and every returned header exactly as supplied. Do not use multipart encoding or include your Taan API key. URLs expire after 15 minutes.

If you have only inline text, the upload array is empty and you can continue immediately.

3. Start generation

After all files are uploaded, call POST /api/v1/music/input:

json
{
  "project_id": "11111111-1111-4111-8111-111111111111",
  "audio_format": "mp3"
}

The response is 202 Accepted with the same job-response shape as text generation. Keep its job ID and check progress.

There is one initial generation per project. Repeating the same project and format returns its existing job. Register a new intent for another composition.

Recover an interrupted upload

Request When to use it
POST /api/v1/music/intents/{project_id}/refresh-uploads Get fresh URLs for files still needing upload. Send no body. Skip files listed in arrived_input_ids.
POST /api/v1/music/intents/{project_id}/complete-upload Tell Taan to check the uploaded files. Send no body.
GET /api/v1/music/intents/{project_id}/readiness Read state: awaiting_upload, checking, ready, or failed.

Readiness checks are optional before generation. ready means your inputs are ready, not that music has been created. If you already have a generation job ID, retain it. Upload any missing files and complete the upload, or repeat the original input request; do not create a replacement project just to resume it.

Refinement

Request a musical change to a version created through text or input generation. For example, add a strings part while preserving the piano melody and duration.

POST /api/v1/music/refine

Use the project_id and exact music_version_id from a completed result:

json
{
  "project_id": "11111111-1111-4111-8111-111111111111",
  "music_version_id": "44444444-4444-4444-8444-444444444444",
  "instruction": "Add a sustained strings accompaniment. Preserve the piano melody and duration.",
  "audio_format": "wav"
}

instruction is required and may contain up to 8,000 characters. audio_format defaults to wav. An Idempotency-Key is optional but recommended; retain it with the request.

The response is 202 Accepted. Poll the returned job and read result.outcome:

Outcome What it means
changed A new version was created. Save its music_version_id for further changes.
unchanged The original version was returned because no change was needed.
unsupported The requested edit could not be made; the original version was returned.

For unchanged or unsupported, read result.explanation when present. No new music charge is made for those outcomes, and the original audio format is retained. Do not label the original audio as a new version or save an MP3 result with a .wav extension.

Music produced from uploaded MIDI cannot currently be refined through this endpoint. Some older music versions are also unsupported; these requests return 422 UNSUPPORTED_REFINEMENT_SOURCE without starting paid work.

MIDI → music

Turn your MIDI into audio. Upload the score, wait for it to be ready, then describe the sound you want.

1. Register the MIDI file

POST /api/v1/music/midi/intents

json
{
  "request_id": "77777777-7777-4777-8777-777777777777",
  "filename": "score.mid",
  "content_type": "audio/midi",
  "size_bytes": 4096
}

All fields are required. Generate a new UUID for request_id and retain it. Replace size_bytes with the actual size. Supported extensions are .mid and .midi, with a maximum size of 16 MiB and a score duration of 10–240 seconds.

The 201 Created response contains:

  • project_id: the project to use for conversion.
  • asset.id: the uploaded score's identifier; pass it later as midi_asset_id.
  • asset.status: the score's current upload/readiness status.
  • upload: when an upload is needed, its url, required headers, and expires_at.

Reusing the same request_id and file declaration recovers the same registration. It can also refresh a pending upload URL.

2. Upload and check the score

PUT the raw MIDI bytes to upload.url with every header in upload.headers. Do not send your Taan API key to that URL.

After uploading, call:

http
POST /api/v1/music/intents/{project_id}/midi-assets/{asset_id}/complete

Send an empty body, not {}. The response is 202 while verification is pending, or 200 when the score is ready or rejected. Check the score about every five seconds:

http
GET /api/v1/music/intents/{project_id}/midi-assets/{asset_id}

Read status: awaiting_upload, verifying, ready, or rejected. Continue only when it is ready. If it is rejected, read error.code and error.message; changing the file extension alone does not make an unsupported file valid.

3. Create the audio

POST /api/v1/music/midi

json
{
  "project_id": "11111111-1111-4111-8111-111111111111",
  "midi_asset_id": "88888888-8888-4888-8888-888888888888",
  "caption": "Gentle acoustic piano with warm sustained strings, instrumental, no vocals.",
  "seed": 42,
  "audio_format": "mp3"
}
Field Required Description
project_id Yes Project returned by MIDI registration.
midi_asset_id Yes asset.id of a ready MIDI file in that project.
caption Yes Desired sound, in one nonblank line of up to 256 characters. Describe the style, instruments, and mood; the MIDI file supplies the notes and timing.
seed Yes Integer from 0 to 2,147,483,647. Keep it unchanged when retrying this conversion.
audio_format No wav or mp3; defaults to wav.

Duration comes from the MIDI file; do not send duration_sec. The response is 202 Accepted with a job ID. Follow the same progress and download steps.

Repeating the same conversion request returns the existing job. Changing the score, caption, seed, or format after submission returns 409. Start a new MIDI registration with a new request_id for a different conversion.

Check progress and download

These steps apply to all four APIs. Save the submission response as accepted.json if using the shell examples.

bash
PROJECT_ID="$(jq -er '.project_id' accepted.json)"
JOB_ID="$(jq -er '.job_id' accepted.json)"
curl --fail-with-body --silent --show-error \
  "$TAAN_API_BASE_URL/api/v1/jobs/$JOB_ID" \
  -H "Authorization: Bearer $TAAN_API_KEY" \
  -o job.json
jq '{job_id, status, stage, error}' job.json

Repeat the GET about every five seconds while the job is queued or running. If your application stops waiting, resume with the same job ID later. A client timeout does not cancel the job.

status Your next step
queued Wait and check again.
running Wait and check again; stage can provide a progress label.
succeeded Read the outcome and download the result.
failed Read error.code; retain the job ID when investigating.

Use status to decide when a job is finished. stage is descriptive, not a percentage or a promised completion time. There are no public cancellation, webhook, or progress-streaming endpoints.

A successful result looks like this:

json
{
  "job_id": "22222222-2222-4222-8222-222222222222",
  "project_id": "11111111-1111-4111-8111-111111111111",
  "operation": "generate",
  "status": "succeeded",
  "stage": "completed",
  "result": {
    "music_id": "33333333-3333-4333-8333-333333333333",
    "music_version_id": "44444444-4444-4444-8444-444444444444",
    "outcome": "generated",
    "artifacts": [
      {
        "artifact_id": "55555555-5555-4555-8555-555555555555",
        "kind": "full_mix",
        "url": "https://example.com/your-temporary-audio-download",
        "expires_at": "2026-11-14T12:15:00Z"
      }
    ]
  },
  "error": null
}

The URL above is a placeholder. Use the URL in your own result. operation is generate for text, input, and MIDI jobs, or refine for refinement jobs.

Save music_version_id. Select the full_mix artifact for the complete track. Separate stem artifacts may also be returned, but are not guaranteed.

For the WAV text example:

bash
jq -e '.status == "succeeded"' job.json > /dev/null
MUSIC_VERSION_ID="$(jq -er '.result.music_version_id' job.json)"
AUDIO_URL="$(jq -er '[.result.artifacts[] | select(.kind == "full_mix")][0].url' job.json)"
curl --fail-with-body --silent --show-error "$AUDIO_URL" -o score.wav

Use .mp3 for an MP3 result. Choose the format when submitting a job, or request a supported format for the saved version below. Changing the download filename does not convert the audio.

Download links expire at expires_at. GET the same job again for fresh links to the same result. This does not create new music or charge again. Treat working upload and download URLs as private; do not publish them or attach your API key to them.

Download a saved version as WAV or MP3

POST /api/v1/music/download returns a temporary full-mix download URL for a saved music version in your API project. All three fields are required. Use the project's project_id and the completed job's result.music_version_id; set audio_format to wav or mp3.

Save this request as download.json, replacing the example IDs:

json
{
  "project_id": "11111111-1111-4111-8111-111111111111",
  "music_version_id": "44444444-4444-4444-8444-444444444444",
  "audio_format": "mp3"
}

If the version already has the requested format, the API returns its link. For supported WAV results, requesting MP3 exports the saved audio without generating music again, creating a new music version, or charging credits. The original WAV is preserved. MP3-to-WAV conversion and stem exports are not supported by this endpoint. If the requested format is unavailable for that version, the API returns 404.

The response is synchronous: 200 OK returns a URL, not a job ID. A new MP3 export may take several minutes; allow up to 25 minutes for the API request. This example allows 30 minutes including connection overhead:

bash
curl --fail-with-body --silent --show-error --max-time 1800 \
  "$TAAN_API_BASE_URL/api/v1/music/download" \
  -H "Authorization: Bearer $TAAN_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @download.json > download-response.json

Successful response:

json
{
  "url": "https://example.com/your-temporary-mp3-download",
  "expires_at": "2026-11-17T12:15:00Z"
}

The URL expires after 15 minutes. Download it without an API key. To refresh it or recover after a timeout, repeat the same project, version, and format request; no Idempotency-Key is required.

bash
AUDIO_URL="$(jq -er '.url' download-response.json)"
curl --fail-with-body --silent --show-error "$AUDIO_URL" -o score.mp3

Credits

GET /api/v1/me/credits returns your balance:

json
{
  "balance_credits": 1000,
  "reserved_credits": 100,
  "available_credits": 900
}

available_credits is what you can use for new work. reserved_credits are set aside for work in progress and are not available for another request.

Generation and changed refinements use credits. Reading your balance, checking a job, refreshing its download links, and exporting a supported saved version to MP3 are free. Retrying an identical music request according to the rules below returns its existing job without a second generation charge. Rate limits still apply to those API requests.

If a job reports INSUFFICIENT_CREDITS, check your balance before starting new work. For questions about a charge or failed job, retain its job ID.

Retry safely

An idempotency key identifies one intended operation. Use 1–128 printable, non-space ASCII characters. Store the key and exact request body before submitting; do not generate a new key simply because a request timed out.

Operation How to recover a lost response
Text generation Repeat the exact request with its required Idempotency-Key.
Input registration Repeat the exact request with the same Idempotency-Key. Without a key, another registration creates another project.
Input generation Repeat the same project_id and audio_format.
Refinement with a key Repeat the same key, project, source version, instruction, and format.
Refinement without a key The same project, source version, instruction, and format return the same job. Use a new key for an intentional repeat.
MIDI registration Repeat the same request_id and file declaration.
MIDI conversion Repeat the same project, MIDI asset, caption, seed, and format.
Format download Repeat the same project, music version, and format. This does not generate music or charge credits.
Job or readiness read Repeat the GET using the saved identifier.

Changing the request associated with an existing key or initial-generation job returns 409. Keep a separate key for each new text request, input registration, or refinement.

If you already have a job ID, check that job first. Do not automatically create replacement work after a timeout or failure. If you have neither a saved ID nor a recoverable request, contact support with the approximate request time before submitting again.

Rate limits

Limits are shared across API keys for the same Taan account. Activity in Studio and connected assistants can also use the same allowances. Creating another API key does not increase your limit.

API activity Sustained requests/minute Maximum burst when allowance is full
Read jobs, readiness, MIDI status, or account details 600 100
Register inputs/MIDI, refresh upload URLs, or complete non-MIDI uploads 60 15
Generate music or request a refinement, across all four APIs 12 4
Request a saved version as WAV or MP3 120 30
Complete a MIDI upload for checking 30 5

These are request-rate limits, not credit balances or guarantees of simultaneous music generation. Allowances recover over time; they do not reset together at the start of each minute. Repeated requests to the same job also count toward the relevant request limit. File transfers to the returned upload/download URLs are separate from these API requests.

When limited, the API returns 429 with a Retry-After header in seconds and a matching retry_after field:

json
{
  "code": "RATE_LIMITED",
  "error": "Too many requests. Try again shortly.",
  "retry_after": 4
}

Wait at least that long before retrying. Keep the original request, key, and IDs. Avoid immediate retry loops or starting replacement jobs.

503 RATE_LIMIT_UNAVAILABLE means the request cannot be accepted temporarily. Wait, then follow the same recovery rules. If a job was already accepted, continue checking that job.

Formats and limits

Item Supported values or limit
Text/input duration without video 10–240 seconds; default 30
Input duration with video Determined by the video; omit duration_sec
MIDI duration 10–240 seconds, determined by the uploaded score
Video MP4, MOV, WebM; up to 250 MiB
Script file TXT, PDF, DOCX; up to 20 MiB
MIDI .mid or .midi; up to 16 MiB
Standalone prompt Up to 8,000 characters
Combined musical direction Up to 8,000 characters, including separators between entries
Inline script Up to 100,000 characters
Refinement instruction Up to 8,000 characters
MIDI caption One nonblank line, up to 256 characters
Output WAV by default; optional MP3

One MiB is 1,048,576 bytes. Text must be nonblank. File extensions and content types must agree. An input request supports at most one video and one script, with accompanying musical direction.

Errors and troubleshooting

A request may fail immediately with an HTTP error. A job accepted with 202 can also fail later; always check its final status.

Response or symptom What to do
400 Check required fields, IDs, allowed values, and input combinations. Remove fields not supported by that endpoint.
401 Check that your API key is present, valid, and not expired or revoked.
403 Check whether your account is permitted to perform this action.
404 Check the path and IDs, and that the resource belongs to your account. A format-download request also returns this when the requested format is unavailable for that version.
409 CONFLICT Compare the request with your original submission. Recover the original job or use a new request for intentionally different work.
409 MIDI_NOT_READY Wait for the MIDI asset to become ready before conversion.
413 Reduce the request or file size to the documented limit.
422 UNSUPPORTED_REFINEMENT_SOURCE Use a supported version created by text or input generation.
Other 422 Read the error code and message; the supplied file or operation is unsupported.
429 RATE_LIMITED Wait for Retry-After, then retry with the same identifiers.
503 Temporary unavailability. Preserve your request and follow the retry rules.
Job remains queued or running Continue checking its existing job ID. Do not submit a replacement solely because it is taking longer.
Refinement succeeds but audio is unchanged Read result.outcome and result.explanation.
Download link expires GET the same job again for a fresh link.

For a failed job, read error.code. For an HTTP error, read code and error when present. When contacting support, share the endpoint, approximate request time, project/job IDs, and error code. Never share an API key or a private upload/download URL in a public message.

Endpoint reference

All paths below are relative to https://api.taan.ai. All require your Taan API key.

Method Path Purpose
POST /api/v1/music/text Create music directly from a prompt
POST /api/v1/music/input Create music from registered inputs
POST /api/v1/music/refine Refine a saved music version
POST /api/v1/music/midi Convert a ready MIDI asset to music
POST /api/v1/music/download Download a saved full mix as WAV or MP3; export supported WAV results to MP3
GET /api/v1/jobs/{job_id} Read progress and retrieve result/download links
GET /api/v1/me Read your authenticated user ID
GET /api/v1/me/credits Read your credit balance
POST /api/v1/music/intents Register inputs and obtain upload instructions
POST /api/v1/music/intents/{project_id}/refresh-uploads Refresh pending upload URLs
POST /api/v1/music/intents/{project_id}/complete-upload Check uploaded inputs
GET /api/v1/music/intents/{project_id}/readiness Read input readiness
POST /api/v1/music/midi/intents Create a MIDI project and register its score
POST /api/v1/music/intents/{project_id}/midi-assets Register another MIDI asset in an existing project
POST /api/v1/music/intents/{project_id}/midi-assets/{asset_id}/complete Complete a MIDI upload with an empty request body
GET /api/v1/music/intents/{project_id}/midi-assets/{asset_id} Read MIDI readiness and any rejection reason

For existing integrations, POST /api/v1/music/generate remains supported for registered text/input intents. It accepts the same body as /api/v1/music/input. New integrations can use the task-specific endpoints above.

Updated 17 November 2026.

Search the library

MCP, API, papers, and benchmark notesESC to close