Lyria 3.5 API requests and MP3 responses
Use the lyria-3.5 model ID with the Interactions API, find MP3 audio in model output steps, and understand safe request handling.
Model and endpoint
The official model page lists lyria-3.5 as a preview model. The music generation documentation uses the Interactions API for full-length music generation.
PlayLyria fixes its generation integration to lyria-3.5. It does not label output from Lyria RealTime or an older clip model as Lyria 3.5.
A minimal REST request
Run the request on a trusted server with a key provided through the environment. Do not put a Google API key in a browser bundle or public repository.
curl https://generativelanguage.googleapis.com/v1beta/interactions \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"model": "lyria-3.5",
"input": "A gentle instrumental piano piece with soft strings. No vocals."
}'
This example follows the published API contract. A live call, timing, quota, and billing still need to be verified with the account that will run it; this guide does not present a simulated response as a successful live generation.
Find the MP3 data
The documented REST response contains steps. Steps of type model_output contain content blocks. Audio blocks have type audio and carry base64 data. Text blocks may contain lyrics or information about the structure.
const audioBlocks = interaction.steps
.filter((step) => step.type === 'model_output')
.flatMap((step) => step.content ?? [])
.filter((block) => block.type === 'audio');
const audio = audioBlocks.at(-1);
if (!audio?.data) throw new Error('No audio was returned');
const mp3Bytes = Buffer.from(audio.data, 'base64');
MP3 is the documented default output. Check the returned media type and file validity before offering a download. The requested duration is not a substitute for reading the actual audio duration.
Treat a timeout as an uncertain result
If the network connection ends after a paid request was sent, it does not prove that the provider did no work. Automatically resending can create a second paid generation.
Store your task ID and a submission marker before contacting the provider. When audio is returned, save the existing bytes under a deterministic file key. Retry file storage or accounting separately; do not regenerate music to repair a storage failure.
Do not infer model-specific background execution, cancellation, or request idempotency from another model’s API documentation. Verify those capabilities with the exact account and model first.
Price and practical limits
Google’s pricing page lists a base price of $0.08 per track as checked on September 5, 2026. Confirm charges against actual billing, including failures. Preview availability and quotas may differ by project.
For a browser workflow that manages sign-in, credits, playback, and downloads, use the PlayLyria generator. API billing and PlayLyria credits are separate.