Skip to content

[firebase_vertexai]: generateContent doesn't work when file_data is included #13530

@MaggieThomann

Description

@MaggieThomann

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Other

Which platforms are affected?

Web

Description

I generateContent via chat.sendMessage in a Flutter application on web with the following payload:

{
    "model": "models/gemini-1.5-flash",
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Hi what's this an image of?"
                },
                {
                    "file_data": {
                        "file_uri": "gs://vertex-a-i-gemini-dynam-1zmn51.appspot.com/o/users/TwiK8CKJ9cPZRoa4qqON9XFwSBV2/uploads/1729590224013000.jpg",
                        "mime_type": "image/jpeg"
                    }
                }
            ]
        }
    ],
    "tools": [],
    "systemInstruction": {
        "role": "system",
        "parts": [
            {
                "text": "You are an expert assistant specialized in helping expatriates living in Germany. Your role is to provide guidance and support on a wide range of expat-related topics, ensuring your responses are clear and actionable. Follow the JSON response format outlined below:\n\nResponse Format:\n\n{\n  \"type\": \"string\", // Type of the response. Possible values: \"TextMessage\", \"DetailCard\", \"EmailCard\", \"SingleActionCard\", \"BannerCard\".\n  \"data\": {\n    \"TextMessage\": {\n      \"text\": \"string\" // A plain text response, up to 10 sentences long.\n    },\n    \"DetailCard\": {\n      \"title\": \"string\", // Title of the card.\n      \"subtitle\": \"string\", // Subtitle of the card.\n      \"description\": \"string\" // A one-sentence high-level summary.\n    },\n    \"EmailCard\": {\n      \"toEmail\": \"string\", // Placeholder for recipient's email address.\n      \"subject\": \"string\", // Subject of the email.\n      \"text\": \"string\" // Email body text.\n    },\n    \"SingleActionCard\": {\n      \"title\": \"string\", // Title of the action.\n      \"description\": \"string\", // Description of the action.\n      \"actionTitle\": \"string\" // Label for the action (e.g., 'Submit Form').\n    },\n    \"BannerCard\": {\n      \"description\": \"string\", // A brief tip or suggestion.\n      \"label\": \"string\" // Maximum 4 words summarizing the tip.\n    }\n  }\n}\n\nGuidelines:\n1. Documentation and Forms: If a user requests specific documents or forms, provide detailed instructions or templates when available.\n2. Legal or Professional Advice: If the user's query requires advice beyond general knowledge (e.g., legal, medical), suggest that they consult a qualified professional.\n3. Response Format: Choose the appropriate response format based on the user's query and ensure the information is actionable and easy to understand."
            }
        ]
    }
}

And it returned:

{
  "error": {
    "code": 400,
    "message": "Service agents are being provisioned (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents). Service agents are needed to read the Cloud Storage file provided. So please try again in a few minutes.",
    "status": "FAILED_PRECONDITION"
  }
}

I tried again the following day and it returned the same problem. The API works if I don't include the file_data parameter.

Reproducing the issue

  1. Create a new Firebase project and enable Vertex AI for Gemini SDK
  2. Upload an image to a cloud storage bucket in that project and set it for public access manually
  3. Try to call the generateContent endpoint with the uri of the file being included in one of the user parts.

Firebase Core version

2.31.0

Flutter Version

3.22.2

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionThis issue needs maintainer attention.platform: webIssues / PRs which are specifically for web.plugin: vertexailabel issues for vertexai plugintype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions