Skip to content

[codex] fix(gemini): pass custom http options to sdk - #12014

Open
yzlu0917 wants to merge 1 commit into
continuedev:mainfrom
yzlu0917:codex/issue-12008-gemini-custom-headers
Open

[codex] fix(gemini): pass custom http options to sdk#12014
yzlu0917 wants to merge 1 commit into
continuedev:mainfrom
yzlu0917:codex/issue-12008-gemini-custom-headers

Conversation

@yzlu0917

@yzlu0917 yzlu0917 commented Apr 3, 2026

Copy link
Copy Markdown

Summary

  • pass requestOptions.headers and requestOptions.timeout into the GoogleGenAI SDK via httpOptions
  • forward custom Gemini apiBase values into the SDK so chat/stream requests use the same endpoint override as embed requests
  • add adapter tests covering custom headers, custom base URL forwarding, and the default no-httpOptions path

Why

Continue's Gemini adapter already honored custom request options for the manual embed() path, but chat and streaming requests were created through GoogleGenAI without any of the configured requestOptions.headers or custom apiBase. That meant API gateways expecting custom auth headers like x-api-key could work for one path and silently fail for the main chat path.

This change keeps the SDK-based Gemini implementation, but makes its HTTP configuration consistent with the rest of the adapter.

Validation

  • ran npm test -- src/test/gemini-adapter.vitest.ts src/test/main.test.ts in packages/openai-adapters

Closes #12008


Summary by cubic

Fixes the Gemini adapter to pass custom headers, timeouts, and a custom apiBase to the @google/genai SDK for chat and streaming. Also standardizes OpenRouter defaults by exporting and applying OPENROUTER_HEADERS. Addresses #12008.

  • Bug Fixes
    • Gemini: Build httpOptions from requestOptions.headers and requestOptions.timeout, pass to GoogleGenAI, and forward apiBase (clears apiVersion) so chat/stream use the same endpoint as embeds. Added tests for headers/base URL forwarding and omitting httpOptions by default.
    • OpenRouter: Export OPENROUTER_HEADERS from @continuedev/openai-adapters and merge them into the core OpenRouter client’s requestOptions.headers. Rename X-Title to X-OpenRouter-Title and add X-OpenRouter-Categories.

Written for commit 97ab659. Summary will update on new commits.

@yzlu0917
yzlu0917 requested a review from a team as a code owner April 3, 2026 05:54
@yzlu0917
yzlu0917 requested review from sestinj and removed request for a team April 3, 2026 05:54
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 3, 2026

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

@yzlu0917
yzlu0917 force-pushed the codex/issue-12008-gemini-custom-headers branch from daca94d to 97ab659 Compare April 9, 2026 11:25
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provider gemini does not pass custom headers to gemini API

1 participant