Support `generateContent` (non-streaming) wire\_api for Gemini models in Codex
What feature would you like to see?
I'd like Codex to support Gemini models using the generateContent method (non-streaming) by allowing a new value in the wire_api field — e.g., generateContent.
Currently, Codex supports only "chat" and "responses" as wire_api variants. However, some Gemini models — such as gemini-2.5-pro — are available via the REST API but do not support :streamGenerateContent, which Codex seems to use when wire_api = "chat".
Allowing a wire_api = "generateContent" option would let Codex users use newer Gemini models that are otherwise fully available via the REST API.
Are you interested in implementing this feature?
I'd be happy to test and help verify this feature once it's implemented, but I'd prefer to wait for guidance from the Codex team before contributing code.
Additional information
This feature request directly addresses the root cause of issues reported by the community regarding Gemini provider integration, such as in Issue #519 ("long thinking / blocking with gemini provider") and Issue #880 ("OpenAI rejected the request... Status: 400").
An attempt to fix this was made in Pull Request #881, which corrected the base URL. However, as noted in the PR's comments, this was not a complete solution because Codex still attempted to use an incorrect API endpoint (/models) and likely the wrong authentication method. The PR was ultimately closed without being merged.
My proposal for a new wire_api = "generateContent" option would solve this cleanly by instructing Codex to use the correct non-streaming endpoint.
Here’s a real-world example:
curl -s -X POST \
-H "Content-Type: application/json" \
-H "X-Goog-Api-Key: $GEMINI_API_KEY" \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent" \
-d '{
"contents": [{"parts": [{"text": "Explain how AI works"}]}]
}'
This call works as expected. However, attempting to use gemini-2.5-pro in Codex results in a 404 error due to the likely use of :streamGenerateContent, which the model doesn’t support.
Being able to specify wire_api = "generateContent" would solve this and unlock newer models for Codex users.
Thanks!
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗