{
"candidates": [
{
"content": {
"parts": [
{
"text": "Here is an upbeat folk song featuring guitar and harmonica.",
"inlineData": {
"mimeType": "audio/mpeg",
"data": "SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4..."
}
}
],
"role": "model"
},
"finishReason": "STOP",
"safetyRatings": [
{
"category": "<string>",
"probability": "<string>"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 15,
"candidatesTokenCount": 200,
"totalTokenCount": 215
}
}{
"error": {
"message": "Invalid request parameters",
"type": "http_error",
"code": 400,
"status": "INVALID_ARGUMENT"
}
}{
"error": {
"message": "Invalid API Key",
"type": "authentication_error",
"code": 401,
"status": "UNAUTHENTICATED"
}
}{
"error": {
"message": "Invalid request parameters",
"type": "http_error",
"code": 400,
"status": "INVALID_ARGUMENT"
}
}{
"error": {
"message": "Access denied",
"type": "permission_error",
"code": 403,
"status": "PERMISSION_DENIED"
}
}{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"code": 429,
"status": "RESOURCE_EXHAUSTED"
}
}{
"error": {
"message": "Internal server error",
"type": "server_error",
"code": 500,
"status": "UNKNOWN"
}
}Gemini Format - Music Generation
- Uses the Gemini native format generateContent endpoint to generate music via the Lyria 3 model
- Enable audio output by including
AUDIOingenerationConfig.responseModalities; ifTEXTis also included, the response will additionally return text descriptions (lyrics/structure) - Supports text prompts and image input (up to 10 images); images are used to inspire visually-driven music creation
- Duration, structure (verse/chorus/bridge), style, etc. are primarily controlled via text prompts
lyria-3-clip-preview: generates fixed 30-second clips, returns MP3 by default (audio/mpeg)lyria-3-pro-preview: generates full songs; you can requestaudio/mpegoraudio/wavviaresponseMimeType, but the actual output format should be determined by theinlineData.mimeTypein the response- For SSE streaming output, use
/v1beta/models/{model}:streamGenerateContent?alt=sse - Music generation is a single-turn process; multi-turn iterative editing is not supported
{
"candidates": [
{
"content": {
"parts": [
{
"text": "Here is an upbeat folk song featuring guitar and harmonica.",
"inlineData": {
"mimeType": "audio/mpeg",
"data": "SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4..."
}
}
],
"role": "model"
},
"finishReason": "STOP",
"safetyRatings": [
{
"category": "<string>",
"probability": "<string>"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 15,
"candidatesTokenCount": 200,
"totalTokenCount": 215
}
}{
"error": {
"message": "Invalid request parameters",
"type": "http_error",
"code": 400,
"status": "INVALID_ARGUMENT"
}
}{
"error": {
"message": "Invalid API Key",
"type": "authentication_error",
"code": 401,
"status": "UNAUTHENTICATED"
}
}{
"error": {
"message": "Invalid request parameters",
"type": "http_error",
"code": 400,
"status": "INVALID_ARGUMENT"
}
}{
"error": {
"message": "Access denied",
"type": "permission_error",
"code": 403,
"status": "PERMISSION_DENIED"
}
}{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"code": 429,
"status": "RESOURCE_EXHAUSTED"
}
}{
"error": {
"message": "Internal server error",
"type": "server_error",
"code": 500,
"status": "UNKNOWN"
}
}Authorizations
All endpoints require Bearer Token authentication
Add the following to your request headers:
Authorization: Bearer YOUR_API_KEY
Path Parameters
Model name. lyria-3-clip-preview generates 30-second clips (default MP3 / audio/mpeg). lyria-3-pro-preview generates full songs; you can request audio/mpeg or audio/wav, but the actual output format should be determined by the returned inlineData.mimeType
lyria-3-clip-preview, lyria-3-pro-preview "lyria-3-clip-preview"
Body
Content list. Music generation is a single-turn process; multi-turn iterative editing is not supported
Show child attributes
Show child attributes
Generation config; responseModalities must include AUDIO for music generation requests
Show child attributes
Show child attributes
System instruction. Lyria 3 model support for this field is not confirmed by official documentation; it may not take effect
Show child attributes
Show child attributes
Content safety filter settings
Show child attributes
Show child attributes