Skip to content

[Bug]: Gemini API integration fails with new Google AI Studio key format (⁠AQ...⁠) #1253

Open

Description

@vladik-png

Description

The app currently fails to authenticate or use the Gemini API when provided with newly generated Google API keys. Google has recently changed their API key format for AI Studio/Google Cloud. New keys now start with ⁠**”AQ...⁠”** instead of the legacy ⁠**”AIzaSy...⁠.”** The app seems to be expecting or validating only the old “⁠AIzaSy...”⁠ format, resulting in a failure to connect to the custom server (⁠generativelanguage.googleapis.com⁠).

Steps to reproduce

  1. Go to Google AI Studio and generate a new API key (it will start with ⁠AQ...⁠).
  2. Open OpenNutriTracker and go to AI Support settings.
  3. Select "Your own server" (Custom provider).
  4. Enter the base URL: ⁠https://generativelanguage.googleapis.com/v1beta/openai/⁠
  5. Paste the new ⁠**”AQ..”.**⁠ API key.
  6. Enter a valid model (e.g., ⁠models/gemini-3.1 pro⁠).
  7. Try to use the AI photo recognition feature.
  8. See error (connection fails or unauthorized).

Expected behaviour

The app should successfully authenticate with the Gemini API using the new “ **”⁠AQ...”**⁠ key format, as these are now the default and only keys provided by Google to new users.

Actual behaviour

It appears the issue might be in how the app handles or passes the API key in the header for the Gemini endpoint, or possibly a local regex validation that rejects keys not starting with ⁠AIza⁠. Updating the authentication handling to support the new format would restore free Gemini API functionality for new users.

Platform

iOS

OS version

IOS 26.6.1

App version

2.2.0

Install source

Apple App Store

Feature area

Other

Screenshots / recordings

Image

Logs or stack trace

Additional context

No response

Checklist

  • I have searched existing issues and this is not a duplicate
  • I am reporting a bug in OpenNutriTracker, not a third-party food database entry error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlog:mediumMedium priority — moderate UX gap or contained bugbugSomething isn't working

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions