Music Generation with Google Lyria 3

VerifiedCaution

Generate 30-second music clips or full 2-3 minute songs using Google Lyria 3 via the Gemini API. Free, control genre, BPM, instruments, mood via text prompts.

Sby Skills Guide Bot
ContentIntermediate
207/24/2026
Claude Code
#music-generation#google-lyria#gemini-api#audio#creativity

Recommended for

Our review

Generates music using Google Lyria 3 via the Gemini API for free. It can produce 30-second clips or full 2-3 minute songs from text prompts with control over genre, BPM, instruments, and mood.

Strengths

  • Free to use with a Gemini API key
  • Fine-grained control over genre, tempo, instruments, and mood
  • Outputs studio-quality MP3 files
  • Two separate models for clips and full-length songs

Limitations

  • Requires setup (API key and SDK installation)
  • Rate limits on the free tier
  • Full-length song quality can be inconsistent
When to use it

When you need to quickly generate original music for personal projects, prototypes, or creative content without musical composition skills.

When not to use it

For professional music production requiring granular control over each track or advanced mixing.

Security analysis

Caution
Quality score82/100

The skill uses bash to run a Python script with the user prompt stored in an environment variable via `PROMPT='$ARGUMENTS'`. If the prompt contains a single quote, it breaks out of the string and can inject shell commands. The note suggests escaping or using Write tool, but does not enforce safety. Since the user controls the input, risk is low if used carefully, but the vulnerability exists.

Findings
  • Potential command injection via unsanitized single quotes in prompt when passed to PROMPT environment variable in shell, allowing arbitrary command execution if input contains single quote and command substitution.

Examples

Lo-fi hip hop clip
Generate a 30-second lo-fi hip hop clip at 85 BPM with a Rhodes piano, soft vinyl crackle, and simple kick-snare drums, instrumental only, chill and nostalgic mood.
Synthwave song
Create a 2-minute synthwave song at 120 BPM in D minor with analog synthesizers, arpeggiated bass, and a retro drum machine. Energetic and neon-lit vibe, no vocals.
Acoustic folk song
Write a 3-minute acoustic folk song in G major with acoustic guitar, light percussion, and soft male vocals. Melancholic and introspective, with a verse-chorus structure.

name: make-music description: Generate music using Google Lyria 3 (FREE with Gemini API key). 30-second clips or full 2-3 minute songs from text prompts. Genre, BPM, instruments, mood - all controlled via prompt. argument-hint: <prompt describing the music you want> allowed-tools: Bash, Read, Write

Music Generation with Google Lyria 3 (FREE)

Generate 30-second music clips or full 2-3 minute songs using Google's Lyria 3 model via the Gemini API. Free tier — no cost.

Setup

  1. Get a free Gemini API key from Google AI Studio
  2. Set it as an environment variable:
    export GEMINI_API_KEY="your-key-here"
    
  3. Install the Google GenAI SDK:
    pip install google-genai
    

API Details

  • Model (clips): lyria-3-clip-preview — 30-second clips
  • Model (full songs): lyria-3-pro-preview — 2-3 minute complete songs
  • Output: MP3, 48kHz stereo, SynthID watermarked
  • Cost: FREE on Gemini free tier (rate limits apply)

Prompt Tips

Control everything through the text prompt:

  • Genre: "lo-fi hip hop", "synthwave", "jazz", "EDM", "acoustic folk"
  • BPM: "85 BPM", "120 BPM", "140 BPM"
  • Key: "C minor", "G major", "D minor pentatonic"
  • Instruments: "Rhodes piano", "TR-808 drums", "acoustic guitar", "analog synths"
  • Mood: "chill", "energetic", "melancholic", "triumphant", "dreamy"
  • Structure: [Intro], [Verse], [Chorus], [Bridge], [Outro]
  • Vocals: say "instrumental only" or "no vocals" to skip vocals
  • Timestamps: [0:00 - 0:10] Soft piano intro [0:10 - 0:25] Drums kick in

Usage

Run this inline Python script to generate music. The prompt is passed via the PROMPT env var and the Python body is a single-quoted heredoc — so the user's text can't break out of the Python string or inject code.

PROMPT='$ARGUMENTS' python3 - <<'PYEOF'
import os, time
from google import genai
from google.genai import types

key = os.environ.get('GEMINI_API_KEY')
if not key:
    print('ERROR: Set GEMINI_API_KEY environment variable first')
    print('Get a free key at: https://aistudio.google.com/apikey')
    exit(1)

client = genai.Client(api_key=key)
prompt = os.environ.get('PROMPT', '')
out_dir = os.path.join(os.path.expanduser('~'), '.claude-music-gen')
os.makedirs(out_dir, exist_ok=True)

response = client.models.generate_content(
    model='lyria-3-clip-preview',
    contents=prompt,
    config=types.GenerateContentConfig(response_modalities=['AUDIO', 'TEXT']),
)

ts = int(time.time())
for part in response.candidates[0].content.parts:
    if part.text:
        print(f'INFO: {part.text[:200]}')
    if part.inline_data:
        out = os.path.join(out_dir, f'music_{ts}.mp3')
        with open(out, 'wb') as f:
            f.write(part.inline_data.data)
        print(f'MUSIC: {out} ({len(part.inline_data.data) / 1024:.0f} KB)')
PYEOF

Full-Length Songs

For full 2-3 minute songs with verses/choruses, change the model to lyria-3-pro-preview:

PROMPT='$ARGUMENTS' python3 - <<'PYEOF'
import os, time
from google import genai
from google.genai import types

key = os.environ.get('GEMINI_API_KEY')
if not key:
    print('ERROR: Set GEMINI_API_KEY environment variable first')
    exit(1)

client = genai.Client(api_key=key)
prompt = os.environ.get('PROMPT', '')
out_dir = os.path.join(os.path.expanduser('~'), '.claude-music-gen')
os.makedirs(out_dir, exist_ok=True)

response = client.models.generate_content(
    model='lyria-3-pro-preview',
    contents=prompt,
    config=types.GenerateContentConfig(response_modalities=['AUDIO', 'TEXT']),
)

ts = int(time.time())
for part in response.candidates[0].content.parts:
    if part.text:
        print(f'INFO: {part.text[:200]}')
    if part.inline_data:
        out = os.path.join(out_dir, f'song_{ts}.mp3')
        with open(out, 'wb') as f:
            f.write(part.inline_data.data)
        print(f'SONG: {out} ({len(part.inline_data.data) / 1024:.0f} KB)')
PYEOF

Note: If your prompt contains a single quote ('), quote-escape it or use the Write tool to drop the prompt into a temp file first, then read that file in Python. The single-quoted heredoc protects the Python body but can't protect the outer PROMPT='...' assignment.

Rate Limits

  • Free tier has rate limits (be reasonable — add 30s between calls if generating multiple)
  • Clip model: always 30 seconds
  • Pro model: 2-3 minutes, full songs

Limitations

  • Non-deterministic (same prompt = different output each time)
  • Safety filters block copyrighted content or specific artist voice requests
  • Single-turn only (can't iteratively edit a track)

Requirements

  • Python 3.10+
  • google-genai SDK (pip install google-genai)
  • Free Gemini API key from Google AI Studio
Related skills