DEV Community

q2408808
q2408808

Posted on

Lyria 3 Pro API Tutorial: Generate AI Music with Google DeepMind's Latest Model (Python & JS)

Google DeepMind just dropped Lyria 3 Pro — and here's how to start generating AI music via API in under 5 minutes.

On March 25, 2026, Google DeepMind announced Lyria 3 Pro, the most advanced AI music generation model yet. It can create full 3-minute tracks with professional-grade structural awareness — intros, verses, choruses, bridges — all from a single text prompt.

What Is Lyria 3 Pro?

Lyria 3 Pro is Google DeepMind's premier AI music generation model, released March 25, 2026:

  • 3-minute full tracks — vs. 30-second clips from Lyria 3 Clip
  • Structural composition awareness — understands intros, verses, choruses, and bridges
  • Realistic vocals with expressive nuance
  • Global language & genre support
  • SynthID watermarking — every track is transparently marked as AI-generated
  • Available on: Vertex AI, Gemini API, Google AI Studio, Google Vids, ProducerAI

Source: Google DeepMind Blog | Fetched: 2026-03-28

Why Use NexaAPI?

NexaAPI gives you one unified key to access 50+ AI models — including audio and music generation — at up to 5× cheaper than official pricing.

  • ✅ One API key for 50+ models
  • ✅ OpenAI-compatible SDK
  • ✅ Pay-per-use, no monthly commitment
  • ✅ Sub-200ms median latency

Note: Lyria 3 Pro integration is coming soon on NexaAPI. Check nexa-api.com for the latest model catalog.

Python Code Example

# pip install nexaapi
from nexaapi import NexaAPI

client = NexaAPI(api_key='YOUR_API_KEY')

# Generate AI music with Lyria 3 Pro via NexaAPI
result = client.audio.generate(
    model='lyria-3-pro',
    prompt='An upbeat electronic pop track with piano melody and driving beat',
    duration=30
)

print(result.audio_url)
with open('my_track.mp3', 'wb') as f:
    f.write(result.audio_data)
Enter fullscreen mode Exit fullscreen mode

Get your free API key at https://nexa-api.com | Install: pip install nexaapiPyPI

JavaScript Code Example

// npm install nexaapi
import NexaAPI from 'nexaapi';

const client = new NexaAPI({ apiKey: 'YOUR_API_KEY' });

async function generateMusic() {
  const result = await client.audio.generate({
    model: 'lyria-3-pro',
    prompt: 'An upbeat electronic pop track with piano melody and driving beat',
    duration: 30
  });
  console.log(result.audioUrl);
}

generateMusic();
Enter fullscreen mode Exit fullscreen mode

Install via npm: https://npmjs.com/package/nexaapi

Pricing Comparison

Provider Price Setup
Google Vertex AI Variable GCP pricing GCP account + billing
Google AI Studio Paid API key Google paid tier
NexaAPI Up to 5× cheaper One key, instant

Get Started in 3 Steps

  1. Get your free API keyhttps://nexa-api.com
  2. Install the SDKpip install nexaapi or npm install nexaapi
  3. Start generating → Copy the code examples above and run

Resources

Top comments (0)