Skip to content

fix: support Google Gemini /models lfix: support Google Gemini models listing via x-goog-api-keyisting via x-goog-api-key header - #55

Closed
simplvis wants to merge 1 commit into
lidge-jun:mainfrom
simplvis:fix/google-models-listing
Closed

simplvis wants to merge 1 commit into
lidge-jun:mainfrom
simplvis:fix/google-models-listing

Conversation

@simplvis

@simplvis simplvis commented Jul 2, 2026

Copy link
Copy Markdown

Google Generative Language API uses x-goog-api-key header instead of Authorization: Bearer, and its /models response returns { models: [{ name: "models/gemini-..." }] } rather than OpenAI's { data: [{ id: "gemini-..." }] } format.
This fix handles both issues so that the Google provider's models appear in the opencodex dashboard and Codex model picker.

- buildModelsRequest: use x-goog-api-key header and /v1/models URL for Google adapter
- fetchProviderModels: normalize Gemini API response format (models array with   name field) to OpenAI-compatible shape (data array with id field)
lidge-jun added a commit that referenced this pull request Jul 2, 2026
…beta

The Google provider's models never appeared in the dashboard or Codex model
picker: /models was probed with Authorization: Bearer, which the Generative
Language API rejects, and its { models: [...] } response shape was never
parsed. buildModelsRequest now targets /v1beta/models?pageSize=1000 (v1 misses
preview models; pageSize caps at 1000 so no pageToken loop) with the
documented x-goog-api-key header, and the catalog maps the Google shape
(strip the models/ prefix, keep generateContent-capable models, use
inputTokenLimit as the context hint). API-key validation on `ocx login`
switches to the same probe.

The branch keys on effectiveGoogleMode(), which backfills googleMode from the
provider registry — a saved key-login config omits it — so google-vertex and
google-antigravity keep their existing request paths (regression-tested).

Supersedes PR #55 (same intent; that patch didn't compile and leaked the
header change into vertex/antigravity).

Co-Authored-By: Claude Fable 5 <[email protected]>
@lidge-jun

Copy link
Copy Markdown
Owner

Thanks @simplvis — good catch on both the header and the /v1beta endpoint. We shipped the same header/endpoint fix independently on our stabilization branch (84cef2f, which also covers the ADC/OAuth x-goog-user-project path and routes through the new googleFetch retry wrapper from 6cb379b, so this PR would now conflict with / regress those). Your nextPageToken pagination handling was missing from our version though — we're porting that part with credit (Co-authored-by) in the next release. Closing this PR as superseded; the pagination improvement lands via the stabilization branch. Thanks again for the contribution! 🙏

@lidge-jun lidge-jun closed this Jul 2, 2026
@lidge-jun

Copy link
Copy Markdown
Owner

Correction to my note above: after re-checking the actual diff, this PR contains no pagination handling — that part of my earlier comment was wrong, apologies for the confusion. The accurate summary: 84cef2f on the stabilization branch fully supersedes this PR — same x-goog-api-key + /v1beta intent, plus the { models: [...] } response-shape parsing, pageSize=1000 (the API's cap, so no pageToken loop is needed), generateContent filtering with inputTokenLimit context hints, tests, and scoping via googleMode so vertex/antigravity request paths are unaffected (this patch as written also had a template-literal syntax error in buildModelsRequest). Nothing further to port. Thanks again for identifying the root cause — the fix ships in the next release.

agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…beta

The Google provider's models never appeared in the dashboard or Codex model
picker: /models was probed with Authorization: Bearer, which the Generative
Language API rejects, and its { models: [...] } response shape was never
parsed. buildModelsRequest now targets /v1beta/models?pageSize=1000 (v1 misses
preview models; pageSize caps at 1000 so no pageToken loop) with the
documented x-goog-api-key header, and the catalog maps the Google shape
(strip the models/ prefix, keep generateContent-capable models, use
inputTokenLimit as the context hint). API-key validation on `ocx login`
switches to the same probe.

The branch keys on effectiveGoogleMode(), which backfills googleMode from the
provider registry — a saved key-login config omits it — so google-vertex and
google-antigravity keep their existing request paths (regression-tested).

Supersedes PR lidge-jun#55 (same intent; that patch didn't compile and leaked the
header change into vertex/antigravity).

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants