Skip to content

generate_content() returns 400 INVALID_ARGUMENT for Lyria models on Vertex AI; interactions.create() works as expected #2533

@zJvco

Description

@zJvco

Is this a client library issue or a product issue?

Client library issue (SDK) or possibly a Vertex AI endpoint issue. The official documentation states that generate_content() supports Lyria models, but the SDK/endpoint returns 400 INVALID_ARGUMENT via Vertex AI while client.interactions.create() works correctly for the same models.

ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}

Environment details

  • Programming language: Python
  • OS: Linux (Ubuntu / WSL2)
  • Language runtime version: Python 3.12
  • Package version: google-genai==2.7.0
  • Auth mode: Vertex AI with ADC (vertexai=True, project, location="global")

Steps to reproduce

  • Set up a Vertex AI project with ADC credentials and location="global" (required by Lyria, attempting other regions returns 500 InternalServerError: Lyria 3 only supports global Cardolan)
  • Install google-genai>=2.7.0
  • Call client.models.generate_content() with a Lyria model and response_modalities=["AUDIO"]

Minimal reproduction (failing):

from google import genai

client = genai.Client(vertexai=True, project="YOUR_PROJECT_ID", location="global")

response = client.models.generate_content(
    model="lyria-3-clip-preview",
    contents="A short upbeat lo-fi hip hop piece with piano.",
    config=genai.types.GenerateContentConfig(
        response_modalities=["AUDIO"],
    ),
)

Error received:

google.genai.errors.ClientError: 400 INVALID_ARGUMENT.
{'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}

The error is raised before any HTTP response is printed, suggesting SDK-level validation or an immediate rejection by the Vertex AI endpoint.

I also tested without any config at all:

response = client.models.generate_content(
    model="lyria-3-clip-preview",
    contents="A short upbeat lo-fi hip hop piece with piano.",
)
# Also returns 400 INVALID_ARGUMENT

Expected behavior

According to the official documentation, generate_content() should support Lyria models and return audio via response.parts[i].inline_data.

Actual behavior

400 INVALID_ARGUMENT is returned for any call to generate_content() with lyria-3-clip-preview or lyria-3-pro-preview via Vertex AI.

Workaround found

client.interactions.create() works correctly for the same models and credentials:

import base64
from google import genai

client = genai.Client(vertexai=True, project="YOUR_PROJECT_ID", location="global")

interaction = client.interactions.create(
    model="lyria-3-clip-preview",
    input="A short upbeat lo-fi hip hop piece with piano.",
)

if interaction.output_audio and interaction.output_audio.data:
    audio_bytes = base64.b64decode(interaction.output_audio.data)
    with open("output.mp3", "wb") as f:
        f.write(audio_bytes)
    print(f"Sucess: {len(audio_bytes)} bytes, mime={interaction.output_audio.mime_type}")

This produces a valid MP3 file. The inconsistency between generate_content() and interactions.create() for the same Lyria models suggests either a missing route in the Vertex AI endpoint for the generateContent method, or a validation mismatch in the SDK when Lyria models are used with GenerateContentConfig.

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions