I am using Gemini Dev API and trying to get a simple response to an audio file that I am uploading to GCS
Code is
from google import genai
from google.genai import types as google_genai_types # Alias for its types module
def aistudio(GEMINI_API_KEY, filename):
client = genai.Client(
api_key=GEMINI_API_KEY
)
destination_blob_name = f"audio_uploads/{os.path.basename(filename)}"
gcs_file_uri = upload_to_gcs(GCS_BUCKET_NAME, filename, destination_blob_name)
audio_file_part = google_genai_types.Part.from_uri(file_uri=gcs_file_uri, mime_type=audio_mime_type)
response = client.models.generate_content_stream(
model=MODEL_ID,
contents=["Analyze this audio", audio_file_part],
)
for chunk in response:
if hasattr(chunk, 'text') and chunk.text:
print(chunk.text, end="")
I keep geting API error: 400 INVALID_ARGUMENT. {‘error’: {‘code’: 400, ‘message’: 'Unsupported file uri: gs://…
Bucket is public, can view it from any device anywhere, API key has no restrictions.