Skip to content

Commit 2c33bd3

Browse files
navedmerchantroomote
authored andcommitted
refactor(opencode-go): consolidate model metadata
1 parent 4151fc3 commit 2c33bd3

5 files changed

Lines changed: 250 additions & 51 deletions

File tree

‎packages/types/src/__tests__/opencode-go.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
describe("opencode-go registry", () => {
1414
const anthropicFormatModels = [
1515
"qwen3.8-max",
16+
"qwen3.8-flash",
1617
"qwen3.7-max",
1718
"qwen3.7-plus",
1819
"qwen3.6-plus",

‎packages/types/src/providers/opencode-go.ts‎

Lines changed: 228 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,6 @@ export const opencodeGoDefaultModelInfo: ModelInfo = {
2121

2222
export const OPENCODE_GO_DEFAULT_TEMPERATURE = 0
2323

24-
/**
25-
* Limits for Go models that do not yet have a full native configuration below.
26-
*
27-
* The Go `/v1/models` endpoint currently returns only model IDs, so these
28-
* values prevent newly listed models from inheriting the generic 200k context
29-
* window. Keep this table aligned with the endpoint and models.dev metadata.
30-
*/
31-
export const opencodeGoModelLimits: Record<string, Pick<ModelInfo, "contextWindow" | "maxTokens">> = {
32-
"kimi-k2.7-code": { contextWindow: 262_144, maxTokens: 262_144 },
33-
"longcat-2.0": { contextWindow: 1_000_000, maxTokens: 131_072 },
34-
"glm-5.3-flash": { contextWindow: 1_000_000, maxTokens: 131_072 },
35-
"deepseek-v4-flash-vision-exp": { contextWindow: 1_000_000, maxTokens: 384_000 },
36-
"qwen3.8-flash": { contextWindow: 1_000_000, maxTokens: 131_072 },
37-
"qwen3.5-plus": { contextWindow: 262_144, maxTokens: 65_536 },
38-
"mimo-v2-pro": { contextWindow: 1_048_576, maxTokens: 128_000 },
39-
"mimo-v2-omni": { contextWindow: 262_144, maxTokens: 128_000 },
40-
"hy4-preview": { contextWindow: 1_024_000, maxTokens: 64_000 },
41-
hy3: { contextWindow: 256_000, maxTokens: 64_000 },
42-
"hy3-preview": { contextWindow: 256_000, maxTokens: 64_000 },
43-
"gpt-5.6-luna": { contextWindow: 1_050_000, maxTokens: 128_000 },
44-
"grok-4.5": { contextWindow: 500_000, maxTokens: 500_000 },
45-
"grok-4.6": { contextWindow: 500_000, maxTokens: 500_000 },
46-
"muse-spark-1.2-contributor": { contextWindow: 1_048_576, maxTokens: 131_072 },
47-
}
48-
4924
/**
5025
* Native per-model configuration for the Opencode Go plan.
5126
*
@@ -127,6 +102,21 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
127102
description:
128103
"GLM-5.3 is Zhipu's flagship coding and agent model with a 1M context window, 128k max output, and always-on reasoning with configurable effort (Low/High/Max). Available via the Opencode Go plan.",
129104
},
105+
"glm-5.3-flash": {
106+
maxTokens: 131_072,
107+
contextWindow: 1_000_000,
108+
supportsImages: true,
109+
supportsPromptCache: true,
110+
supportsMaxTokens: true,
111+
supportsReasoningEffort: ["low", "high", "max"],
112+
reasoningEffort: "max",
113+
preserveReasoning: true,
114+
inputPrice: 0.075,
115+
outputPrice: 0.25,
116+
cacheReadsPrice: 0.015,
117+
description:
118+
"GLM-5.3 Flash is Zhipu's fast multimodal coding and agent model with a 1M context window and configurable reasoning effort. Available via the Opencode Go plan.",
119+
},
130120
"glm-5.2": {
131121
maxTokens: 131_072,
132122
contextWindow: 1_000_000,
@@ -188,6 +178,36 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
188178
description:
189179
"Kimi K2.6 is Moonshot AI's native multimodal agentic MoE model with a 256k context window, built for long-horizon coding and tool use. Available via the Opencode Go plan.",
190180
},
181+
"kimi-k2.7-code": {
182+
maxTokens: 262_144,
183+
contextWindow: 262_144,
184+
supportsImages: true,
185+
supportsPromptCache: true,
186+
supportsMaxTokens: true,
187+
preserveReasoning: true,
188+
defaultTemperature: 1.0,
189+
inputPrice: 0.95,
190+
outputPrice: 4.0,
191+
cacheReadsPrice: 0.19,
192+
description:
193+
"Kimi K2.7 Code is Moonshot AI's coding model for long-context programming tasks, with multimodal input and a 256k context window. Available via the Opencode Go plan.",
194+
},
195+
196+
// --- Meituan LongCat ---
197+
"longcat-2.0": {
198+
maxTokens: 131_072,
199+
contextWindow: 1_000_000,
200+
supportsImages: false,
201+
supportsPromptCache: true,
202+
supportsMaxTokens: true,
203+
supportsReasoningBinary: true,
204+
preserveReasoning: true,
205+
inputPrice: 0.3,
206+
outputPrice: 1.2,
207+
cacheReadsPrice: 0.006,
208+
description:
209+
"LongCat 2.0 is Meituan's long-context reasoning and coding model with a 1M context window. Available via the Opencode Go plan.",
210+
},
191211

192212
// --- Xiaomi MiMo ---
193213
"mimo-v2.5": {
@@ -226,6 +246,36 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
226246
description:
227247
"MiMo V2.5 Pro - Xiaomi's flagship reasoning model with 1M context, deep thinking, and tool calling. Available via the Opencode Go plan.",
228248
},
249+
"mimo-v2-pro": {
250+
maxTokens: 128_000,
251+
contextWindow: 1_048_576,
252+
supportsImages: false,
253+
supportsPromptCache: false,
254+
preserveReasoning: true,
255+
inputPrice: 1.0,
256+
outputPrice: 3.0,
257+
cacheReadsPrice: 0.2,
258+
longContextPricing: {
259+
thresholdTokens: 256_000,
260+
inputPriceMultiplier: 2,
261+
outputPriceMultiplier: 2,
262+
cacheReadsPriceMultiplier: 2,
263+
},
264+
description:
265+
"MiMo V2 Pro is Xiaomi's text reasoning and coding model with a 1M context window. Available via the Opencode Go plan.",
266+
},
267+
"mimo-v2-omni": {
268+
maxTokens: 128_000,
269+
contextWindow: 262_144,
270+
supportsImages: true,
271+
supportsPromptCache: false,
272+
preserveReasoning: true,
273+
inputPrice: 0.4,
274+
outputPrice: 2.0,
275+
cacheReadsPrice: 0.08,
276+
description:
277+
"MiMo V2 Omni is Xiaomi's multimodal reasoning model with a 256k context window. Available via the Opencode Go plan.",
278+
},
229279

230280
// --- MiniMax ---
231281
"minimax-m2.5": {
@@ -280,6 +330,21 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
280330
},
281331

282332
// --- Alibaba Qwen ---
333+
"qwen3.5-plus": {
334+
maxTokens: 65_536,
335+
contextWindow: 262_144,
336+
supportsImages: true,
337+
supportsPromptCache: true,
338+
supportsReasoningBudget: true,
339+
supportsReasoningBinary: true,
340+
preserveReasoning: true,
341+
inputPrice: 0.2,
342+
outputPrice: 1.2,
343+
cacheReadsPrice: 0.02,
344+
cacheWritesPrice: 0.25,
345+
description:
346+
"Qwen3.5 Plus is Alibaba's multimodal reasoning model with a 256k context window. Available via the Opencode Go plan.",
347+
},
283348
"qwen3.6-plus": {
284349
maxTokens: 65_536,
285350
contextWindow: 1_000_000,
@@ -346,6 +411,22 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
346411
description:
347412
"Qwen3.8 Max - Alibaba's flagship multimodal reasoning model with a 1M context window, 128k max output, and long-horizon coding and agentic capabilities. Available via the Opencode Go plan.",
348413
},
414+
"qwen3.8-flash": {
415+
maxTokens: 131_072,
416+
contextWindow: 1_000_000,
417+
supportsImages: true,
418+
supportsPromptCache: true,
419+
supportsMaxTokens: true,
420+
supportsReasoningBudget: true,
421+
supportsReasoningBinary: true,
422+
preserveReasoning: true,
423+
inputPrice: 0.15,
424+
outputPrice: 0.47,
425+
cacheReadsPrice: 0.016,
426+
cacheWritesPrice: 0.2,
427+
description:
428+
"Qwen3.8 Flash is Alibaba's fast multimodal reasoning model with a 1M context window. Available via the Opencode Go plan.",
429+
},
349430

350431
// --- DeepSeek ---
351432
"deepseek-v4-pro": {
@@ -384,6 +465,70 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
384465
description:
385466
"DeepSeek-V4-Flash is DeepSeek's fast, cost-efficient V4 model supporting thinking and non-thinking modes. Available via the Opencode Go plan.",
386467
},
468+
"deepseek-v4-flash-vision-exp": {
469+
maxTokens: 384_000,
470+
contextWindow: 1_000_000,
471+
supportsImages: true,
472+
supportsPromptCache: true,
473+
supportsMaxTokens: true,
474+
supportsReasoningEffort: ["disable", "low", "high", "max"],
475+
reasoningEffort: "high",
476+
preserveReasoning: true,
477+
inputPrice: 0.22,
478+
outputPrice: 0.66,
479+
cacheReadsPrice: 0.007,
480+
description:
481+
"DeepSeek V4 Flash Vision Experimental is a fast multimodal reasoning model with a 1M context window. Available via the Opencode Go plan.",
482+
},
483+
484+
// --- Tencent Hunyuan ---
485+
"hy4-preview": {
486+
maxTokens: 64_000,
487+
contextWindow: 1_024_000,
488+
supportsImages: false,
489+
supportsPromptCache: true,
490+
supportsMaxTokens: true,
491+
supportsReasoningEffort: ["disable", "high"],
492+
reasoningEffort: "high",
493+
preserveReasoning: true,
494+
inputPrice: 0.834,
495+
outputPrice: 2.501,
496+
cacheReadsPrice: 0.042,
497+
description:
498+
"Hunyuan 4 Preview is Tencent's long-context reasoning and coding model with a 1M context window. Available via the Opencode Go plan.",
499+
},
500+
hy3: {
501+
maxTokens: 64_000,
502+
contextWindow: 256_000,
503+
supportsImages: false,
504+
supportsPromptCache: true,
505+
supportsMaxTokens: true,
506+
supportsReasoningEffort: ["disable", "low", "high"],
507+
reasoningEffort: "high",
508+
preserveReasoning: true,
509+
inputPrice: 0.0175,
510+
outputPrice: 0.0725,
511+
cacheReadsPrice: 0.004375,
512+
description:
513+
"Hunyuan 3 is Tencent's reasoning and coding model with a 256k context window. Available via the Opencode Go plan.",
514+
},
515+
"hy3-preview": {
516+
// The live endpoint still lists this historical alias; it shares HY3's limits and pricing.
517+
maxTokens: 64_000,
518+
contextWindow: 256_000,
519+
supportsImages: false,
520+
supportsPromptCache: true,
521+
supportsMaxTokens: true,
522+
supportsReasoningEffort: ["disable", "low", "high"],
523+
reasoningEffort: "high",
524+
preserveReasoning: true,
525+
inputPrice: 0.0175,
526+
outputPrice: 0.0725,
527+
cacheReadsPrice: 0.004375,
528+
description:
529+
"Hunyuan 3 Preview is Tencent's preview reasoning and coding model with a 256k context window. Available via the Opencode Go plan.",
530+
},
531+
387532
// --- OpenAI Responses ---
388533
// Luna is curated here because the Go gateway's model catalogue does not
389534
// currently provide its capability metadata. These values intentionally
@@ -393,6 +538,7 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
393538
contextWindow: 1_050_000,
394539
supportsImages: true,
395540
supportsPromptCache: true,
541+
supportsMaxTokens: true,
396542
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
397543
reasoningEffort: "medium",
398544
inputPrice: 0.2,
@@ -406,7 +552,62 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
406552
cacheWritesPriceMultiplier: 2,
407553
cacheReadsPriceMultiplier: 2,
408554
},
409-
description: "GPT-5.6 Luna via the OpenCode Go Responses API.",
555+
description:
556+
"GPT-5.6 Luna is OpenAI's fast reasoning model with a 1M context window. Available via the Opencode Go plan.",
557+
},
558+
"grok-4.5": {
559+
maxTokens: 500_000,
560+
contextWindow: 500_000,
561+
supportsImages: true,
562+
supportsPromptCache: true,
563+
supportsMaxTokens: true,
564+
supportsReasoningEffort: ["low", "medium", "high"],
565+
reasoningEffort: "high",
566+
inputPrice: 2.0,
567+
outputPrice: 6.0,
568+
cacheReadsPrice: 0.3,
569+
longContextPricing: {
570+
thresholdTokens: 200_000,
571+
inputPriceMultiplier: 2,
572+
outputPriceMultiplier: 2,
573+
cacheReadsPriceMultiplier: 2,
574+
},
575+
description:
576+
"Grok 4.5 is xAI's multimodal reasoning and agent model with a 500k context window. Available via the Opencode Go plan.",
577+
},
578+
"grok-4.6": {
579+
maxTokens: 500_000,
580+
contextWindow: 500_000,
581+
supportsImages: true,
582+
supportsPromptCache: true,
583+
supportsMaxTokens: true,
584+
supportsReasoningEffort: ["low", "medium", "high", "xhigh"],
585+
reasoningEffort: "high",
586+
inputPrice: 2.0,
587+
outputPrice: 6.0,
588+
cacheReadsPrice: 0.5,
589+
longContextPricing: {
590+
thresholdTokens: 200_000,
591+
inputPriceMultiplier: 2,
592+
outputPriceMultiplier: 2,
593+
cacheReadsPriceMultiplier: 2,
594+
},
595+
description:
596+
"Grok 4.6 is xAI's multimodal reasoning and agent model with a 500k context window. Available via the Opencode Go plan.",
597+
},
598+
"muse-spark-1.2-contributor": {
599+
maxTokens: 131_072,
600+
contextWindow: 1_048_576,
601+
supportsImages: true,
602+
supportsPromptCache: true,
603+
supportsMaxTokens: true,
604+
supportsReasoningEffort: ["minimal", "low", "medium", "high", "xhigh"],
605+
reasoningEffort: "medium",
606+
inputPrice: 0.1,
607+
outputPrice: 0.2,
608+
cacheReadsPrice: 0.002,
609+
description:
610+
"Muse Spark 1.2 Contributor is Meta's multimodal coding model with a 1M context window. Available via the Opencode Go plan.",
410611
},
411612
}
412613

@@ -429,6 +630,7 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
429630
export const OPENCODE_GO_ANTHROPIC_FORMAT_MODELS = new Set<string>([
430631
// --- Alibaba Qwen ---
431632
"qwen3.8-max",
633+
"qwen3.8-flash",
432634
"qwen3.7-max",
433635
"qwen3.7-plus",
434636
"qwen3.6-plus",
@@ -488,11 +690,3 @@ export function isOpencodeGoResponsesFormatModel(modelId: string): boolean {
488690
export function getOpencodeGoModelInfo(modelId: string): ModelInfo | undefined {
489691
return opencodeGoModels[modelId]
490692
}
491-
492-
/** Returns explicit model limits when Go omits them from `/v1/models`. */
493-
export function getOpencodeGoModelLimits(modelId: string): Pick<ModelInfo, "contextWindow" | "maxTokens"> | undefined {
494-
const native = getOpencodeGoModelInfo(modelId)
495-
return native
496-
? { contextWindow: native.contextWindow, maxTokens: native.maxTokens }
497-
: opencodeGoModelLimits[modelId]
498-
}

‎src/api/providers/__tests__/opencode-go.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,7 @@ describe("OpencodeGoHandler", () => {
13441344

13451345
describe("isOpencodeGoAnthropicFormatModel", () => {
13461346
it("classifies Qwen and MiniMax Go models as Anthropic-format", () => {
1347+
expect(isOpencodeGoAnthropicFormatModel("qwen3.8-flash")).toBe(true)
13471348
expect(isOpencodeGoAnthropicFormatModel("qwen3.7-max")).toBe(true)
13481349
expect(isOpencodeGoAnthropicFormatModel("qwen3.7-plus")).toBe(true)
13491350
expect(isOpencodeGoAnthropicFormatModel("qwen3.6-plus")).toBe(true)
@@ -1357,6 +1358,7 @@ describe("OpencodeGoHandler", () => {
13571358
expect(isOpencodeGoAnthropicFormatModel("kimi-k2.6")).toBe(false)
13581359
expect(isOpencodeGoAnthropicFormatModel("deepseek-v4-pro")).toBe(false)
13591360
expect(isOpencodeGoAnthropicFormatModel("mimo-v2.5")).toBe(false)
1361+
expect(isOpencodeGoAnthropicFormatModel("qwen3.5-plus")).toBe(false)
13601362
})
13611363

13621364
it("defaults unknown model IDs to the OpenAI-compatible format", () => {

0 commit comments

Comments
 (0)