Skip to content

feat: add ChatGPT OAuth web search support#11

Merged
emilsvennesson merged 7 commits intomainfrom
feat/chatgpt-oauth-websearch
Apr 10, 2026
Merged

feat: add ChatGPT OAuth web search support#11
emilsvennesson merged 7 commits intomainfrom
feat/chatgpt-oauth-websearch

Conversation

@emilsvennesson
Copy link
Copy Markdown
Owner

Summary

  • add ChatGPT OAuth-backed web search support for OpenAI models by cherry-picking Dylan Liew's implementation (be4a3e3231ccb926daf0308e46836f3081b62847) with attribution
  • prefer ChatGPT OAuth routing over OpenAI API-key routing for OpenAI-model web searches to avoid consuming API credits when OAuth is available
  • simplify docs to a single ChatGPT/OpenAI provider entry and clarify OAuth-vs-API-key behavior

Details

  • new ChatGPT provider adapter and auth resolution:
    • src/providers/chatgpt/auth.ts
    • src/providers/chatgpt/constants.ts
    • src/providers/chatgpt/index.ts
  • provider dispatch/types wiring updated for chatgpt provider type
  • resolution behavior updates:
    • reuse OpenAI model override tags (websearch: \"auto\" / \"always\") for ChatGPT OAuth mode
    • set resolution priority to prefer ChatGPT OAuth before OpenAI API key for OpenAI-family routing
  • docs/error messaging updates for ChatGPT OAuth support and ChatGPT/OpenAI wording

Credit

Verification

  • bun run check
  • bun run build

Dylan-Liew and others added 4 commits April 10, 2026 22:03
Route OpenAI-model web searches through ChatGPT OAuth when available so they do not consume API credits. Reuse OpenAI model websearch overrides for OAuth mode and clarify docs and error text for OpenAI API key vs ChatGPT OAuth behavior.
Document OpenAI API key and ChatGPT OAuth support in one provider row with Responses API wording only. Keep OAuth-preferred behavior explicit without implementation-specific backend details.
Use ChatGPT/OpenAI wording in supported providers table while keeping the single-row OpenAI Responses API description.
Copilot AI review requested due to automatic review settings April 10, 2026 20:20
Replace ambiguous 'if both are available' phrasing and explicitly state that OpenAI-family web search uses ChatGPT OAuth whenever it is available.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds ChatGPT OAuth-backed web search support for OpenAI-family models by introducing a new chatgpt provider adapter, resolving OAuth credentials from OpenCode auth state, and prioritizing ChatGPT OAuth routing over OpenAI API-key routing when available.

Changes:

  • Introduce a new chatgpt provider adapter that calls ChatGPT’s /responses endpoint via SSE streaming.
  • Add ChatGPT OAuth credential resolution (auth.jsonopenai oauth entry) and inject it into provider resolution with higher priority than OpenAI API keys.
  • Update types, provider dispatch/priority wiring, and docs/error messaging to reflect “ChatGPT/OpenAI” behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types.ts Adds chatgpt provider type and supports accountId in credentials/config.
src/providers/registry.ts Updates provider resolution priority to prefer chatgpt before openai.
src/providers/index.ts Wires in the chatgpt provider adapter for dispatch/error formatting.
src/providers/chatgpt/index.ts Implements ChatGPT web search execution via SSE parsing and structured response building.
src/providers/chatgpt/constants.ts Defines ChatGPT base URL and user agent constants.
src/providers/chatgpt/auth.ts Resolves ChatGPT OAuth credentials from OpenCode auth store (auth.json).
src/index.ts Injects ChatGPT OAuth resolution and prefers it for OpenAI-family routing.
src/config.ts Extends resolution types/error copy to mention ChatGPT OAuth (and adds scan state entries).
README.md Consolidates docs into “ChatGPT/OpenAI” and clarifies OAuth-vs-API-key preference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 35 to 40
interface ScanState {
anthropic: ScanResult;
chatgpt: ScanResult;
copilot: ScanResult;
openai: ScanResult;
}
Remove unreachable chatgpt scan state, gate OAuth routing when OpenAI uses a custom baseURL, and cap ChatGPT response output tokens. Update README notes to reflect custom baseURL behavior for ChatGPT/OpenAI routing.
Align routing gate with OpenCode provider behavior by checking whether OpenAI baseURL was explicitly configured, rather than assuming a default endpoint string. This avoids brittle assumptions about SDK defaults while preserving custom endpoint intent.
@emilsvennesson emilsvennesson merged commit 79986b0 into main Apr 10, 2026
1 check passed
@emilsvennesson emilsvennesson deleted the feat/chatgpt-oauth-websearch branch April 10, 2026 20:45
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.

3 participants