Lyria 3.5 is Google's family of music generation models, available through the Gemini API. With Lyria 3.5, you can generate high-quality, 44.1 kHz stereo audio from text prompts or from images. These models deliver structural coherence, including vocals, timed lyrics, and full instrumental arrangements.
The Lyria family includes models:
| Model | Model ID | Best for | Duration | Output |
|---|---|---|---|---|
| Lyria 3 Clip | lyria-3-clip-preview |
Short clips, loops, previews | 30 seconds | MP3 |
| Lyria 3.5 | lyria-3.5 |
Full-length songs with verses, choruses, bridges | A couple of minutes (controllable using prompt) | MP3 |
Both models can be used using the new Interactions API, supporting multimodal inputs (text and images), and produce 44.1 kHz high-fidelity stereo audio.
Generate a music clip
The Lyria 3 Clip model always generates a 30-second clip. To generate a
clip, call the interactions.create method with a text prompt. The response
always includes the generated lyrics and song structure alongside the audio in
the steps schema.
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="lyria-3-clip-preview",
input="A short instrumental acoustic guitar piece.",
)
generated_audio = interaction.output_audio
if generated_audio:
with open("music.mp3", "wb") as f:
f.write(base64.b64decode(generated_audio.data))
lyrics = interaction.output_text
if lyrics:
print(f"Lyrics:\n{lyrics}")
JavaScript
import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: 'lyria-3-clip-preview',
input: 'A short instrumental acoustic guitar piece.',
});
const generatedAudio = interaction.output_audio;
if (generatedAudio) {
fs.writeFileSync('music.mp3', Buffer.from(generatedAudio.data, 'base64'));
}
const lyrics = interaction.output_text;
if (lyrics) {
console.log(`Lyrics:\n${lyrics}`);
}
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("lyria-3-clip-preview"))
.input(InteractionsInput.of("A short instrumental acoustic guitar piece."))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
if (interaction.outputAudio().isPresent() && interaction.outputAudio().get().data().isPresent()) {
byte[] audioBytes = Base64.getDecoder().decode(interaction.outputAudio().get().data().get());
Files.write(Paths.get("music.mp3"), audioBytes);
}
interaction.outputText().ifPresent(lyrics -> System.out.println("Lyrics:\n" + lyrics));
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"model": "lyria-3-clip-preview",
"input": "A short instrumental acoustic guitar piece."
}'
You can retrieve generated music data by using the interaction.output_audio
property, which returns the last generated audio block. You can also retrieve
the song's lyrics and structure by using the interaction.output_text
property. For details on convenience properties, see the
Interactions overview.
Generate a full-length song
Use the lyria-3.5 model to generate full-length songs that last a
couple of minutes. The Pro model understands musical structure and can create
compositions with distinct verses, choruses, and bridges. You can influence the
duration by specifying it in your prompt (e.g., "create a 2-minute song") or by
using timestamps to define the structure.
Python
interaction = client.interactions.create(
model="lyria-3.5",
input="An epic cinematic orchestral piece about a journey home. Starts with a solo piano intro, builds through sweeping strings, and climaxes with a massive wall of sound.",
)
JavaScript
const interaction = await client.interactions.create({
model: 'lyria-3.5',
input: 'A beautiful piano melody.',
});
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("lyria-3.5"))
.input(
InteractionsInput.of(
"An epic cinematic orchestral piece about a journey home. Starts with a solo piano intro, builds through sweeping strings, and climaxes with a massive wall of sound."))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
REST
curl -X POST "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 beautiful piano melody."
}'
Select output format
By default, the Lyria 3.5 models generate audio in MP3 format. For
Lyria 3.5, you can also request the output in WAV format by setting
the response_format.
Python
interaction = client.interactions.create(
model="lyria-3.5",
input="A beautiful piano melody.",
response_format={"type": "audio"},
)
JavaScript
const interaction = await client.interactions.create({
model: 'lyria-3.5',
input: 'A beautiful piano melody.',
response_format: {
type: 'audio',
},
});
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AudioResponseFormat;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseFormat;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("lyria-3.5"))
.input(InteractionsInput.of("A beautiful piano melody."))
.responseFormat(
CreateModelInteractionResponseFormat.of(
ResponseFormat.of(AudioResponseFormat.builder().build())))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "lyria-3.5",
"input": "A beautiful piano melody.",
"response_format": {
"type": "audio"
}
}'
Parse the response
The response from Lyria 3.5 contains multiple content blocks within the steps schema.
Interactions return a sequence of steps, where model_output steps contain the
generated content.
Text content blocks contain the generated lyrics or a JSON description of the song
structure.
Content blocks with audio type contain the base64 encoded audio data.
Python
lyrics = []
audio_data = None
generated_audio = interaction.output_audio
if generated_audio:
with open("output.mp3", "wb") as f:
f.write(base64.b64decode(generated_audio.data))
lyrics = interaction.output_text
if lyrics:
print(f"Lyrics:\n{lyrics}")
JavaScript
const lyrics = [];
let audioData = null;
const generatedAudio = interaction.output_audio;
if (generatedAudio) {
fs.writeFileSync("output.mp3", Buffer.from(generatedAudio.data, 'base64'));
}
const lyrics = interaction.output_text;
if (lyrics) {
console.log("Lyrics:\n" + lyrics);
}
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("lyria-3.5"))
.input(InteractionsInput.of("A song about a starry night."))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
if (interaction.outputAudio().isPresent() && interaction.outputAudio().get().data().isPresent()) {
byte[] audioBytes = Base64.getDecoder().decode(interaction.outputAudio().get().data().get());
Files.write(Paths.get("output.mp3"), audioBytes);
}
if (interaction.outputText().isPresent()) {
System.out.println("Lyrics:\n" + interaction.outputText().get());
}
REST
# The output from the REST API is a JSON object containing base64 encoded data.
# You can extract the text or the audio data using a tool like jq.
# To extract the audio and save it to a file:
curl ... | jq -r '.steps[] | select(.type=="model_output") | .content[] | select(.type=="audio") | .data' | base64 -d > output.mp3
Interleaved lyrics and music
Because the output from Lyria 3.5 is complex—containing separate steps and blocks for generated lyrics (text) and the song itself (audio)—convenience properties offer a fast and recommended shortcut.
However, if you want full, programmatic control over the raw timeline of steps
returned by the server (such as logging individual content blocks as they are
received), you can manually iterate over steps instead:
Python
lyrics = []
audio_data = None
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "audio":
audio_data = base64.b64decode(content_block.data)
elif content_block.type == "text":
lyrics.append(content_block.text)
if lyrics