Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions packages/types/src/providers/openai-codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,29 @@ import type { ModelInfo } from "../model.js"

export type OpenAiCodexModelId = keyof typeof openAiCodexModels

export const openAiCodexDefaultModelId: OpenAiCodexModelId = "gpt-5.3-codex"
export const openAiCodexDefaultModelId: OpenAiCodexModelId = "gpt-5.4"

/**
* 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.4": {
maxTokens: 128000,
contextWindow: 1_050_000,
includedTools: ["apply_patch"],
excludedTools: ["apply_diff", "write_to_file"],
supportsImages: true,
supportsPromptCache: true,
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh"],
reasoningEffort: "none",
inputPrice: 0,
outputPrice: 0,
supportsVerbosity: true,
supportsTemperature: false,
description: "GPT-5.4: Most capable model with upfront planning and deep reasoning via ChatGPT subscription",
},
"gpt-5.1-codex-max": {
maxTokens: 128000,
contextWindow: 400000,
Expand Down Expand Up @@ -119,7 +134,7 @@ export const openAiCodexModels = {
excludedTools: ["apply_diff", "write_to_file"],
supportsImages: true,
supportsPromptCache: true,
supportsReasoningEffort: ["minimal", "low", "medium", "high"],
supportsReasoningEffort: ["none", "low", "medium", "high"],
reasoningEffort: "medium",
// Subscription-based: no per-token costs
inputPrice: 0,
Expand Down
41 changes: 28 additions & 13 deletions src/api/providers/__tests__/openai-codex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,42 @@
import { OpenAiCodexHandler } from "../openai-codex"

describe("OpenAiCodexHandler.getModel", () => {
it.each(["gpt-5.1", "gpt-5", "gpt-5.1-codex", "gpt-5-codex", "gpt-5-codex-mini", "gpt-5.3-codex-spark"])(
"should return specified model when a valid model id is provided: %s",
(apiModelId) => {
const handler = new OpenAiCodexHandler({ apiModelId })
const model = handler.getModel()

expect(model.id).toBe(apiModelId)
expect(model.info).toBeDefined()
// Default reasoning effort for GPT-5 family
expect(model.info.reasoningEffort).toBe("medium")
},
)
it.each([
"gpt-5.1",
"gpt-5",
"gpt-5.1-codex",
"gpt-5-codex",
"gpt-5-codex-mini",
"gpt-5.3-codex-spark",
])("should return specified model when a valid model id is provided: %s", (apiModelId) => {
const handler = new OpenAiCodexHandler({ apiModelId })
const model = handler.getModel()

expect(model.id).toBe(apiModelId)
expect(model.info).toBeDefined()
// Default reasoning effort for GPT-5 family
expect(model.info.reasoningEffort).toBe("medium")
})

it("should fall back to default model when an invalid model id is provided", () => {
const handler = new OpenAiCodexHandler({ apiModelId: "not-a-real-model" })
const model = handler.getModel()

expect(model.id).toBe("gpt-5.3-codex")
expect(model.id).toBe("gpt-5.4")
expect(model.info).toBeDefined()
})

it("should use GPT-5.4 with thinking/non-thinking reasoning effort levels", () => {
const handler = new OpenAiCodexHandler({ apiModelId: "gpt-5.4" })
const model = handler.getModel()

expect(model.id).toBe("gpt-5.4")
expect(model.info.contextWindow).toBe(1_050_000)
expect(model.info.supportsReasoningEffort).toContain("none")
expect(model.info.supportsReasoningEffort).toContain("xhigh")
expect(model.info.reasoningEffort).toBe("none")
})

it("should use Spark-specific limits and capabilities", () => {
const handler = new OpenAiCodexHandler({ apiModelId: "gpt-5.3-codex-spark" })
const model = handler.getModel()
Expand Down
Loading