Open History to see the last commit
1import type { ModelReasoning } from '@tanstack/ai'
2import type { ModelReasoningCapability } from '@tanstack/ai/adapter-internals'
3
4// Reasoning shapes: the levels a model has for `chat({ reasoning })`, and
5// the provider value to send for each. Each model points at one of them.
6const EFFORT_LOW_TO_HIGH = {
7 levels: { low: 'low', medium: 'medium', high: 'high' },
8 budget: false,
9} as const
10const EFFORT_LOW_TO_XHIGH = {
11 levels: { low: 'low', medium: 'medium', high: 'high', xhigh: 'xhigh' },
12 budget: false,
13} as const
14const EFFORT_NONE_LOW_TO_HIGH = {
15 levels: { off: 'none', low: 'low', medium: 'medium', high: 'high' },
16 budget: false,
17} as const
18const EFFORT_NONE_LOW_TO_XHIGH = {
19 levels: {
20 off: 'none',
21 low: 'low',
22 medium: 'medium',
23 high: 'high',
24 xhigh: 'xhigh',
25 },
26 budget: false,
27} as const
28/**
29 * Models known to work with Codex. The harness accepts any OpenAI model id
30 * its backend supports, so this list exists for autocomplete — any string is
31 * accepted via the `(string & {})` escape hatch in {@link CodexModel}.
32 */
33export const CODEX_MODELS = [
34 'gpt-5.3-codex',
35 'gpt-5.2-codex',
36 'gpt-5.1-codex',
37 'gpt-5.1-codex-mini',
38 'gpt-5.1',
39] as const
40
41export type KnownCodexModel = (typeof CODEX_MODELS)[number]
42
43/** Any model id accepted by Codex; known ids get autocomplete. */
44export type CodexModel = KnownCodexModel | (string & {})
45
46// Reasoning
47//
48// Each model's data for `chat({ reasoning })`: the levels it has, with the
49// provider value for each, and whether it takes a thinking token budget. The
50// data comes from models.dev. The generator that writes it comes with the model
51// catalog later. Until then, edit these entries by hand.
52
53const CODEX_REASONING = {
54 'gpt-5.3-codex': EFFORT_NONE_LOW_TO_XHIGH,
55 'gpt-5.2-codex': EFFORT_LOW_TO_XHIGH,
56 'gpt-5.1-codex': EFFORT_LOW_TO_HIGH,
57 'gpt-5.1-codex-mini': EFFORT_LOW_TO_HIGH,
58 'gpt-5.1': EFFORT_NONE_LOW_TO_HIGH,
59} satisfies Partial<Record<KnownCodexModel, ModelReasoning>>
60
61/**
62 * Each model's reasoning levels, and whether it takes a token budget, for
63 * `chat({ reasoning })`. A model that is not here does not reason.
64 */
65export type CodexModelReasoningByName = {
66 [K in keyof typeof CODEX_REASONING]: ModelReasoningCapability<
67 (typeof CODEX_REASONING)[K]
68 >
69}
70
71/**
72 * Runtime map from model id to its reasoning data, for the text adapter. An
73 * unknown id gives `undefined`: the adapter sends no reasoning field.
74 */
75export const CODEX_MODEL_REASONING: Readonly<Record<string, ModelReasoning>> =
76 CODEX_REASONING