Skip to article

Game music

Generate instrumental music or a song for your game.

What you can create

Generate music for exploration, combat, menus or cinematics. Lyria supports a requested duration and optional BPM; Suno uses its own generation controls. Example: create a 60-second instrumental forest exploration cue.

Prepare the music brief

Describe mood, instruments, energy and intended use in prompt. Choose engine: lyria or suno. Instrumental defaults to true. When instrumental is false, supply at least three characters of lyrics. No input image or audio upload is required for this text-to-music workflow.

Generate music in the workspace

  1. Open Game music generator.
  2. Choose the engine and describe the cue. Enter lyrics for a song.
  3. For Lyria, set the duration and optional tempo.
  4. Select a destination, review the cost and generate.
  5. Listen to all returned tracks and download the available audio formats.

Choices, limits and cost

A generation costs 4 credits. Lyria allows 1–240 seconds, defaulting to 60; Suno does not accept a user-controlled duration in this contract. Prompt length is 3–800 characters, lyrics up to 5,000. Lyria titles allow 120 characters; Suno titles allow 80. A result can contain multiple tracks; use task asset IDs instead of assuming one audio file.

Parameters

These fields are generated from the same input Schema used by REST and MCP. Nested required fields apply when their parent object or selected variant is present. Business conditions described above are validated before submission.

FieldTypeRequiredDefault and limits
characterIdstringNominLength: 1; maxLength: 255
characterTargetobject / objectNoSee the workflow requirements above.
projectIdstringNominLength: 1; maxLength: 255
folderIdstring / nullNoSee the workflow requirements above.
titlestringNoDefault: ""; maxLength: 120
promptstringYesminLength: 3; maxLength: 800
instrumentalbooleanNoDefault: true
lyricsstringNoDefault: ""; maxLength: 5000
enginestringYesMust be "lyria"
durationSecondsintegerNoDefault: 60; minimum: 1; maximum: 240
bpmintegerNominimum: 1; maximum: 9007199254740991
enginestringYesMust be "suno"
titlestringNoDefault: ""; maxLength: 80

API example

This example costs 4 credits. A quote does not reserve balance or bypass subscription requirements. Set SPRITEFLOW_API_KEY in your shell. Replace the placeholder asset ID 00000000-0000-4000-8000-000000000001 with a ready asset you own when present. Use a new idempotency key for each intentional generation; keep it unchanged when retrying.

bash

# Use the same BASE_URL for credentials, uploads and generation.
BASE_URL="https://spriteflow.io"
IDEMPOTENCY_KEY="example-workflow-001"

cat > request.json <<'JSON'
{
  "operation": "generate_music",
  "input": {
    "engine": "lyria",
    "prompt": "Quiet forest exploration, acoustic guitar and soft strings",
    "durationSeconds": 60,
    "instrumental": true
  }
}
JSON

curl --fail-with-body "$BASE_URL/api/v1/estimates" \
  -H "Authorization: Bearer $SPRITEFLOW_API_KEY" \
  -H "Content-Type: application/json" --data-binary @request.json

curl --fail-with-body "$BASE_URL/api/v1/tasks" \
  -H "Authorization: Bearer $SPRITEFLOW_API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" --data-binary @request.json

An accepted request returns HTTP 202, Location and Retry-After headers. Example response (IDs are illustrative):

json
{"taskId":"00000000-0000-4000-8000-000000000002","status":"accepted","statusUrl":"/api/v1/tasks/00000000-0000-4000-8000-000000000002","pollAfterSeconds":10,"replayed":false}

MCP example

Call estimate_cost with the same operation and input, then call generate_music. The following is a tools/call params object:

json
{
  "name": "generate_music",
  "arguments": {
    "input": {
      "engine": "lyria",
      "prompt": "Quiet forest exploration, acoustic guitar and soft strings",
      "durationSeconds": 60,
      "instrumental": true
    },
    "idempotencyKey": "example-workflow-001"
  }
}

The tool returns the same task receipt in structuredContent and a JSON text result. Pass taskId to get_task. Tool annotations describe behavior; permissions are still checked on the server.

Completion, download and reuse

Poll the returned statusUrl after pollAfterSeconds. Continue while terminal is false. Read items for per-task results, progress for batch counts and assets for ready files. A batch can be partially_completed: use its successful assets and review each failed item before deciding whether to create a separate retry.

For each returned asset ID, call get_download_url or GET /api/v1/assets/{assetId}/download. Download the temporary URL before it expires. Image assets can be passed into a compatible operation as inputAssetId or a style reference. Do not pass provider task IDs, download URLs or local filesystem paths as asset IDs.

Failures and recovery

  • INVALID_PARAMETERS: fix the field errors before submitting. Check the business conditions and defaults above.
  • INPUT_ASSET_UNAVAILABLE: confirm the upload, check ownership and ensure the asset is ready and not trashed.
  • INSUFFICIENT_CREDITS: add credits before a new request; a cost estimate does not reserve them.
  • A timeout or lost response: resend the identical request with the original idempotency key. Never invent a new key just because the response was lost.
  • A terminal generation failure: inspect the item error and refund information. Refund handling uses the existing generation workflow. Do not assume an in-progress or unknown submission is safe to repeat.

Uploads · Tasks · Credits · Idempotency · Save destinations · Download and export