Source file context_window.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
let all =
  [
    (* https://developers.openai.com/api/docs/models/gpt-6-cyber (2026-11-09) *)
    ("gpt-6-cyber", 1_050_000);
    ("gpt-6.2-astra", 1_050_000);
    ("gpt-6.2-astra-healthcare", 1_050_000);
    ("gpt-6.2-sol", 1_050_000);
    ("gpt-6.2-sol-healthcare", 1_050_000);
    ("gpt-6-astra", 1_050_000);
    ("gpt-6-astra-healthcare", 1_050_000);
    ("gpt-6.1-terra", 1_050_000);
    ("gpt-6.1-sol", 1_050_000);
    ("gpt-6.1-sol-healthcare", 1_050_000);
    ("gpt-6-sol", 1_050_000);
    ("gpt-6-luna", 1_050_000);
    ("claude-fable-5-2", 1_000_000);
    ("claude-mythos-5-2", 1_000_000);
    ("claude-fable-5-1", 1_000_000);
    ("claude-mythos-5-1", 1_000_000);
    ("claude-opus-5-5", 1_000_000);
    ("claude-opus-5", 1_000_000);
    ("claude-sonnet-5-5", 1_000_000);
    ("claude-haiku-5-5", 1_000_000);
    ("muse-spark-1.3", 1_048_576);
    ("muse-spark-1.3-contributor", 1_048_576);
    ("muse-wonder-1.0", 1_048_576);
    (* https://dev.meta.ai/docs/muse-ember (2026-11-09) *)
    ("muse-ember-1.0", 1_048_576);
    ("gpt-5.6-cyber", 400_000);
    ("gpt-5.3-codex", 400_000);
    ("chat-latest", 400_000);
    ("grok-4.7", 500_000);
    ("grok-4.6", 500_000);
    ("grok-build-0.1", 256_000);
    ("gpt-5.6-sol", 1_050_000);
    ("gpt-5.6-terra", 1_050_000);
    ("gpt-5.6-luna", 1_050_000);
    ("gpt-5.5", 1_050_000);
    ("gpt-5.4", 1_050_000);
    ("gpt-5.4-mini", 400_000);
    ("gpt-5.4-nano", 400_000);
    ("gpt-5.4-pro", 1_050_000);
    ("gpt-5.2", 400_000);
    ("gpt-5.2-pro", 400_000);
    ("gpt-5.2-codex", 400_000);
    ("gpt-5.1", 400_000);
    ("gpt-5.1-codex", 400_000);
    ("gpt-5.1-codex-max", 400_000);
    ("gpt-5.1-codex-mini", 400_000);
    ("gpt-5", 400_000);
    ("gpt-5-pro", 400_000);
    ("gpt-5-mini", 400_000);
    ("gpt-5-nano", 400_000);
    ("gpt-5-codex", 400_000);
    ("gpt-5-image", 400_000);
    ("gpt-5-image-mini", 400_000);
    ("gpt-4o", 128_000);
    ("gpt-4o-2024-11-20", 128_000);
    ("gpt-4o-2024-08-06", 128_000);
    ("gpt-4o-2024-05-13", 128_000);
    ("gpt-4o-mini", 128_000);
    ("gpt-4o-mini-2024-07-18", 128_000);
    ("gpt-4.1", 1_047_576);
    ("gpt-4.1-mini", 1_047_576);
    ("gpt-4.1-nano", 1_047_576);
    ("gpt-4-turbo", 128_000);
    ("gpt-4-turbo-2024-04-09", 128_000);
    ("gpt-4-turbo-preview", 128_000);
    ("gpt-4", 8_192);
    ("gpt-4-0613", 8_192);
    ("gpt-4-32k", 32_768);
    ("gpt-3.5-turbo", 16_385);
    ("gpt-3.5-turbo-0125", 16_385);
    ("gpt-3.5-turbo-16k", 16_385);
    ("o1", 200_000);
    ("o1-2024-12-17", 200_000);
    ("o1-preview", 128_000);
    ("o1-mini", 128_000);
    ("o1-pro", 200_000);
    ("o3", 200_000);
    ("o3-2025-04-16", 200_000);
    ("o3-mini", 200_000);
    ("o3-mini-2025-01-31", 200_000);
    ("o3-pro", 200_000);
    ("o3-deep-research", 200_000);
    ("o4-mini", 200_000);
    ("o4-mini-deep-research", 200_000);
    ("gpt-oss-120b", 131_072);
    ("gpt-oss-20b", 131_072);
    ("claude-fable-5", 1_000_000);
    ("claude-mythos-5", 1_000_000);
    ("claude-opus-4-8", 1_000_000);
    ("claude-opus-4-7", 1_000_000);
    ("claude-sonnet-5", 1_000_000);
    ("claude-opus-4-6", 1_000_000);
    ("claude-sonnet-4-6", 1_000_000);
    ("claude-opus-4-5-20251101", 200_000);
    ("claude-opus-4-5", 200_000);
    ("claude-sonnet-4-5-20250929", 200_000);
    ("claude-sonnet-4-5", 200_000);
    ("claude-haiku-4-5-20251001", 200_000);
    ("claude-haiku-4-5", 200_000);
    (* retired on the provider's first-party API as of 2026-10; kept so existing ids still resolve *)
    ("claude-opus-4-1-20250805", 200_000);
    ("claude-opus-4-1", 200_000);
    ("claude-sonnet-4-20250514", 200_000);
    ("claude-sonnet-4-0", 200_000);
    ("claude-opus-4-20250514", 200_000);
    ("claude-opus-4-0", 200_000);
    ("claude-3-5-sonnet-20241022", 200_000);
    ("claude-3-5-sonnet-20240620", 200_000);
    ("claude-3-5-haiku-20241022", 200_000);
    ("claude-3-opus-20240229", 200_000);
    ("claude-3-haiku-20240307", 200_000);
    ("muse-spark-1.2", 1_048_576);
    ("muse-spark-1.1", 1_048_576);
    ("muse-spark-1.2-contributor", 1_048_576);
    ("grok-4.5", 500_000);
    ("grok-4.3", 1_000_000);
    ("grok-4.20-0309-reasoning", 1_000_000);
    ("grok-4.20-0309-non-reasoning", 1_000_000);
    ("grok-4.20-multi-agent-0309", 1_000_000);
    (* retired on the provider's first-party API as of 2026-10; kept so existing ids still resolve *)
    ("grok-4-1-fast-reasoning", 2_000_000);
    ("grok-4-1-fast-non-reasoning", 2_000_000);
    ("grok-4-fast-reasoning", 2_000_000);
    ("grok-4-fast-non-reasoning", 2_000_000);
    ("grok-4-0709", 256_000);
    ("grok-4", 256_000);
    ("grok-code-fast-1", 256_000);
    ("grok-3", 131_072);
    ("grok-3-mini", 131_072);
    ("grok-2-vision-1212", 32_768);
  ]

let get ?fallback model =
  match List.assoc_opt model all with
  | Some value -> Some value
  | None -> fallback

let has model = Option.is_some (List.assoc_opt model all)