Create a song

POSThttps://api.mozartai.com/v1/songs

Starts a job that makes two new songs from a text prompt with Hans 2.0, with optional lyrics.

Cost
25 credits
Rate limit
Write
Idempotency key
Required
Runs as a job
Poll or wait on job.id
MCP tool
create_song
CLI (coming soon)
mozart songs create

When to use: The user asks for a new song. Pass prompt; add lyrics for words to sing, or instrumental for no vocals. The answer comes back at once with job.id and project_id; then call POST /v1/jobs/wait until the job has succeeded.

When not to use: To remake an existing song or uploaded audio in a new style, use POST /v1/covers. For lyrics only, use POST /v1/lyrics.

Side effects: Creates one job and two songs in the user's library, private, in the key's current project or project_id. Repeating the call with the same idempotency key returns the first job and spends nothing; a new key starts and charges a second job. Never create again while the job is running.

Authentication

Send your API key as Authorization: Bearer <key>. The key needs these scopes:

  • generate
  • credits:spend

Headers

  • idempotency-keystringRequired1 to 255 characters

    A unique string per intended action. Repeating a call with the same key returns the first answer instead of doing the work twice: a key is bound to its first request for 90 days; its response is replayed for 24 hours; use a new key for a new request.

Request body

  • promptstringRequired1 to 10000 characters

    What the song should be: style, mood, instruments, subject. Hans 2.0 rewrites a prompt over 1,000 characters to fit before it generates.

  • lyricsstringOptionalat most 3000 characters

    Words to sing, with optional section labels such as [Verse] and [Chorus]. Leave out both this and instrumental to have lyrics written from the prompt.

  • instrumentalbooleanOptionalDefaults to false

    Make the songs without vocals. Not allowed with lyrics.

  • titlestringOptional1 to 200 characters

    The title of both songs. Leave it out to have titles written from the prompt.

  • modelenumOptional

    The model that makes the songs. Leave it out to use the default model. Only the models in the models list are accepted.

  • duration_secondsintegerOptionalat most 300

    The song length in seconds, for a model whose max_duration_seconds in the models list is a number. A model whose max_duration_seconds is null picks its own length and refuses this field with GENERATION_INPUT_NOT_SUPPORTED_BY_MODEL.

  • project_idstringOptional

    The project to put the songs in. Leave it out to use the key's current project.

  • dry_runbooleanOptionalDefaults to false

    Return the price and balance without starting a job or spending credits.

dry_run still needs an idempotency-key header, like every write. Use a different key from the real request.

Response 202

The job started (or, with dry_run, the price it would cost).

  • dry_runbooleanRequired
  • estimateobjector nullRequired

    The price check. Always filled on a dry run. On a real start some operations fill it and others leave it null (song and cover starts do), so read it only on a dry run and read the charge from job.credits_charged.

    Show 3 properties
    • credits_requirednumberRequired
    • balancenumberRequired

      The credits available now: the balance minus credits held by jobs that have not finished, the same number as available in the credits read.

    • balance_afternumberRequired
  • jobobjector nullRequired
    Show 14 properties
    • idstringRequired
    • objectconstantRequired
    • kindenumRequired
      Show 9 values
      • song
      • cover
      • inpaint
      • stem
      • stems
      • midi
      • master
      • cover_art
      • persona
    • statusenumRequired
      Allowed values
      • queued
      • running
      • succeeded
      • failed
      • cancelled
    • playablebooleanRequired
    • project_idstringor nullRequired
    • song_idslist of stringRequired
    • outputslist of objectRequired
      Show 8 properties
      • typeenumRequired
        Allowed values
        • audio
        • stem
        • midi
        • image
        • persona
      • song_idstringor nullRequired
      • persona_idstringor nullRequired
      • labelstringor nullRequired
      • urlstringor nullRequired
      • url_expires_atstringor nullRequired
      • content_typestringor nullRequired
      • duration_secondsnumberor nullRequired
    • credits_chargednumberor nullRequired

      null while the job is pending; the settled ledger debit once it finishes; 0 for free operations, test keys and released or refunded holds

    • credits_refundedbooleanRequired
    • errorobjector nullRequired
      Show 3 properties
      • codestringRequired
      • messagestringRequired
      • next_stepstringor nullRequired
    • poll_after_secondsnumberor nullRequired
    • created_atstringRequired
    • completed_atstringor nullRequired
  • balance_afternumberor nullRequired

    The balance after this call's hold, when the operation reports it; null on song and cover starts. Read GET /v1/credits for the current balance.

Response headers

  • x-request-idThe id of this request; quote it when asking for help.
  • x-mozart-api-versionThe API version that answered.
  • x-ratelimit-limitRequests allowed in the current window for this caller.
  • x-ratelimit-remainingRequests left in the current window.
  • x-ratelimit-resetWhen the window resets, in Unix seconds.
  • idempotent-replayedtrue when this answer is the stored answer to an earlier call with the same idempotency key; the work was not done again.

Errors

What to do: INSUFFICIENT_CREDITS (type insufficient_credits): stop, tell the user (with plans_url if set); never retry. PUBLIC_API_RATE_LIMITED: wait retry_after_seconds, then retry once with the same idempotency key. PUBLIC_API_MODEL_NOT_AVAILABLE: pick one of allowed_models. PUBLIC_API_PROJECT_SONG_LIMIT_REACHED: call again without project_id.

StatusTypeMeaning
400invalid_requestThe request is malformed or an input is invalid.
401authenticationThe key or token is missing, invalid or revoked.
402insufficient_creditsThe account has too few credits for this call. A REST key also needs an API plan (Starter, Build, Scale or Growth) or API credits; with neither, every call is refused with PUBLIC_API_CREDITS_REQUIRED. payment_required: The account's plan does not include this; it needs an upgrade.
403permissionThe caller may not do this: a missing scope, a Mozart CLI sign-in whose account is below Pro, or access not enabled.
404not_foundThe resource or route does not exist for this caller.
409conflictThe request conflicts with the current state, or an idempotency key was reused with a different body.
422content_refusedThe input was refused by content screening.
429rate_limitedToo many requests; retry after Retry-After seconds. limit_reached: A daily, concurrent or total limit was reached.
500internalMozart failed to answer; retry later.
503provider_unavailableA generation provider is unavailable; retry later. service_unavailable: A Mozart check the request needs, such as content screening, is temporarily unavailable; retry after retry_after_seconds.