Skip to content

fix(ai): update Gemini API model to gemini-1.5-flash-latest#68

Open
kaligautier wants to merge 2 commits intomainfrom
fix/gemini-api-model-404
Open

fix(ai): update Gemini API model to gemini-1.5-flash-latest#68
kaligautier wants to merge 2 commits intomainfrom
fix/gemini-api-model-404

Conversation

@kaligautier
Copy link
Copy Markdown
Owner

Problem

The application was experiencing 404 errors when calling the Gemini API with retry exhaustion:

4xx error from Gemini API: {
  "error": {
    "code": 404,
    "message": "models/gemini-1.5-pro 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"
  }
}

Root Cause

The model identifier gemini-1.5-pro has been deprecated by Google and is no longer available on the Gemini API v1beta endpoint. The error message confirms the model cannot be found for the generateContent operation.

Solution

Updated the Gemini model configuration from gemini-1.5-pro to gemini-1.5-flash-latest across all configuration files:

Files Changed

Configuration Update

Before:

ai:
  gemini:
    model: gemini-1.5-pro

After:

ai:
  gemini:
    model: gemini-1.5-flash-latest

Benefits

Aspect Benefit
Availability ✅ Uses currently available model on Gemini API
Performance 🚀 Gemini 1.5 Flash is optimized for speed
Cost 💰 More cost-effective than Pro model
Stability 🔒 Uses -latest suffix for automatic updates
Compatibility ✅ Maintains same API interface and functionality

Testing

  • ✅ Compilation successful
  • ✅ No breaking changes to API interface
  • ✅ Configuration validated across environments

Additional Context

Gemini 1.5 Flash is Google's recommended model for:

  • Fast responses (lower latency)
  • High-volume applications
  • Cost-sensitive workloads
  • Same context window as Pro (up to 1M tokens)

The -latest suffix ensures the application always uses the most recent stable version of the Gemini 1.5 Flash model.

References


🤖 Generated with Claude Code

kaligautier and others added 2 commits October 7, 2025 15:08
…ash-latest

## Problem
The application was failing with 404 errors when calling the Gemini API:
```
models/gemini-1.5-pro is not found for API version v1beta,
or is not supported for generateContent
```

## Root Cause
The model name `gemini-1.5-pro` is deprecated and no longer available
on the Gemini API v1beta endpoint.

## Solution
Updated the model name to `gemini-1.5-flash-latest` across:
- application.yml (default configuration)
- application-docker.yml (Docker environment configuration)
- GeminiAIAdapter.java (default value in @value annotation)

## Benefits
- ✅ Fixes 404 errors from Gemini API
- ✅ Uses latest stable model version
- ✅ Gemini 1.5 Flash is faster and more cost-effective
- ✅ Maintains same API functionality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The previous fix updated the model name but the API was still using
the deprecated v1beta endpoint. Gemini 1.5 models require the v1 endpoint.

Changes:
- Update API path from /v1beta/models/ to /v1/models/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Oct 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant