-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add OpenAI codex provider #5270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e075693
feat: add OpenAI Codex provider with OAuth subscription authenticatio…
hannesrudolph 6579c04
Update referers
kevinvandijk 3818dcb
Update types
kevinvandijk a200686
fix(openai-codex): reset invalid model selection (#10777)
hannesrudolph 79c8cb7
Add gpt codex models to useProviderModels hook
kevinvandijk ce427c1
Add missing translations
kevinvandijk 6839f7c
Add changeset
kevinvandijk da9d5e2
Use the same user agent as for our own backend
kevinvandijk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "kilo-code": minor | ||
| --- | ||
|
|
||
| Add support for OpenAI Codex subscriptions (thanks Roo) | ||
|
|
||
| - Fix: Reset invalid model selection when using OpenAI Codex provider (PR #10777 by @hannesrudolph) | ||
| - Add OpenAI - ChatGPT Plus/Pro Provider that gives subscription-based access to Codex models without per-token costs (PR #10736 by @hannesrudolph) | ||
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| import type { ModelInfo } from "../model.js" | ||
|
|
||
| /** | ||
| * OpenAI Codex Provider | ||
| * | ||
| * This provider uses OAuth authentication via ChatGPT Plus/Pro subscription | ||
| * instead of direct API keys. Requests are routed to the Codex backend at | ||
| * https://chatgpt.com/backend-api/codex/responses | ||
| * | ||
| * Key differences from openai-native: | ||
| * - Uses OAuth Bearer tokens instead of API keys | ||
| * - Subscription-based pricing (no per-token costs) | ||
| * - Limited model subset available | ||
| * - Custom routing to Codex backend | ||
| */ | ||
|
|
||
| export type OpenAiCodexModelId = keyof typeof openAiCodexModels | ||
|
|
||
| export const openAiCodexDefaultModelId: OpenAiCodexModelId = "gpt-5.2-codex" | ||
|
|
||
| /** | ||
| * Models available through the Codex OAuth flow. | ||
| * These models are accessible to ChatGPT Plus/Pro subscribers. | ||
| * Costs are 0 as they are covered by the subscription. | ||
| */ | ||
| export const openAiCodexModels = { | ||
| "gpt-5.1-codex-max": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["low", "medium", "high", "xhigh"], | ||
| reasoningEffort: "xhigh", | ||
| // Subscription-based: no per-token costs | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsTemperature: false, | ||
| description: "GPT-5.1 Codex Max: Maximum capability coding model via ChatGPT subscription", | ||
| }, | ||
| "gpt-5.1-codex": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["low", "medium", "high"], | ||
| reasoningEffort: "medium", | ||
| // Subscription-based: no per-token costs | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsTemperature: false, | ||
| description: "GPT-5.1 Codex: GPT-5.1 optimized for agentic coding via ChatGPT subscription", | ||
| }, | ||
| "gpt-5.2-codex": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["low", "medium", "high", "xhigh"], | ||
| reasoningEffort: "medium", | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsTemperature: false, | ||
| description: "GPT-5.2 Codex: OpenAI's flagship coding model via ChatGPT subscription", | ||
| }, | ||
| "gpt-5.1": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["none", "low", "medium", "high"], | ||
| reasoningEffort: "medium", | ||
| // Subscription-based: no per-token costs | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsVerbosity: true, | ||
| supportsTemperature: false, | ||
| description: "GPT-5.1: General GPT-5.1 model via ChatGPT subscription", | ||
| }, | ||
| "gpt-5": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["minimal", "low", "medium", "high"], | ||
| reasoningEffort: "medium", | ||
| // Subscription-based: no per-token costs | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsVerbosity: true, | ||
| supportsTemperature: false, | ||
| description: "GPT-5: General GPT-5 model via ChatGPT subscription", | ||
| }, | ||
| "gpt-5-codex": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["low", "medium", "high"], | ||
| reasoningEffort: "medium", | ||
| // Subscription-based: no per-token costs | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsTemperature: false, | ||
| description: "GPT-5 Codex: GPT-5 optimized for agentic coding via ChatGPT subscription", | ||
| }, | ||
| "gpt-5-codex-mini": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["low", "medium", "high"], | ||
| reasoningEffort: "medium", | ||
| // Subscription-based: no per-token costs | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsTemperature: false, | ||
| description: "GPT-5 Codex Mini: Faster coding model via ChatGPT subscription", | ||
| }, | ||
| "gpt-5.1-codex-mini": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["low", "medium", "high"], | ||
| reasoningEffort: "medium", | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsTemperature: false, | ||
| description: "GPT-5.1 Codex Mini: Faster version for coding tasks via ChatGPT subscription", | ||
| }, | ||
| "gpt-5.2": { | ||
| maxTokens: 128000, | ||
| contextWindow: 400000, | ||
| supportsNativeTools: true, | ||
| defaultToolProtocol: "native", | ||
| includedTools: ["apply_patch"], | ||
| excludedTools: ["apply_diff", "write_to_file"], | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh"], | ||
| reasoningEffort: "medium", | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| supportsTemperature: false, | ||
| description: "GPT-5.2: Latest GPT model via ChatGPT subscription", | ||
| }, | ||
| } as const satisfies Record<string, ModelInfo> |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these PR numbers dont make a lot of sense in our repo, should these be urls?