Skip to content

Commit db24d2f

Browse files
committed
refactor(opencode-go): consolidate model metadata
1 parent 206e082 commit db24d2f

5 files changed

Lines changed: 270 additions & 50 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
@@ -11,6 +11,7 @@ import {
1111
describe("opencode-go registry", () => {
1212
const anthropicFormatModels = [
1313
"qwen3.8-max",
14+
"qwen3.8-flash",
1415
"qwen3.7-max",
1516
"qwen3.7-plus",
1617
"qwen3.6-plus",

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

Lines changed: 248 additions & 33 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
*
@@ -126,6 +101,21 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
126101
description:
127102
"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.",
128103
},
104+
"glm-5.3-flash": {
105+
maxTokens: 131_072,
106+
contextWindow: 1_000_000,
107+
supportsImages: true,
108+
supportsPromptCache: true,
109+
supportsMaxTokens: true,
110+
supportsReasoningEffort: ["low", "high", "max"],
111+
reasoningEffort: "max",
112+
preserveReasoning: true,
113+
inputPrice: 0.075,
114+
outputPrice: 0.25,
115+
cacheReadsPrice: 0.015,
116+
description:
117+
"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.",
118+
},
129119
"glm-5.2": {
130120
maxTokens: 131_072,
131121
contextWindow: 1_000_000,
@@ -187,6 +177,36 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
187177
description:
188178
"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.",
189179
},
180+
"kimi-k2.7-code": {
181+
maxTokens: 262_144,
182+
contextWindow: 262_144,
183+
supportsImages: true,
184+
supportsPromptCache: true,
185+
supportsMaxTokens: true,
186+
preserveReasoning: true,
187+
defaultTemperature: 1.0,
188+
inputPrice: 0.95,
189+
outputPrice: 4.0,
190+
cacheReadsPrice: 0.19,
191+
description:
192+
"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.",
193+
},
194+
195+
// --- Meituan LongCat ---
196+
"longcat-2.0": {
197+
maxTokens: 131_072,
198+
contextWindow: 1_000_000,
199+
supportsImages: false,
200+
supportsPromptCache: true,
201+
supportsMaxTokens: true,
202+
supportsReasoningBinary: true,
203+
preserveReasoning: true,
204+
inputPrice: 0.3,
205+
outputPrice: 1.2,
206+
cacheReadsPrice: 0.006,
207+
description:
208+
"LongCat 2.0 is Meituan's long-context reasoning and coding model with a 1M context window. Available via the Opencode Go plan.",
209+
},
190210

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

229279
// --- MiniMax ---
230280
"minimax-m2.5": {
@@ -279,6 +329,21 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
279329
},
280330

281331
// --- Alibaba Qwen ---
332+
"qwen3.5-plus": {
333+
maxTokens: 65_536,
334+
contextWindow: 262_144,
335+
supportsImages: true,
336+
supportsPromptCache: true,
337+
supportsReasoningBudget: true,
338+
supportsReasoningBinary: true,
339+
preserveReasoning: true,
340+
inputPrice: 0.2,
341+
outputPrice: 1.2,
342+
cacheReadsPrice: 0.02,
343+
cacheWritesPrice: 0.25,
344+
description:
345+
"Qwen3.5 Plus is Alibaba's multimodal reasoning model with a 256k context window. Available via the Opencode Go plan.",
346+
},
282347
"qwen3.6-plus": {
283348
maxTokens: 65_536,
284349
contextWindow: 1_000_000,
@@ -345,6 +410,22 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
345410
description:
346411
"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.",
347412
},
413+
"qwen3.8-flash": {
414+
maxTokens: 131_072,
415+
contextWindow: 1_000_000,
416+
supportsImages: true,
417+
supportsPromptCache: true,
418+
supportsMaxTokens: true,
419+
supportsReasoningBudget: true,
420+
supportsReasoningBinary: true,
421+
preserveReasoning: true,
422+
inputPrice: 0.15,
423+
outputPrice: 0.47,
424+
cacheReadsPrice: 0.016,
425+
cacheWritesPrice: 0.2,
426+
description:
427+
"Qwen3.8 Flash is Alibaba's fast multimodal reasoning model with a 1M context window. Available via the Opencode Go plan.",
428+
},
348429

349430
// --- DeepSeek ---
350431
"deepseek-v4-pro": {
@@ -383,6 +464,147 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
383464
description:
384465
"DeepSeek-V4-Flash is DeepSeek's fast, cost-efficient V4 model supporting thinking and non-thinking modes. Available via the Opencode Go plan.",
385466
},
467+
"deepseek-v4-flash-vision-exp": {
468+
maxTokens: 384_000,
469+
contextWindow: 1_000_000,
470+
supportsImages: true,
471+
supportsPromptCache: true,
472+
supportsMaxTokens: true,
473+
supportsReasoningEffort: ["disable", "low", "high", "max"],
474+
reasoningEffort: "high",
475+
preserveReasoning: true,
476+
inputPrice: 0.22,
477+
outputPrice: 0.66,
478+
cacheReadsPrice: 0.007,
479+
description:
480+
"DeepSeek V4 Flash Vision Experimental is a fast multimodal reasoning model with a 1M context window. Available via the Opencode Go plan.",
481+
},
482+
483+
// --- Tencent Hunyuan ---
484+
"hy4-preview": {
485+
maxTokens: 64_000,
486+
contextWindow: 1_024_000,
487+
supportsImages: false,
488+
supportsPromptCache: true,
489+
supportsMaxTokens: true,
490+
supportsReasoningEffort: ["disable", "high"],
491+
reasoningEffort: "high",
492+
preserveReasoning: true,
493+
inputPrice: 0.834,
494+
outputPrice: 2.501,
495+
cacheReadsPrice: 0.042,
496+
description:
497+
"Hunyuan 4 Preview is Tencent's long-context reasoning and coding model with a 1M context window. Available via the Opencode Go plan.",
498+
},
499+
hy3: {
500+
maxTokens: 64_000,
501+
contextWindow: 256_000,
502+
supportsImages: false,
503+
supportsPromptCache: true,
504+
supportsMaxTokens: true,
505+
supportsReasoningEffort: ["disable", "low", "high"],
506+
reasoningEffort: "high",
507+
preserveReasoning: true,
508+
inputPrice: 0.0175,
509+
outputPrice: 0.0725,
510+
cacheReadsPrice: 0.004375,
511+
description:
512+
"Hunyuan 3 is Tencent's reasoning and coding model with a 256k context window. Available via the Opencode Go plan.",
513+
},
514+
"hy3-preview": {
515+
// The live endpoint still lists this historical alias; it shares HY3's limits and pricing.
516+
maxTokens: 64_000,
517+
contextWindow: 256_000,
518+
supportsImages: false,
519+
supportsPromptCache: true,
520+
supportsMaxTokens: true,
521+
supportsReasoningEffort: ["disable", "low", "high"],
522+
reasoningEffort: "high",
523+
preserveReasoning: true,
524+
inputPrice: 0.0175,
525+
outputPrice: 0.0725,
526+
cacheReadsPrice: 0.004375,
527+
description:
528+
"Hunyuan 3 Preview is Tencent's preview reasoning and coding model with a 256k context window. Available via the Opencode Go plan.",
529+
},
530+
531+
// --- Responses API models ---
532+
"gpt-5.6-luna": {
533+
maxTokens: 128_000,
534+
contextWindow: 1_050_000,
535+
supportsImages: true,
536+
supportsPromptCache: true,
537+
supportsMaxTokens: true,
538+
supportsReasoningEffort: ["none", "low", "medium", "high", "xhigh", "max"],
539+
reasoningEffort: "medium",
540+
inputPrice: 0.2,
541+
outputPrice: 1.2,
542+
cacheWritesPrice: 0.25,
543+
cacheReadsPrice: 0.02,
544+
longContextPricing: {
545+
thresholdTokens: 272_000,
546+
inputPriceMultiplier: 2,
547+
outputPriceMultiplier: 1.5,
548+
cacheWritesPriceMultiplier: 2,
549+
cacheReadsPriceMultiplier: 2,
550+
},
551+
description:
552+
"GPT-5.6 Luna is OpenAI's fast reasoning model with a 1M context window. Available via the Opencode Go plan.",
553+
},
554+
"grok-4.5": {
555+
maxTokens: 500_000,
556+
contextWindow: 500_000,
557+
supportsImages: true,
558+
supportsPromptCache: true,
559+
supportsMaxTokens: true,
560+
supportsReasoningEffort: ["low", "medium", "high"],
561+
reasoningEffort: "high",
562+
inputPrice: 2.0,
563+
outputPrice: 6.0,
564+
cacheReadsPrice: 0.3,
565+
longContextPricing: {
566+
thresholdTokens: 200_000,
567+
inputPriceMultiplier: 2,
568+
outputPriceMultiplier: 2,
569+
cacheReadsPriceMultiplier: 2,
570+
},
571+
description:
572+
"Grok 4.5 is xAI's multimodal reasoning and agent model with a 500k context window. Available via the Opencode Go plan.",
573+
},
574+
"grok-4.6": {
575+
maxTokens: 500_000,
576+
contextWindow: 500_000,
577+
supportsImages: true,
578+
supportsPromptCache: true,
579+
supportsMaxTokens: true,
580+
supportsReasoningEffort: ["low", "medium", "high", "xhigh"],
581+
reasoningEffort: "high",
582+
inputPrice: 2.0,
583+
outputPrice: 6.0,
584+
cacheReadsPrice: 0.5,
585+
longContextPricing: {
586+
thresholdTokens: 200_000,
587+
inputPriceMultiplier: 2,
588+
outputPriceMultiplier: 2,
589+
cacheReadsPriceMultiplier: 2,
590+
},
591+
description:
592+
"Grok 4.6 is xAI's multimodal reasoning and agent model with a 500k context window. Available via the Opencode Go plan.",
593+
},
594+
"muse-spark-1.2-contributor": {
595+
maxTokens: 131_072,
596+
contextWindow: 1_048_576,
597+
supportsImages: true,
598+
supportsPromptCache: true,
599+
supportsMaxTokens: true,
600+
supportsReasoningEffort: ["minimal", "low", "medium", "high", "xhigh"],
601+
reasoningEffort: "medium",
602+
inputPrice: 0.1,
603+
outputPrice: 0.2,
604+
cacheReadsPrice: 0.002,
605+
description:
606+
"Muse Spark 1.2 Contributor is Meta's multimodal coding model with a 1M context window. Available via the Opencode Go plan.",
607+
},
386608
}
387609

388610
/**
@@ -404,6 +626,7 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
404626
export const OPENCODE_GO_ANTHROPIC_FORMAT_MODELS = new Set<string>([
405627
// --- Alibaba Qwen ---
406628
"qwen3.8-max",
629+
"qwen3.8-flash",
407630
"qwen3.7-max",
408631
"qwen3.7-plus",
409632
"qwen3.6-plus",
@@ -431,11 +654,3 @@ export function isOpencodeGoAnthropicFormatModel(modelId: string): boolean {
431654
export function getOpencodeGoModelInfo(modelId: string): ModelInfo | undefined {
432655
return opencodeGoModels[modelId]
433656
}
434-
435-
/** Returns explicit model limits when Go omits them from `/v1/models`. */
436-
export function getOpencodeGoModelLimits(modelId: string): Pick<ModelInfo, "contextWindow" | "maxTokens"> | undefined {
437-
const native = getOpencodeGoModelInfo(modelId)
438-
return native
439-
? { contextWindow: native.contextWindow, maxTokens: native.maxTokens }
440-
: opencodeGoModelLimits[modelId]
441-
}

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

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

800800
describe("isOpencodeGoAnthropicFormatModel", () => {
801801
it("classifies Qwen and MiniMax Go models as Anthropic-format", () => {
802+
expect(isOpencodeGoAnthropicFormatModel("qwen3.8-flash")).toBe(true)
802803
expect(isOpencodeGoAnthropicFormatModel("qwen3.7-max")).toBe(true)
803804
expect(isOpencodeGoAnthropicFormatModel("qwen3.7-plus")).toBe(true)
804805
expect(isOpencodeGoAnthropicFormatModel("qwen3.6-plus")).toBe(true)
@@ -812,6 +813,7 @@ describe("OpencodeGoHandler", () => {
812813
expect(isOpencodeGoAnthropicFormatModel("kimi-k2.6")).toBe(false)
813814
expect(isOpencodeGoAnthropicFormatModel("deepseek-v4-pro")).toBe(false)
814815
expect(isOpencodeGoAnthropicFormatModel("mimo-v2.5")).toBe(false)
816+
expect(isOpencodeGoAnthropicFormatModel("qwen3.5-plus")).toBe(false)
815817
})
816818

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

0 commit comments

Comments
 (0)