Repository navigation
Conversation
…reFoundation#202) GeminiProvider just passed self.api_key straight to AsyncOpenAI without checking it was actually set. if GEMINI_API_KEY is missing, AsyncOpenAI quietly falls back to looking for OPENAI_API_KEY instead, so you get an error mentioning OpenAI even though you're trying to set up Gemini. that's almost certainly what happened in AcademySoftwareFoundation#202, no repro steps but "400 error when using gemini" lines up exactly with this. repro'd it locally: with no key set at all, the error you get back is "The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable" - which is useless if you set GEMINI_API_KEY and it just didn't make it into the container's env. CustomProvider already has a workaround for this same openai-sdk quirk (falls back to a dummy key since ollama doesn't need one). did the same idea here but raise a clear GEMINI_API_KEY-specific error instead, since gemini's api actually requires a real key unlike local/custom providers. added a test for the missing-key case. Signed-off-by: luka <158089407+lukalul@users.noreply.github.com>
lukalul
force-pushed
the
fix-gemini-missing-api-key-error
branch
from
September 22, 2026 21:38
232ca2d to
6291731
Compare
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GeminiProvider just passed self.api_key straight to AsyncOpenAI without checking it was actually set. if GEMINI_API_KEY is missing, AsyncOpenAI quietly falls back to looking for OPENAI_API_KEY instead, so you get an error mentioning OpenAI even though you're trying to set up Gemini. that's almost certainly what happened in #202, no repro steps but "400 error when using gemini" lines up exactly with this.
repro'd it locally: with no key set at all, the error you get back is "The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable" - useless if you did set GEMINI_API_KEY and it just didn't make it into the container's env.
CustomProvider already has a workaround for this same openai-sdk quirk (falls back to a dummy key since ollama doesn't need one). did the same idea here but raise a clear GEMINI_API_KEY-specific error instead, since gemini's api actually requires a real key unlike local/custom providers.
added a test for the missing-key case.
closes #202