I'm developing an Android app using Kotlin and Jetpack Compose. I'm trying to integrate Gemini AI to analyze images uploaded by the user using the Firebase Vertex AI SDK (com.google.firebase:firebase-vertexai-ktx).
Despite using the latest stable library versions managed by the Firebase BoM (32.7.4) and the corresponding Vertex AI library, I consistently get a 404 Not Found error when calling generateContent. The error message always indicates that the model (tried gemini-pro-vision, gemini-1.5-flash-latest, gemini-1.5-pro-latest) is not found for the v1beta API version.
Error Log: com.google.firebase.vertexai.type.ServerException: [404 Not Found] { "error": { "code": 404, "message": "models/[Google Gemini] is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.", "status": "NOT_FOUND" } }
What I've Tried:
- Firebase BoM: Ensured
firebase-vertexai-ktxversion is managed by Firebase BoM (32.7.4). - Different Models: Tested with
gemini-pro-vision,gemini-1.5-flash-latest, andgemini-1.5-pro-latest. The error persists. - API Key (Alternative Method): Also tried using the standalone Google AI Android SDK (
com.google.ai.client.generativeai:generativeai:0.7.0) with a dedicated API key. Got the exact same404 v1betaerror. - API Key Verification: Verified the API key is correct for the project (
smart-ai-outfit-app), has no restrictions, and the "Generative Language API" (generativelanguage.googleapis.com) is enabled. - New Project Test: Created a brand new Google Cloud Project, enabled the API, generated a new key, and tested with
curl. Still received the404 Not Founderror forv1andv1betaendpoints (generativelanguage.googleapis.com) for models likegemini-proandgemini-1.0-pro. gcloudTest:gcloud ai models list --region=us-central1 --project=[PROJECT_ID]returns "Listed 0 items" for both old and new projects, even after enabling the Vertex AI API (aiplatform.googleapis.com).- API Explorer Test: Calls via Google API Explorer (using the new project's API key) also result in the same
404 Not Founderror. - Cache Clearing: Performed extensive cache clearing (Android Studio Invalidate/Restart, deleting
.gradle/caches, deleting project.gradleandbuildfolders, system restart).
Gradle Setup:
libs.versions.toml:[versions] # ... other versions ... firebaseBom = "32.7.4" kotlin = "2.0.21" # Or your Kotlin version # ... [libraries] # ... other libraries ... firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" } firebase-vertexai = { group = "com.google.firebase", name = "firebase-vertexai-ktx" } # Managed by BoM # ... [plugins] # ... other plugins ...app/build.gradle.kts:dependencies { implementation(platform(libs.firebase.bom)) implementation(libs.firebase.vertexai) // ... other Firebase and Android dependencies ... }settings.gradle.kts: Repositoriesgoogle()andmavenCentral()are declared correctly.
Question:
Why does the SDK (both Firebase Vertex AI and Google AI) seem to be stuck using the v1beta endpoint, leading to a 404 Not Found error, even with the latest libraries and verified project/API setup? Is there any other configuration or potential account-level issue that could be causing this persistent error across different projects?