|
| 1 | +import type { ModelInfo } from "../model.js" |
| 2 | + |
| 3 | +/** |
| 4 | + * OpenAI Codex Provider |
| 5 | + * |
| 6 | + * This provider uses OAuth authentication via ChatGPT Plus/Pro subscription |
| 7 | + * instead of direct API keys. Requests are routed to the Codex backend at |
| 8 | + * https://chatgpt.com/backend-api/codex/responses |
| 9 | + * |
| 10 | + * Key differences from openai-native: |
| 11 | + * - Uses OAuth Bearer tokens instead of API keys |
| 12 | + * - Subscription-based pricing (no per-token costs) |
| 13 | + * - Limited model subset available |
| 14 | + * - Custom routing to Codex backend |
| 15 | + */ |
| 16 | + |
| 17 | +export type OpenAiCodexModelId = keyof typeof openAiCodexModels |
| 18 | + |
| 19 | +export const openAiCodexDefaultModelId: OpenAiCodexModelId = "gpt-5.2-codex" |
| 20 | + |
| 21 | +/** |
| 22 | + * Models available through the Codex OAuth flow. |
| 23 | + * These models are accessible to ChatGPT Plus/Pro subscribers. |
| 24 | + * Costs are 0 as they are covered by the subscription. |
| 25 | + */ |
| 26 | +export const openAiCodexModels = { |
| 27 | + "gpt-5.1-codex-max": { |
| 28 | + maxTokens: 128000, |
| 29 | + contextWindow: 400000, |
| 30 | + supportsNativeTools: true, |
| 31 | + defaultToolProtocol: "native", |
| 32 | + includedTools: ["apply_patch"], |
| 33 | + excludedTools: ["apply_diff", "write_to_file"], |
| 34 | + supportsImages: true, |
| 35 | + supportsPromptCache: true, |
| 36 | + supportsReasoningEffort: ["low", "medium", "high", "xhigh"], |
| 37 | + reasoningEffort: "xhigh", |
| 38 | + // Subscription-based: no per-token costs |
| 39 | + inputPrice: 0, |
| 40 | + outputPrice: 0, |
| 41 | + supportsTemperature: false, |
| 42 | + description: "GPT-5.1 Codex Max: Maximum capability coding model via ChatGPT subscription", |
| 43 | + }, |
| 44 | + "gpt-5.2-codex": { |
| 45 | + maxTokens: 128000, |
| 46 | + contextWindow: 400000, |
| 47 | + supportsNativeTools: true, |
| 48 | + defaultToolProtocol: "native", |
| 49 | + includedTools: ["apply_patch"], |
| 50 | + excludedTools: ["apply_diff", "write_to_file"], |
| 51 | + supportsImages: true, |
| 52 | + supportsPromptCache: true, |
| 53 | + supportsReasoningEffort: ["low", "medium", "high", "xhigh"], |
| 54 | + reasoningEffort: "medium", |
| 55 | + inputPrice: 0, |
| 56 | + outputPrice: 0, |
| 57 | + supportsTemperature: false, |
| 58 | + description: "GPT-5.2 Codex: OpenAI's flagship coding model via ChatGPT subscription", |
| 59 | + }, |
| 60 | + "gpt-5.1-codex-mini": { |
| 61 | + maxTokens: 128000, |
| 62 | + contextWindow: 400000, |
| 63 | + supportsNativeTools: true, |
| 64 | + defaultToolProtocol: "native", |
| 65 | + includedTools: ["apply_patch"], |
| 66 | + excludedTools: ["apply_diff", "write_to_file"], |
| 67 | + supportsImages: true, |
| 68 | + supportsPromptCache: true, |
| 69 | + supportsReasoningEffort: ["low", "medium", "high"], |
| 70 | + reasoningEffort: "medium", |
| 71 | + inputPrice: 0, |
| 72 | + outputPrice: 0, |
| 73 | + supportsTemperature: false, |
| 74 | + description: "GPT-5.1 Codex Mini: Faster version for coding tasks via ChatGPT subscription", |
| 75 | + }, |
| 76 | + "gpt-5.2": { |
| 77 | + maxTokens: 128000, |
| 78 | + contextWindow: 400000, |
| 79 | + supportsNativeTools: true, |
| 80 | + defaultToolProtocol: "native", |
| 81 | + includedTools: ["apply_patch"], |
| 82 | + excludedTools: ["apply_diff", "write_to_file"], |
| 83 | + supportsImages: true, |
| 84 | + supportsPromptCache: true, |
| 85 | + supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh"], |
| 86 | + reasoningEffort: "medium", |
| 87 | + inputPrice: 0, |
| 88 | + outputPrice: 0, |
| 89 | + supportsTemperature: false, |
| 90 | + description: "GPT-5.2: Latest GPT model via ChatGPT subscription", |
| 91 | + }, |
| 92 | +} as const satisfies Record<string, ModelInfo> |
0 commit comments