/ mervelas / src / utils / model / openCodeModels.ts
Swadhin Biswas feat: implement mervelas cli engine, built-in tools, and reactive UI · 4/3/2026
0358986
384 lines · 10.1 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
export type OpenCodeTransport =
  | 'responses'
  | 'messages'
  | 'chat-completions'
  | 'google-models'

export type OpenCodeModelCatalogEntry = {
  id: string
  label: string
  description: string
  transport: OpenCodeTransport
  free?: boolean
  keyless?: boolean
  supported?: boolean
}

const RESPONSES_DESCRIPTION = 'OpenCode Zen Responses endpoint'
const MESSAGES_DESCRIPTION = 'OpenCode Zen Messages endpoint'
const CHAT_COMPLETIONS_DESCRIPTION = 'OpenCode Zen Chat Completions endpoint'
const GOOGLE_MODELS_DESCRIPTION = 'OpenCode Zen Google models endpoint'

export const OPENCODE_MODEL_CATALOG: OpenCodeModelCatalogEntry[] = [
  {
    id: 'claude-opus-4-6',
    label: 'Claude Opus 4.6',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'claude-opus-4-5',
    label: 'Claude Opus 4.5',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'claude-opus-4-1',
    label: 'Claude Opus 4.1',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'claude-sonnet-4-6',
    label: 'Claude Sonnet 4.6',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'claude-sonnet-4-5',
    label: 'Claude Sonnet 4.5',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'claude-sonnet-4',
    label: 'Claude Sonnet 4',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'claude-3-5-haiku',
    label: 'Claude 3.5 Haiku',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'claude-haiku-4-5',
    label: 'Claude Haiku 4.5',
    description: `OpenCode Zen Claude model via the ${MESSAGES_DESCRIPTION}`,
    transport: 'messages',
    supported: true,
  },
  {
    id: 'gemini-3.1-pro',
    label: 'Gemini 3.1 Pro',
    description: `Available on OpenCode Zen via the ${GOOGLE_MODELS_DESCRIPTION} (not wired in Mervelas yet)`,
    transport: 'google-models',
    supported: false,
  },
  {
    id: 'gemini-3-pro',
    label: 'Gemini 3 Pro',
    description: `Available on OpenCode Zen via the ${GOOGLE_MODELS_DESCRIPTION} (not wired in Mervelas yet)`,
    transport: 'google-models',
    supported: false,
  },
  {
    id: 'gemini-3-flash',
    label: 'Gemini 3 Flash',
    description: `Available on OpenCode Zen via the ${GOOGLE_MODELS_DESCRIPTION} (not wired in Mervelas yet)`,
    transport: 'google-models',
    supported: false,
  },
  {
    id: 'gpt-5.4',
    label: 'GPT 5.4',
    description: `OpenCode Zen GPT model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.4-pro',
    label: 'GPT 5.4 Pro',
    description: `Premium OpenCode Zen GPT model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.4-mini',
    label: 'GPT 5.4 Mini',
    description: `Smaller OpenCode Zen GPT model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.4-nano',
    label: 'GPT 5.4 Nano',
    description: `Smallest OpenCode Zen GPT model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.3-codex-spark',
    label: 'GPT 5.3 Codex Spark',
    description: `Coding-focused OpenCode Zen model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.3-codex',
    label: 'GPT 5.3 Codex',
    description: `Coding-focused OpenCode Zen model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.2',
    label: 'GPT 5.2',
    description: `OpenCode Zen GPT model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.2-codex',
    label: 'GPT 5.2 Codex',
    description: `OpenCode Zen GPT coding model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.1',
    label: 'GPT 5.1',
    description: `OpenCode Zen GPT model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.1-codex-max',
    label: 'GPT 5.1 Codex Max',
    description: `OpenCode Zen GPT coding model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.1-codex',
    label: 'GPT 5.1 Codex',
    description: `OpenCode Zen GPT coding model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5.1-codex-mini',
    label: 'GPT 5.1 Codex Mini',
    description: `OpenCode Zen GPT coding model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5',
    label: 'GPT 5',
    description: `OpenCode Zen GPT model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5-codex',
    label: 'GPT 5 Codex',
    description: `OpenCode Zen GPT coding model via the ${RESPONSES_DESCRIPTION}`,
    transport: 'responses',
    supported: true,
  },
  {
    id: 'gpt-5-nano',
    label: 'GPT 5 Nano',
    description: `Free on OpenCode Zen and usable without a key via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'glm-5',
    label: 'GLM 5',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'glm-4.7',
    label: 'GLM 4.7',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'glm-4.6',
    label: 'GLM 4.6',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'minimax-m2.5',
    label: 'MiniMax M2.5',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'minimax-m2.5-free',
    label: 'MiniMax M2.5 Free',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'minimax-m2.1',
    label: 'MiniMax M2.1',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'qwen3.6-plus-free',
    label: 'Qwen 3.6 Plus Free',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'mimo-v2-pro-free',
    label: 'MiMo V2 Pro Free',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'mimo-v2-omni-free',
    label: 'MiMo V2 Omni Free',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'mimo-v2-flash-free',
    label: 'MiMo V2 Flash Free',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'kimi-k2.5',
    label: 'Kimi K2.5',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'kimi-k2',
    label: 'Kimi K2',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'kimi-k2-thinking',
    label: 'Kimi K2 Thinking',
    description: `Available on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    supported: true,
  },
  {
    id: 'trinity-large-preview-free',
    label: 'Trinity Large Preview Free',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'big-pickle',
    label: 'Big Pickle',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
  {
    id: 'nemotron-3-super-free',
    label: 'Nemotron 3 Super Free',
    description: `Free on OpenCode Zen via the ${CHAT_COMPLETIONS_DESCRIPTION}`,
    transport: 'chat-completions',
    free: true,
    keyless: true,
    supported: true,
  },
]

const OPENCODE_MODEL_LOOKUP = new Map(
  OPENCODE_MODEL_CATALOG.map(model => [model.id, model]),
)

export function getOpenCodeModelCatalogEntry(
  model: string,
): OpenCodeModelCatalogEntry | undefined {
  return OPENCODE_MODEL_LOOKUP.get(model.trim())
}

export function getOpenCodeTransportForModel(
  model: string,
): OpenCodeTransport | null {
  const normalized = model.trim().toLowerCase()
  const known = getOpenCodeModelCatalogEntry(normalized)
  if (known) {
    return known.transport
  }

  if (normalized.startsWith('claude-')) {
    return 'messages'
  }

  if (
    normalized.startsWith('gpt-') ||
    normalized.startsWith('codex') ||
    normalized.includes('codex')
  ) {
    return 'responses'
  }

  if (normalized.startsWith('gemini-')) {
    return 'google-models'
  }

  return 'chat-completions'
}

export function isSupportedOpenCodeTransport(
  transport: OpenCodeTransport | null,
): boolean {
  return (
    transport === 'responses' ||
    transport === 'messages' ||
    transport === 'chat-completions'
  )
}