Skip to content

fix(gemini): route Gemini through OpenAI-compatible endpoint for OpenShell - #2440

Merged
bmahabirbu merged 2 commits into
openkaiden:mainfrom
bmahabirbu:fix-gemini
Jul 13, 2026
Merged

bmahabirbu merged 2 commits into
openkaiden:mainfrom
bmahabirbu:fix-gemini

Conversation

@bmahabirbu

@bmahabirbu bmahabirbu commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Register Gemini connections with OpenShell as openai provider type since OpenShell has no native gemini provider, using Google's OpenAI-compatible endpoint (generativelanguage.googleapis.com/v1beta/openai/)
  • Add endpoint to the Gemini connection so the OpenCode agent generates a proper custom provider config block with @ai-sdk/openai-compatible
  • Inject default apiKey: '{env:OPENAI_API_KEY}' in OpenCode's custom provider options so the SDK can authenticate via the env var OpenShell injects
Screencast.From.2026-07-13.02-40-34.mp4

Fixes: #2429

Test:

Add ur api key to the gemini extension so its saved in kaiden

select the opencode provider with gemini and create a sandbox see if u can interact with it

bmahabirbu and others added 2 commits July 12, 2026 20:16
OpenShell only supports protocol-family provider types (openai, anthropic,
...); it has no dedicated "gemini" type, so workspace creation failed with
"unsupported provider type or profile: gemini". Google publishes an
OpenAI-compatible endpoint that accepts a plain Bearer API key, so the
Gemini connection is now registered with OpenShell as an "openai" provider
pointed at that endpoint, mirroring the pattern used by openai-compatible.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Brian Mahabir <56164556+bmahabirbu@users.noreply.github.com>
The Gemini connection was missing an endpoint, so the OpenCode agent
generated a model string (gemini/...) with no provider config block —
OpenCode could not reach the model. Add the Google OpenAI-compat
endpoint to the connection so a custom provider entry is written.

Also inject a default apiKey option ({env:OPENAI_API_KEY}) for custom
providers in the OpenCode extension so @ai-sdk/openai-compatible can
authenticate via the env var that OpenShell injects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Brian <bmahabir@bu.edu>
@bmahabirbu
bmahabirbu requested a review from a team as a code owner July 13, 2026 06:39
@bmahabirbu
bmahabirbu requested review from MarsKubeX and fbricon and removed request for a team July 13, 2026 06:39
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Gemini now registers through an OpenAI-compatible endpoint and stores connection data under OPENAI_* configuration fields. OpenCode endpoint-based providers also receive an OPENAI_API_KEY environment reference.

Changes

OpenAI-compatible connection integration

Layer / File(s) Summary
Gemini connection contract
extensions/gemini/package.json, extensions/gemini/src/gemini.ts
Adds hidden OpenAI-compatible configuration fields, defines the provider type and endpoint, and updates connection registration metadata.
Gemini connection lifecycle
extensions/gemini/src/gemini.ts, extensions/gemini/src/gemini.spec.ts
Writes and clears _type, OPENAI_API_KEY, and OPENAI_BASE_URL during connection lifecycle operations, with updated tests.
OpenCode endpoint wiring
extensions/opencode/src/extension.ts, extensions/opencode/src/extension.spec.ts
Adds {env:OPENAI_API_KEY} to endpoint-based provider options and updates the expectation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: fbricon, marskubex

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: routing Gemini through an OpenAI-compatible endpoint for OpenShell.
Description check ✅ Passed The description matches the changeset and explains the OpenShell/OpenAI-compatible routing and API key handling.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@MarsKubeX MarsKubeX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

Creating a workspace using a gemini-backed model fails

2 participants