Description
Issue Summary
After investigating issue #390 regarding the Google Gemini API integration with mycoder, I've identified potential causes for the error.
Findings
-
The current implementation in
mycoder
supports using the OpenAI provider with alternative APIs through thebaseUrl
configuration, as evidenced by thexai
provider which uses the OpenAIProvider. -
The error in issue Not Working with Google Gemini API #390 occurs when trying to use Google's Gemini API with the OpenAI-compatible endpoint:
export default {
provider: 'openai',
model: 'gemini-2.5-pro-exp-03-25',
baseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai',
logLevel: 'verbose',
githubMode: false,
headless: true
};
- The error message indicates a 400 status code (bad request) with no response body:
Error: Error calling OpenAI API: 400 status code (no body)
Potential Causes
-
Authentication Issues: The code is likely not passing the API key in the correct format for Google's API. Google Gemini API might require an API key to be passed differently than OpenAI.
-
Request Format Incompatibility: While Google advertises OpenAI compatibility, there might be subtle differences in the request format or required parameters.
-
Endpoint URL Structure: The endpoint URL might need to be structured differently, possibly requiring additional path components or query parameters.
Recommended Next Steps
-
Review Google's Gemini API documentation for their OpenAI-compatible endpoint to understand authentication requirements.
-
Add explicit support for Google Gemini in the provider registry, similar to how
xai
is implemented but with any Gemini-specific adjustments. -
Consider adding debug logging to capture the exact request being sent and any response headers to better diagnose the issue.
-
Create a test case specifically for the Google Gemini OpenAI-compatible API to verify the integration.
I'll continue investigating the specific requirements for Google's OpenAI-compatible API and provide further updates.