0

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-ktx version is managed by Firebase BoM (32.7.4).
  • Different Models: Tested with gemini-pro-vision, gemini-1.5-flash-latest, and gemini-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 same 404 v1beta error.
  • 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 the 404 Not Found error for v1 and v1beta endpoints (generativelanguage.googleapis.com) for models like gemini-pro and gemini-1.0-pro.
  • gcloud Test: 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 Found error.
  • Cache Clearing: Performed extensive cache clearing (Android Studio Invalidate/Restart, deleting .gradle/caches, deleting project .gradle and build folders, 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: Repositories google() and mavenCentral() 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?


2 Answers 2

2

It's not the v1beta endpoint issue, you are using a retired Gemini model (see the retired models), retired on 9/24/2025, for both Gemini 1.5 (pro and flash). That's the reason of getting 404 NOT FOUND error (in either Vertex AI or AI Studio). You should migrate to Gemini 2.0/2.5 Flash and later instead following the latest Gemini migration guide.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the suggestion! I've updated my code to use a newer model available in the Firebase Vertex AI SDK, specifically gemini-2.5-flash-preview-09-2025. However, I'm still encountering a 404 Not Found error, often mentioning the v1beta endpoint even with the latest SDK (firebase-vertexai-ktx managed by BoM 32.7.4). Here's the initialization in my ViewModel: ```kotlin private val generativeModel = Firebase.vertexAI.generativeModel( modelName = "gemini-2.5-flash-preview-09-2025" )
can you try with gemini-flash-latest (which points to gemini-2.5-flash-preview-09-2025) or gemini-2.5-flash?
2

The firebase-vertexai-ktx library that you're trying to use was deprecated in favor of the new firebase-ai library (there's even a migration guide). You should use that library instead:

  1. Go to Firebase AI Logic in the Firebase console and click on "Get started".

  2. Update your code:

libs.versions.toml

[versions]
# ... other versions ...
firebaseBom = "34.4.0"  # <-- latest version of the Firebase BoM

# ...

[libraries]
# ... other libraries ...
firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
firebase-ai = { group = "com.google.firebase", name = "firebase-ai" } # Managed by BoM
# ...

[plugins]
# ... other plugins ...

app/build.gradle.kts

dependencies {
    implementation(platform(libs.firebase.bom))
    implementation(libs.firebase.ai)
    // ... other Firebase and Android dependencies ...
}

In your Kotlin code:

val model = Firebase.ai(
  backend = GenerativeBackend.googleAI() // <- or GenerativeBackend.vertexAI()
).generativeModel(
  modelName = "gemini-2.5-flash" // Or whatever model fits your use case
)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.