feat: add ChatGPT OAuth web search support#11
Merged
emilsvennesson merged 7 commits intomainfrom Apr 10, 2026
Merged
Conversation
(cherry picked from commit be4a3e3)
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.
Replace ambiguous 'if both are available' phrasing and explicitly state that OpenAI-family web search uses ChatGPT OAuth whenever it is available.
Contributor
There was a problem hiding this comment.
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
chatgptprovider adapter that calls ChatGPT’s/responsesendpoint via SSE streaming. - Add ChatGPT OAuth credential resolution (
auth.json→openaioauth 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
be4a3e3231ccb926daf0308e46836f3081b62847) with attributionChatGPT/OpenAIprovider entry and clarify OAuth-vs-API-key behaviorDetails
src/providers/chatgpt/auth.tssrc/providers/chatgpt/constants.tssrc/providers/chatgpt/index.tschatgptprovider typewebsearch: \"auto\"/\"always\") for ChatGPT OAuth modeChatGPT/OpenAIwordingCredit
Verification
bun run checkbun run build