Repository Public
1The Gemini API offers two ways to generate music with Lyria:23- **Lyria 3.5 \& Lyria 3 Clip** : Non-streaming generation for 30-second clips or full-length songs with lyrics and vocals. See [Generate music with Lyria 3.5](https://ai.google.dev/gemini-api/docs/music-generation).4- **Lyria RealTime** : Real-time, interactive music streaming and live steering over WebSockets. See [Real-time music generation with Lyria RealTime](https://ai.google.dev/gemini-api/docs/realtime-music-generation).56Both models respond to descriptive text prompts, musical terminology, and structural directions. This guide covers how to write effective prompts for both batch generation and real-time steering.78## Prompt fundamentals910Your prompt can be a short phrase:1112 A folk song about cute cats avoiding puddles, female vocals, acoustic guitar, sound of rain1314Or a structured, detailed description:1516 A 1980s-style synth-pop track with a driving beat, shimmering synthesizers, and a catchy, anthemic chorus. The song should have a retro-futuristic feel with modern production polish. Upbeat tempo around 120 BPM, clear verse-chorus structure, and a memorable instrumental hook. The lyrics describe getting ready for a party.1718Both short and detailed prompts produce strong results. Use the following strategies to guide the model toward the exact sound you want.1920## Genre and style2122Lead your prompt with the primary genre. You can combine genres to create unique hybrids:2324- A fusion of metal and hip-hop25- Death metal combined with operatic vocals26- Classical chamber music with dark electronic drone elements27- Modern electronic dance music (EDM) mixed with Europop2829You can also specify a musical era or regional variant:3031- Early 1990s boom-bap hip-hop32- 1960s French yé-yé pop33- 1980s post-punk and new wave34- 2000s mainstream R\&B35- Berlin minimal techno or Bay Area hyphy3637### Genre keywords3839Use these recognized genre terms in your prompts for Lyria 3.5 and Lyria RealTime:4041- **Electronic \& Dance** : `Acid House, Breakbeat, Chillout, Chiptune, Deep House, Drum & Bass, Dubstep, EDM, Electro Swing, Glitch Hop, Hyperpop, Minimal Techno, Moombahton, Psytrance, Synthpop, Techno, Trance, Trip Hop, Vaporwave`42- **Hip-Hop \& R\&B** : `808 Hip Hop, Boom-Bap, Contemporary R&B, G-funk, Grime, Lo-Fi Hip Hop, Neo-Soul, New Jack Swing, Trap Beat`43- **Rock \& Alternative** : `Alternative Country, Blues Rock, Classic Rock, Funk Metal, Garage Rock, Indie Folk, Indie Pop, Post-Punk, 60s Psychedelic Rock, Shoegaze, Surf Rock`44- **Jazz, Soul \& Funk** : `Acid Jazz, Afrobeat, Bossa Nova, Disco Funk, Funk, Jazz Fusion, Latin Jazz`45- **Folk \& Traditional** : `Bengal Baul, Bhangra, Bluegrass, Celtic Folk, Cumbia, Indian Classical, Irish Folk, Merengue, Polka, Reggae, Reggaeton, Renaissance Music, Salsa`46- **Classical \& Acoustic** : `Baroque, Orchestral Score, Piano Ballad`4748## Instruments and textures4950Lyria selects appropriate instrumentation for the requested genre automatically. If you want specific instruments or unusual combinations, declare them explicitly:5152 A dance track with a driving beat, shimmering synthesizers, and a catchy, anthemic chorus. A saxophone solo enters during the bridge.5354Describe how instruments sound and interact to set mood and texture:5556- A distorted 303 bassline cutting through crisp, tight hi-hats57- Warm, analog synth pads swelling beneath a dry, intimate acoustic guitar58- A wall of sound built from multiple layers of fuzz guitar, with distant, reverb-soaked vocals5960### Instrument keywords6162- **Keyboards \& Synths** : `Buchla Synths, Clavichord, Dirty Synths, Harpsichord, Mellotron, Moog Oscillations, Ragtime Piano, Rhodes Piano, Smooth Pianos, Spacey Synths, Synth Pads`63- **Bass \& Drums** : `303 Acid Bass, 808 Hip Hop Beat, Boomy Bass, Conga Drums, Drumline, Funk Drums, Precision Bass, Tabla, TR-909 Drum Machine`64- **Guitars \& Strings** : `Banjo, Balalaika, Bouzouki, Cello, Charango, Dulcimer, Fiddle, Flamenco Guitar, Guitar, Harp, Koto, Lyre, Mandolin, Pipa, Shamisen, Shredding Guitar, Sitar, Slide Guitar, Viola Ensemble, Warm Acoustic Guitar`65- **Wind \& Brass** : `Alto Saxophone, Bagpipes, Bass Clarinet, Didgeridoo, Harmonica, Ocarina, Trumpet, Tuba, Woodwinds`66- **Percussion** : `Bongos, Djembe, Glockenspiel, Hang Drum, Kalimba, Maracas, Marimba, Mbira, Steel Drum, Vibraphone`6768## Song structure and timing6970For Lyria 3.5, define song progression using tags or arrows:7172- `[Intro] -> [Verse 1] -> [Chorus] -> [Verse 2] -> [Chorus] -> [Bridge] -> [Outro]`73- Start with a quiet piano intro, build into an energetic verse, pause for a moment of silence, then explode into the chorus.7475You can direct energy dynamics and transitions:7677- Build tension through the pre-chorus, then drop to silence before an explosive chorus78- Gradual crescendo throughout the song, adding one instrument per section79- A sudden stop after the bridge, followed by an a cappella chorus8081You can also prompt specific timing markers:8283- Build to a beat drop at 12 seconds84- Vocal sample repeats every 4 bars85- The chorus kicks in at 22 seconds8687## Lyrics and vocals8889Lyria 3.5 generates vocal tracks with lyrics by default. You can provide your own lyrics, ask the model to generate them, or request an instrumental track.9091### Using your own lyrics9293Include your lyrics directly in the prompt beneath a `Lyrics:` header. Tag each section to guide vocal delivery:9495 Lyrics:9697 [Intro]98 Ooooh, yeah99100 [Verse 1]101 Early morning rain on the window pane102 City lights wash away the pain103 Walking down this empty street again104105 [Chorus]106 We keep moving on (moving on)107 Until the morning light108 Everything will be alright109110Use parentheses for backing vocals, echoes, or ad-libs, like `(moving on)`.111112### Directing generated lyrics113114When asking Lyria 3.5 to write lyrics, outline the narrative, emotion, or key phrases:115116 The lyrics describe driving down the Pacific Coast Highway at sunset. The mood is nostalgic and reflective. Include an uplifting, anthemic chorus about second chances and starting over.117118For electronic and dance genres, request short repeating vocal hooks:119120 An upbeat dance-pop track with a repetitive, high-energy vocal hook: "Feel the rhythm all night long."121122### Vocal delivery and singer profiles123124Specify gender, vocal range, and timbre for precise delivery:125126- **Female Soprano**: Clear, crystalline timbre with an agile, soaring delivery. Bright tone capable of airy, breathy textures.127- **Female Alto**: Rich, warm, and husky lower range. Smoky timbre with a soulful, resonant chest voice.128- **Male Tenor**: Bright, piercing, and energetic. Youthful timbre with high belting power that cuts through dense mixes.129- **Male Baritone**: Deep, velvet-smooth chest voice with a warm, soothing, crooning delivery.130- **Weathered Rocker**: Raspy, gritty timbre reminiscent of 1990s alternative rock. Raw emotional intensity with strained upper notes.131132### Non-lyrical vocal effects133134You can also prompt for spoken dialogue, vocal chops, and sampling effects:135136- A vintage radio broadcast voice introduces the song before the beat kicks in137- A spoken voice whispers right before the drop, followed by high-energy synths138- Chopped, pitch-shifted vocal samples looping as an instrumental rhythm element139140## Musical parameters141142Refine your prompt with standard musical properties:143144- **Tempo (BPM)** : Set the tempo directly (e.g. `120 BPM`, `slow tempo around 72 BPM`, `fast 160 BPM`).145- **Key and Scale** : Specify the root key and tonality (e.g. `in G major`, `in D minor`, `in C pentatonic`).146- **Mood and Atmosphere** : Use descriptive emotional adjectives: `Ambient, Bright, Chill, Dark, Dreamy, Emotional, Ethereal, Euphoric, Funky, Groovy, Melancholic, Nostalgic, Ominous, Psychedelic, Relaxed, Soulful, Triumphant, Upbeat, Whimsical`147148## Prompting Lyria RealTime149150Lyria RealTime uses **weighted prompts** rather than a single monolithic prompt string. This lets you blend multiple musical influences dynamically and steer music continuously over a WebSocket connection.151152### Weighted prompt structure153154Each weighted prompt consists of a descriptive text phrase and a floating-point weight:155156 prompts = [157 types.WeightedPrompt(text="minimal techno", weight=1.0),158 types.WeightedPrompt(text="deep sub bass", weight=0.6),159 types.WeightedPrompt(text="shimmering hi-hats", weight=0.4),160 ]161162### Real-time steering strategies163164- **Blending genres** : Blend distinct styles by assigning balanced weights:165 - `ambient synth pads (weight: 0.8)` + `lo-fi hip-hop drums (weight: 0.6)`166 - `flamenco guitar (weight: 0.7)` + `deep house groove (weight: 0.5)`167- **Dynamic transitions** : To transition the music smoothly, adjust prompt weights over time:168 1. Start with `chill jazz piano (weight: 1.0)`.169 2. Gradually add `electronic breakbeat (weight: 0.3)`.170 3. Increase `electronic breakbeat` to `0.8` while lowering `chill jazz piano` to `0.3`.171- **Layering elements** : Keep instrument tags and mood tags separate so you can adjust them independently:172 - Prompt 1: `bossa nova guitar (weight: 0.9)`173 - Prompt 2: `warm acoustic bass (weight: 0.7)`174 - Prompt 3: `subtle vinyl crackle (weight: 0.3)`175176## Example prompts177178### Lyria 3.5 examples179180- **Lo-Fi Study Beat** : `none181 A 30-second lofi hip hop beat with dusty vinyl crackle, mellow Rhodes piano chords, a relaxed boom-bap drum groove at 82 BPM, and a warm upright bassline. Instrumental only.`182- **Pop Anthem** : `none183 An upbeat, feel-good indie-pop song in G major at 122 BPM. Bright acoustic guitar strumming, driving kick drum, handclaps, and warm female vocal harmonies. The lyrics describe an unforgettable summer road trip with friends.`184- **Cinematic Cyberpunk** : `none185 Dark, cinematic cyberpunk synthwave at 110 BPM in D minor. Heavy distorted bass, ominous arpeggiated analog synthesizers, distant metallic percussion, and an ethereal female vocalise swelling during the climax.`186187### Lyria RealTime steering set188189 # Initial high-energy groove190 await session.set_weighted_prompts(191 prompts=[192 types.WeightedPrompt(text="techno groove", weight=1.0),193 types.WeightedPrompt(text="acid 303 bass", weight=0.8),194 ]195 )196197 # Transition to a melodic breakdown198 await session.set_weighted_prompts(199 prompts=[200 types.WeightedPrompt(text="ambient synth pads", weight=1.0),201 types.WeightedPrompt(text="subtle reverberant piano", weight=0.7),202 types.WeightedPrompt(text="techno groove", weight=0.2),203 ]204 )205206## What's next207208- [Generate music with Lyria 3.5](https://ai.google.dev/gemini-api/docs/music-generation): Generate full songs and 30-second clips using the Interactions API.209- [Real-time music generation with Lyria RealTime](https://ai.google.dev/gemini-api/docs/realtime-music-generation): Build real-time, interactive music streaming applications over WebSockets.