Write lyrics

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

Writes song lyrics and a title from a short prompt and returns them in the answer.

Cost
0 credits
Rate limit
Write
Idempotency key
Optional
Daily limit
lyrics
MCP tool
write_lyrics
CLI (coming soon)
mozart lyrics create

When to use: The user wants lyrics written for them, or you want to show lyrics before making a song. Pass prompt and, if needed, language. Pass the returned lyrics to POST /v1/songs as lyrics, and the returned title as title if the user likes it.

When not to use: When the user already has lyrics, pass them straight to POST /v1/songs. That call can also write lyrics itself from its prompt.

Side effects: Nothing is saved; the lyrics and title are only in the answer. Each call without an idempotency key writes new lyrics and counts against the daily lyrics limit again; with the same key it returns the first lyrics and title. title is null only when no title could be written; the lyrics are still usable.

Authentication

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

  • generate
  • credits:spend

Headers

  • idempotency-keystringOptional1 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

  • promptstringRequired
  • languagestringOptional2 to 35 characters
  • dry_runbooleanOptionalDefaults to false

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

Response 200

Success.

  • dry_runbooleanRequired
  • estimateobjector nullRequired
    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
  • titlestringor nullRequired
  • lyricsstringor nullRequired
  • credits_chargednumberor nullRequired
  • balance_afternumberor nullRequired

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: PUBLIC_API_DAILY_LIMIT_REACHED: stop and tell the user when it resets (resets_at). content_refused: revise the prompt once; never reword to get around the refusal.

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.