> ## AI Agent Context > Get the complete documentation index at: https://aistudio.google.com/llms.txt > Use this file to discover all available pages. > For the full documentation in a single file, fetch: https://aistudio.google.com/llms-full.txt # Generate music with Lyria 3.5 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 via prompt) | MP3 | Both models can be used using the standard `generateContent` method and the new [Interactions API](/docs/interactions-overview), supporting multimodal inputs (text and images), and produce **44.1 kHz high-fidelity stereo** audio. {% callout type="note" %} Looking for real-time, streaming music generation? See [Real-time music generation with Lyria RealTime](/docs/realtime-music-generation). {% /callout %} ## Generate a music clip {% id="generate-music" %} The Lyria 3 Clip model always generates a **30-second** clip. To generate a clip, call the `generateContent` method with a text prompt. The response always includes the generated lyrics and song structure alongside the audio. {% tabs %} {% tab label="Python" %} ```python from google import genai client = genai.Client() response = client.models.generate_content( model="lyria-3-clip-preview", contents="Create a 30-second cheerful acoustic folk song with " "guitar and harmonica.", ) # Parse the response for part in response.parts: if part.text is not None: print(part.text) elif part.inline_data is not None: with open("clip.mp3", "wb") as f: f.write(part.inline_data.data) print("Audio saved to clip.mp3") ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import { GoogleGenAI } from "@google/genai"; import * as fs from "node:fs"; const ai = new GoogleGenAI({}); async function main() { const response = await ai.models.generateContent({ model: "lyria-3-clip-preview", contents: "Create a 30-second cheerful acoustic folk song with " + "guitar and harmonica.", }); for (const part of response.candidates[0].content.parts) { if (part.text) { console.log(part.text); } else if (part.inlineData) { const buffer = Buffer.from(part.inlineData.data, "base64"); fs.writeFileSync("clip.mp3", buffer); console.log("Audio saved to clip.mp3"); } } } await main(); ``` {% /tab %} {% tab label="Go" %} ```go package main import ( "context" "fmt" "log" "os" "google.golang.org/genai" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, nil) if err != nil { log.Fatal(err) } result, err := client.Models.GenerateContent( ctx, "lyria-3-clip-preview", genai.Text("Create a 30-second cheerful acoustic folk song " + "with guitar and harmonica."), nil, ) if err != nil { log.Fatal(err) } for _, part := range result.Candidates[0].Content.Parts { if part.Text != "" { fmt.Println(part.Text) } else if part.InlineData != nil { err := os.WriteFile("clip.mp3", part.InlineData.Data, 0644) if err != nil { log.Fatal(err) } fmt.Println("Audio saved to clip.mp3") } } } ``` {% /tab %} {% tab label="Java" %} ```java import com.google.genai.Client; import com.google.genai.types.GenerateContentResponse; import com.google.genai.types.Part; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class GenerateMusicClip { public static void main(String[] args) throws IOException { try (Client client = new Client()) { GenerateContentResponse response = client.models.generateContent( "lyria-3-clip-preview", "Create a 30-second cheerful acoustic folk song with " + "guitar and harmonica."); for (Part part : response.parts()) { if (part.text().isPresent()) { System.out.println(part.text().get()); } else if (part.inlineData().isPresent()) { var blob = part.inlineData().get(); if (blob.data().isPresent()) { Files.write(Paths.get("clip.mp3"), blob.data().get()); System.out.println("Audio saved to clip.mp3"); } } } } } } ``` {% /tab %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3-clip-preview:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [ {"text": "Create a 30-second cheerful acoustic folk song with guitar and harmonica."} ] }] }' ``` {% /tab %} {% tab label="C#" %} ```csharp using System.Threading.Tasks; using Google.GenAI; using Google.GenAI.Types; using System.IO; public class GenerateMusicClip { public static async Task main() { var client = new Client(); var response = await client.Models.GenerateContentAsync( model: "lyria-3-clip-preview", contents: "Create a 30-second cheerful acoustic folk song with guitar and harmonica." ); foreach (var part in response.Candidates[0].Content.Parts) { if (part.Text != null) { Console.WriteLine(part.Text); } else if (part.InlineData != null) { await File.WriteAllBytesAsync("clip.mp3", part.InlineData.Data); Console.WriteLine("Audio saved to clip.mp3"); } } } } ``` {% /tab %} {% /tabs %} {% audio src="https://storage.googleapis.com/generativeai-downloads/songs/Feels%20Sublime.wav" type="audio/wav" /%} For more examples, refer to the [Lyria 3.5 Notebook](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Get_started_Lyria.ipynb) in the Cookbooks repository. ## Generate a full-length song {% id="full-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](/docs/music-generation#timing) to define the structure. {% tabs %} {% tab label="Python" %} ```python response = client.models.generate_content( model="lyria-3.5", contents="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.", ) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript const response = await ai.models.generateContent({ model: "lyria-3.5", contents: "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.", }); ``` {% /tab %} {% tab label="Go" %} ```go result, err := client.Models.GenerateContent( ctx, "lyria-3.5", genai.Text("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."), nil, ) ``` {% /tab %} {% tab label="Java" %} ```java GenerateContentResponse response = client.models.generateContent( "lyria-3.5", "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."); ``` {% /tab %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [ {"text": "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."} ] }] }' ``` {% /tab %} {% tab label="C#" %} ```csharp var response = await client.Models.GenerateContentAsync( model: "lyria-3.5", contents: "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." ); ``` {% /tab %} {% /tabs %} {% audio src="https://storage.googleapis.com/generativeai-downloads/songs/The%20Final%20Horizon.wav" type="audio/wav" /%} ## Select output format {% id="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** (`AUDIO_WAV`) format by setting `generationConfig.responseFormat.audio.mimeType` to `"AUDIO_WAV"`. {% callout type="note" %} Custom `responseFormat` (`response_format`) overrides on `generateContent` are supported using the REST API until the SDKs expose `response_format` on `GenerateContentConfig`. For SDK support, use the [Interactions API](/docs/music-generation#output-format). {% /callout %} {% tabs %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [ {"text": "An atmospheric ambient track."} ] }], "generationConfig": { "responseModalities": ["AUDIO", "TEXT"], "responseFormat": { "audio": { "mimeType": "AUDIO_WAV" } } } }' ``` {% /tab %} {% /tabs %} ## Parse the response {% id="parse-response" %} The response from Lyria 3.5 contains multiple parts. Text parts contain the generated lyrics or a JSON description of the song structure. Parts with `inline_data` contain the audio bytes. Important: You should not assume the lyrics are always the first part. Always iterate through all parts and check the type of each one. {% tabs %} {% tab label="Python" %} ```python lyrics = [] audio_data = None for part in response.parts: if part.text is not None: lyrics.append(part.text) elif part.inline_data is not None: audio_data = part.inline_data.data if lyrics: print("Lyrics:\n" + "\n".join(lyrics)) if audio_data: with open("output.mp3", "wb") as f: f.write(audio_data) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import { GoogleGenAI } from "@google/genai"; import * as fs from "node:fs"; const ai = new GoogleGenAI({}); async function main() { const response = await ai.models.generateContent({ model: "lyria-3-clip-preview", contents: "Create a 30-second cheerful acoustic folk song with " + "guitar and harmonica.", }); for (const part of response.candidates[0].content.parts) { if (part.text) { console.log(part.text); } else if (part.inlineData) { const buffer = Buffer.from(part.inlineData.data, "base64"); fs.writeFileSync("clip.mp3", buffer); console.log("Audio saved to clip.mp3"); } } } await main(); ``` {% /tab %} {% tab label="Go" %} ```go package main import ( "context" "fmt" "log" "os" "google.golang.org/genai" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, nil) if err != nil { log.Fatal(err) } result, err := client.Models.GenerateContent( ctx, "lyria-3-clip-preview", genai.Text("Create a 30-second cheerful acoustic folk song " + "with guitar and harmonica."), nil, ) if err != nil { log.Fatal(err) } for _, part := range result.Candidates[0].Content.Parts { if part.Text != "" { fmt.Println(part.Text) } else if part.InlineData != nil { err := os.WriteFile("clip.mp3", part.InlineData.Data, 0644) if err != nil { log.Fatal(err) } fmt.Println("Audio saved to clip.mp3") } } } ``` {% /tab %} {% tab label="Java" %} ```go package main import ( "context" "fmt" "log" "os" "google.golang.org/genai" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, nil) if err != nil { log.Fatal(err) } result, err := client.Models.GenerateContent( ctx, "lyria-3-clip-preview", genai.Text("Create a 30-second cheerful acoustic folk song " + "with guitar and harmonica."), nil, ) if err != nil { log.Fatal(err) } for _, part := range result.Candidates[0].Content.Parts { if part.Text != "" { fmt.Println(part.Text) } else if part.InlineData != nil { err := os.WriteFile("clip.mp3", part.InlineData.Data, 0644) if err != nil { log.Fatal(err) } fmt.Println("Audio saved to clip.mp3") } } } ``` {% /tab %} {% tab label="C#" %} ```csharp var lyrics = new List<string>(); byte[] audioData = null; foreach (var part in response.Candidates[0].Content.Parts) { if (part.Text != null) { lyrics.Add(part.Text); } else if (part.InlineData != null) { audioData = part.InlineData.Data; } } if (lyrics.Count > 0) { Console.WriteLine("Lyrics:\n" + string.Join("\n", lyrics)); } if (audioData != null) { await File.WriteAllBytesAsync("output.mp3", audioData); } ``` {% /tab %} {% tab label="REST" %} ```bash # 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 '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' | base64 -d > output.mp3 ``` {% /tab %} {% /tabs %} ## Generate music from images {% id="image-to-music" %} Lyria 3.5 supports multimodal inputs - you can provide up to **10 images** alongside your text prompt and the model will compose music inspired by the visual content. {% tabs %} {% tab label="Python" %} ```python from PIL import Image image = Image.open("desert_sunset.jpg") response = client.models.generate_content( model="lyria-3.5", contents=[ "An atmospheric ambient track inspired by the mood and " "colors in this image.", image, ], ) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import { GoogleGenAI } from '@google/genai'; import * as fs from 'node:fs'; const ai = new GoogleGenAI({}); const imageBytes = fs.readFileSync('desert_sunset.jpg').toString('base64'); const response = await ai.models.generateContent({ model: 'lyria-3-clip-preview', contents: [ 'An atmospheric ambient track inspired by the mood and colors in this image.', { inlineData: { mimeType: 'image/jpeg', data: imageBytes, }, }, ], }); for (const candidate of response.candidates ?? []) { for (const part of candidate.content?.parts ?? []) { if (part.text) { console.log(part.text); } else if (part.inlineData?.data) { const buffer = Buffer.from(part.inlineData.data, 'base64'); fs.writeFileSync('clip.mp3', buffer); console.log('Audio saved to clip.mp3'); } } } ``` {% /tab %} {% tab label="Go" %} ```go package main import ( "context" "fmt" "log" "os" "google.golang.org/genai" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, nil) if err != nil { log.Fatal(err) } result, err := client.Models.GenerateContent( ctx, "lyria-3-clip-preview", genai.Text("Create a 30-second cheerful acoustic folk song " + "with guitar and harmonica."), nil, ) if err != nil { log.Fatal(err) } for _, part := range result.Candidates[0].Content.Parts { if part.Text != "" { fmt.Println(part.Text) } else if part.InlineData != nil { err := os.WriteFile("clip.mp3", part.InlineData.Data, 0644) if err != nil { log.Fatal(err) } fmt.Println("Audio saved to clip.mp3") } } } ``` {% /tab %} {% tab label="Java" %} ```go package main import ( "context" "fmt" "log" "os" "google.golang.org/genai" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, nil) if err != nil { log.Fatal(err) } result, err := client.Models.GenerateContent( ctx, "lyria-3-clip-preview", genai.Text("Create a 30-second cheerful acoustic folk song " + "with guitar and harmonica."), nil, ) if err != nil { log.Fatal(err) } for _, part := range result.Candidates[0].Content.Parts { if part.Text != "" { fmt.Println(part.Text) } else if part.InlineData != nil { err := os.WriteFile("clip.mp3", part.InlineData.Data, 0644) if err != nil { log.Fatal(err) } fmt.Println("Audio saved to clip.mp3") } } } ``` {% /tab %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H 'Content-Type: application/json' \ -d "{ \"contents\": [{ \"parts\":[ {\"text\": \"An atmospheric ambient track inspired by the mood and colors in this image.\"}, { \"inline_data\": { \"mime_type\":\"image/jpeg\", \"data\": \"<BASE64_IMAGE_DATA>\" } } ] }] }" ``` {% /tab %} {% tab label="C#" %} ```csharp var response = await client.Models.GenerateContentAsync( model: "lyria-3.5", contents: new List<Part> { Part.FromText("An atmospheric ambient track inspired by the mood and colors in this image."), Part.FromBytes(await File.ReadAllBytesAsync("desert_sunset.jpg"), "image/jpeg") } ); ``` {% /tab %} {% /tabs %}  {% audio src="https://storage.googleapis.com/generativeai-downloads/songs/Purple%20Desert%20Haze.wav" type="audio/wav" /%} ## Provide custom lyrics {% id="custom-lyrics" %} You can write your own lyrics and include them in the prompt. Use section tags like `[Verse]`, `[Chorus]`, and `[Bridge]` to help the model understand the song structure: {% tabs %} {% tab label="Python" %} ```python prompt = """ Create a dreamy indie pop song with the following lyrics: [Verse 1] Walking through the neon glow, city lights reflect below, every shadow tells a story, every corner, fading glory. [Chorus] We are the echoes in the night, burning brighter than the light, hold on tight, don't let me go, we are the echoes down below. [Verse 2] Footsteps lost on empty streets, rhythms sync to heartbeats, whispers carried by the breeze, dancing through the autumn leaves. """ response = client.models.generate_content( model="lyria-3.5", contents=prompt, ) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import { GoogleGenAI } from '@google/genai'; import * as fs from 'node:fs'; const ai = new GoogleGenAI({}); const prompt = ` Create a dreamy indie pop song with the following lyrics: [Verse 1] Walking through the neon glow, city lights reflect below, every shadow tells a story, every corner, fading glory. [Chorus] We are the echoes in the night, burning brighter than the light, hold on tight, don't let me go, we are the echoes down below. [Verse 2] Footsteps lost on empty streets, rhythms sync to heartbeats, whispers carried by the breeze, dancing through the autumn leaves. `; const response = await ai.models.generateContent({ model: 'lyria-3-clip-preview', contents: prompt, }); for (const candidate of response.candidates ?? []) { for (const part of candidate.content?.parts ?? []) { if (part.text) { console.log(part.text); } else if (part.inlineData?.data) { const buffer = Buffer.from(part.inlineData.data, 'base64'); fs.writeFileSync('clip.mp3', buffer); console.log('Audio saved to clip.mp3'); } } } ``` {% /tab %} {% tab label="Go" %} ```go prompt := ` Create a dreamy indie pop song with the following lyrics: [Verse 1] Walking through the neon glow, city lights reflect below, every shadow tells a story, every corner, fading glory. [Chorus] We are the echoes in the night, burning brighter than the light, hold on tight, don't let me go, we are the echoes down below. [Verse 2] Footsteps lost on empty streets, rhythms sync to heartbeats, whispers carried by the breeze, dancing through the autumn leaves. ` result, err := client.Models.GenerateContent( ctx, "lyria-3.5", genai.Text(prompt), nil, ) ``` {% /tab %} {% tab label="Java" %} ```java import com.google.genai.Client; import com.google.genai.types.GenerateContentResponse; import com.google.genai.types.Part; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class GenerateMusicClip { public static void main(String[] args) throws IOException { try (Client client = new Client()) { GenerateContentResponse response = client.models.generateContent( "lyria-3-clip-preview", "Create a 30-second cheerful acoustic folk song with " + "guitar and harmonica."); for (Part part : response.parts()) { if (part.text().isPresent()) { System.out.println(part.text().get()); } else if (part.inlineData().isPresent()) { var blob = part.inlineData().get(); if (blob.data().isPresent()) { Files.write(Paths.get("clip.mp3"), blob.data().get()); System.out.println("Audio saved to clip.mp3"); } } } } } } ``` {% /tab %} {% tab label="C#" %} ```csharp var prompt = @" Create a dreamy indie pop song with the following lyrics: [Verse 1] Walking through the neon glow, city lights reflect below, every shadow tells a story, every corner, fading glory. [Chorus] We are the echoes in the night, burning brighter than the light, hold on tight, don't let me go, we are the echoes down below. [Verse 2] Footsteps lost on empty streets, rhythms sync to heartbeats, whispers carried by the breeze, dancing through the autumn leaves. "; var response = await client.Models.GenerateContentAsync( model: "lyria-3.5", contents: prompt ); ``` {% /tab %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [ {"text": "Create a dreamy indie pop song with the following lyrics: ..."} ] }] }' ``` {% /tab %} {% /tabs %} {% video src="https://storage.googleapis.com/generativeai-downloads/songs/Neon-Echoes_Lyrics.webm" type="video/webm" /%} ## Control timing and structure {% id="timing" %} You can specify exactly what happens at specific moments in the song using timestamps. This is useful for controlling when instruments enter, when lyrics are delivered, and how the song progresses: {% tabs %} {% tab label="Python" %} ```python prompt = """ [0:00 - 0:10] Intro: Begin with a soft lo-fi beat and muffled vinyl crackle. [0:10 - 0:30] Verse 1: Add a warm Fender Rhodes piano melody and gentle vocals singing about a rainy morning. [0:30 - 0:50] Chorus: Full band with upbeat drums and soaring synth leads. The lyrics are hopeful and uplifting. [0:50 - 1:00] Outro: Fade out with the piano melody alone. """ response = client.models.generate_content( model="lyria-3.5", contents=prompt, ) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import { GoogleGenAI } from '@google/genai'; import * as fs from 'node:fs'; const ai = new GoogleGenAI({}); const prompt = ` [0:00 - 0:10] Intro: Begin with a soft lo-fi beat and muffled vinyl crackle. [0:10 - 0:30] Verse 1: Add a warm Fender Rhodes piano melody and gentle vocals singing about a rainy morning. [0:30 - 0:50] Chorus: Full band with upbeat drums and soaring synth leads. The lyrics are hopeful and uplifting. [0:50 - 1:00] Outro: Fade out with the piano melody alone. `; const response = await ai.models.generateContent({ model: 'lyria-3-clip-preview', contents: prompt, }); for (const candidate of response.candidates ?? []) { for (const part of candidate.content?.parts ?? []) { if (part.text) { console.log(part.text); } else if (part.inlineData?.data) { const buffer = Buffer.from(part.inlineData.data, 'base64'); fs.writeFileSync('clip.mp3', buffer); console.log('Audio saved to clip.mp3'); } } } ``` {% /tab %} {% tab label="Go" %} ```go prompt := ` [0:00 - 0:10] Intro: Begin with a soft lo-fi beat and muffled vinyl crackle. [0:10 - 0:30] Verse 1: Add a warm Fender Rhodes piano melody and gentle vocals singing about a rainy morning. [0:30 - 0:50] Chorus: Full band with upbeat drums and soaring synth leads. The lyrics are hopeful and uplifting. [0:50 - 1:00] Outro: Fade out with the piano melody alone. ` result, err := client.Models.GenerateContent( ctx, "lyria-3.5", genai.Text(prompt), nil, ) ``` {% /tab %} {% tab label="Java" %} ```java import com.google.genai.Client; import com.google.genai.types.GenerateContentResponse; import com.google.genai.types.Part; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class GenerateMusicClip { public static void main(String[] args) throws IOException { try (Client client = new Client()) { GenerateContentResponse response = client.models.generateContent( "lyria-3-clip-preview", "Create a 30-second cheerful acoustic folk song with " + "guitar and harmonica."); for (Part part : response.parts()) { if (part.text().isPresent()) { System.out.println(part.text().get()); } else if (part.inlineData().isPresent()) { var blob = part.inlineData().get(); if (blob.data().isPresent()) { Files.write(Paths.get("clip.mp3"), blob.data().get()); System.out.println("Audio saved to clip.mp3"); } } } } } } ``` {% /tab %} {% tab label="C#" %} ```csharp var prompt = @" [0:00 - 0:10] Intro: Begin with a soft lo-fi beat and muffled vinyl crackle. [0:10 - 0:30] Verse 1: Add a warm Fender Rhodes piano melody and gentle vocals singing about a rainy morning. [0:30 - 0:50] Chorus: Full band with upbeat drums and soaring synth leads. The lyrics are hopeful and uplifting. [0:50 - 1:00] Outro: Fade out with the piano melody alone. "; var response = await client.Models.GenerateContentAsync( model: "lyria-3.5", contents: prompt ); ``` {% /tab %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3-clip-preview:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [ {"text": "Create a 30-second cheerful acoustic folk song with guitar and harmonica."} ] }] }' ``` {% /tab %} {% /tabs %} {% audio src="https://storage.googleapis.com/generativeai-downloads/songs/Blue%20Sky%20Breaking.wav" type="audio/wav" /%} ## Generate instrumental tracks {% id="instrumental" %} For background music, game soundtracks, or any use case where vocals are not required, you can prompt the model to produce instrumental-only tracks: {% tabs %} {% tab label="Python" %} ```python response = client.models.generate_content( model="lyria-3-clip-preview", contents="A bright chiptune melody in C Major, retro 8-bit " "video game style. Instrumental only, no vocals.", ) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript const response = await ai.models.generateContent({ model: "lyria-3-clip-preview", contents: "A bright chiptune melody in C Major, retro 8-bit " + "video game style. Instrumental only, no vocals.", }); ``` {% /tab %} {% tab label="Go" %} ```go result, err := client.Models.GenerateContent( ctx, "lyria-3-clip-preview", genai.Text("A bright chiptune melody in C Major, retro 8-bit " + "video game style. Instrumental only, no vocals."), nil, ) ``` {% /tab %} {% tab label="Java" %} ```java GenerateContentResponse response = client.models.generateContent( "lyria-3-clip-preview", "A bright chiptune melody in C Major, retro 8-bit " + "video game style. Instrumental only, no vocals."); ``` {% /tab %} {% tab label="C#" %} ```csharp var response = await client.Models.GenerateContentAsync( model: "lyria-3-clip-preview", contents: "A bright chiptune melody in C Major, retro 8-bit " + "video game style. Instrumental only, no vocals." ); ``` {% /tab %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3-clip-preview:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [ {"text": "Create a 30-second cheerful acoustic folk song with guitar and harmonica."} ] }] }' ``` {% /tab %} {% /tabs %} {% audio src="https://storage.googleapis.com/generativeai-downloads/songs/Pulse%20Wave%20Hero.wav" type="audio/wav" /%} Tip: For [best results](/docs/music-generation#prompt-guide), include "Instrumental only, no vocals" explicitly in your prompt. ## Generate music in different languages {% id="languages" %} Lyria 3.5 generates lyrics in the language of your prompt. To generate a song with French lyrics, write your prompt in French. The model adapts its vocal style and pronunciation to match the language. {% tabs %} {% tab label="Python" %} ```python response = client.models.generate_content( model="lyria-3.5", contents="Crée une chanson pop romantique en français sur un " "coucher de soleil à Paris. Utilise du piano et de " "la guitare acoustique.", ) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript const response = await ai.models.generateContent({ model: "lyria-3.5", contents: "Crée une chanson pop romantique en français sur un " + "coucher de soleil à Paris. Utilise du piano et de " + "la guitare acoustique.", }); ``` {% /tab %} {% tab label="Go" %} ```go result, err := client.Models.GenerateContent( ctx, "lyria-3.5", genai.Text("Crée une chanson pop romantique en français sur un " + "coucher de soleil à Paris. Utilise du piano et de " + "la guitare acoustique."), nil, ) ``` {% /tab %} {% tab label="Java" %} ```java GenerateContentResponse response = client.models.generateContent( "lyria-3.5", "Crée une chanson pop romantique en français sur un " + "coucher de soleil à Paris. Utilise du piano et de " + "la guitare acoustique."); ``` {% /tab %} {% tab label="C#" %} ```csharp using System.Threading.Tasks; using Google.GenAI; using Google.GenAI.Types; using System.IO; public class GenerateMusicClip { public static async Task main() { var client = new Client(); var response = await client.Models.GenerateContentAsync( model: "lyria-3-clip-preview", contents: "Create a 30-second cheerful acoustic folk song with guitar and harmonica." ); foreach (var part in response.Candidates[0].Content.Parts) { if (part.Text != null) { Console.WriteLine(part.Text); } else if (part.InlineData != null) { await File.WriteAllBytesAsync("clip.mp3", part.InlineData.Data); Console.WriteLine("Audio saved to clip.mp3"); } } } } ``` {% /tab %} {% tab label="REST" %} ```bash curl -s -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [ {"text": "Crée une chanson pop romantique en français sur un coucher de soleil à Paris. Utilise du piano et de la guitare acoustique."} ] }] }' ``` {% /tab %} {% /tabs %} {% audio src="https://storage.googleapis.com/generativeai-downloads/songs/Paris%20en%20Or.wav" type="audio/wav" /%} ## Model intelligence {% id="intelligence" %} Lyria 3.5 analyzes your prompt process where the model reasons through musical structure (intro, verse, chorus, bridge, etc.) based on your prompt. This happens before the audio is generated and ensures structural coherence and musicality. Important: While Lyria 3.5 uses a prompt rewriter internally to interpret natural language instructions, it does **not** expose intermediate "thought" blocks or thought signatures to the user. ## Interactions API {% id="interactions-api" %} You can use Lyria 3.5 models with the [Interactions API](/docs/interactions-overview); a unified interface for interacting with Gemini models and agents. It simplifies state management and long-running tasks for complex multimodal use cases. {% tabs %} {% tab label="Python" %} ```python from google import genai import base64 client = genai.Client() interaction = client.interactions.create( model="lyria-3-clip-preview", input="Create a 30-second cheerful acoustic folk song with guitar and harmonica.", ) for step in interaction.steps: if step.type == "model_output": for content_block in step.content: if content_block.type == "text": print(content_block.text) elif content_block.type == "audio": with open("clip.mp3", "wb") as f: f.write(base64.b64decode(content_block.data)) print("Audio saved to clip.mp3") ``` {% /tab %} {% tab label="JavaScript" %} ```javascript import { GoogleGenAI } from '@google/genai'; import * as fs from 'node:fs'; const ai = new GoogleGenAI({}); const interaction = await ai.interactions.create({ model: 'lyria-3-clip-preview', input: 'Create a 30-second cheerful acoustic folk song with guitar and harmonica.', }); for (const step of interaction.steps ?? []) { if (step.type === 'model_output') { for (const contentBlock of step.content ?? []) { if (contentBlock.type === 'text') { console.log(contentBlock.text); } else if (contentBlock.type === 'audio') { const buffer = Buffer.from(contentBlock.data, 'base64'); fs.writeFileSync('clip.mp3', buffer); console.log('Audio saved to clip.mp3'); } } } } ``` {% /tab %} {% tab label="REST" %} ```shell curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Api-Revision: 2026-05-20" \ -H "Content-Type: application/json" \ -d '{ "model": "lyria-3-clip-preview", "input": "Create a 30-second cheerful acoustic folk song with guitar and harmonica." }' ``` {% /tab %} {% /tabs %} {% audio src="https://storage.googleapis.com/generativeai-downloads/songs/Silver%20City%20Soul.wav" type="audio/wav" /%} ## Prompting guide {% id="prompt-guide" %} To learn how to craft effective prompts for music genres, instruments, song structure, custom lyrics, and vocal delivery styles, see the [Lyria prompt guide](/docs/lyria-prompt-guide). ## Best practices {% id="best-practices" %} * **Iterate with Clip first.** Use the faster `lyria-3-clip-preview` model to experiment with prompts before committing to a full-length generation with `lyria-3.5`. * **Be specific.** Vague prompts produce generic results. Mention instruments, BPM, key, mood, and structure for the best output. * **Match your language.** Prompt in the language you want the lyrics in. * **Use section tags.** `[Verse]`, `[Chorus]`, `[Bridge]` tags give the model clear structure to follow. * **Separate lyrics from instructions.** When providing custom lyrics, clearly separate them from your musical direction instructions. ## Limitations {% id="limitations" %} * **Safety**: All prompts are checked by safety filters. Prompts that trigger the filters will be blocked. This includes prompts that request specific artist voices or the generation of copyrighted lyrics. * **Watermarking**: All generated audio includes a [SynthID audio watermark](https://deepmind.google/technologies/synthid/) for identification. This watermark is imperceptible to the human ear and does not affect the listening experience. * **Multi-turn editing**: Music generation is a single-turn process. Iterative editing or refining a generated clip through multiple prompts is not supported in the current version of Lyria 3.5. * **Length**: The Clip model always generates 30-second clips. The Pro model generates songs that last a couple of minutes; exact duration can be influenced through your prompt. * **Determinism**: Results may vary between calls, even with the same prompt. ## What's next {% id="next-steps" %} * Check [pricing](/docs/pricing) for Lyria 3.5 models, * Try [real-time, streaming music generation](/docs/realtime-music-generation) with Lyria RealTime, * Generate multi-speaker conversations with the [TTS models](/docs/speech-generation), * Discover how to generate [images](/docs/image-generation) or [videos](/docs/video), * Find out how Gemini can [understand audio files](/docs/audio), * Have a real-time conversation with Gemini using the [Live API](/docs/live-api).