Skip to content

fix: update Gemini base URL to the correct endpoint #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarcoMuellner
Copy link

This pull request updates the base URL for the Gemini provider across multiple files to ensure consistency and accuracy. The changes replace the outdated URL with the correct one.

Updates to Gemini provider configuration:

Should fix #880

Copy link

github-actions bot commented May 9, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@MarcoMuellner
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request May 9, 2025
@MarcoMuellner
Copy link
Author

This doesn't a 100% fix the full issue - If you run this you won't get the 400 anymore, but rather you will get this:

OpenAI:DEBUG:request https://generativelanguage.googleapis.com/v1beta/models/models { method: 'get', path: '/models' } {
  accept: 'application/json',
  'content-type': 'application/json',
  'user-agent': 'OpenAI/JS 4.95.1',
  'x-stainless-lang': 'js',
  'x-stainless-package-version': '4.95.1',
  'x-stainless-os': 'MacOS',
  'x-stainless-arch': 'arm64',
  'x-stainless-runtime': 'node',
  'x-stainless-runtime-version': 'v22.14.0',
  authorization: 'REDACTED',
  'x-stainless-retry-count': '0',
  'x-stainless-timeout': '600'
}
OpenAI:DEBUG:response (error; (error; no more retries left)) 401 https://generativelanguage.googleapis.com/v1beta/models/models {
  'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
  'content-encoding': 'gzip',
  'content-type': 'application/json; charset=UTF-8',
  date: 'Fri, 09 May 2025 18:42:44 GMT',
  server: 'scaffolding on HTTPServer2',
  'server-timing': 'gfet4t7; dur=27',
  'transfer-encoding': 'chunked',
  vary: 'Origin, X-Origin, Referer',
  'www-authenticate': 'Bearer realm="https://accounts.google.com/", error="invalid_token"',
  'x-content-type-options': 'nosniff',
  'x-frame-options': 'SAMEORIGIN',
  'x-xss-protection': '0'
} 

I assume the reason behind this is because gemini expects the key to be passed differently. As far as i understand it right now in the code, it assumes the provider works the same way as the OpenAI API does - and the curl script clearly tells a different story from google:

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
  "contents": [{
    "parts":[{"text": "Explain how AI works"}]
    }]
   }'

I assume this would probably require a deeper take on the whole thing? Not sure if this ever worked correctly?

@MarcoMuellner
Copy link
Author

Probably also touches #731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant