pi-tsgw 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import { OPENAI_COMPLETIONS_COMPAT } from "./_protocols.ts";
3
+ import { isMaximum, type PayloadWriter, type ThinkingApplier, type ThinkingLevel } from "../_tools.ts";
4
+
5
+ // DeepSeek 在 openai-completions 协议基础上,要求 DeepSeek 特有 thinking 格式,
6
+ // 且多轮(尤其工具调用)必须保留 reasoning_content。
7
+ const DEEPSEEK_COMPAT = {
8
+ ...OPENAI_COMPLETIONS_COMPAT,
9
+ thinkingFormat: "deepseek" as const,
10
+ requiresReasoningContentOnAssistantMessages: true,
11
+ };
12
+
13
+ /**
14
+ * DeepSeek(深度求索)V4 系列。
15
+ * 官方文档:https://api-docs.deepseek.com/
16
+ */
17
+ export function deepseekModels(root: string): ProviderModelConfig[] {
18
+ const v1 = `${root}/v1`;
19
+ return [
20
+ {
21
+ id: "deepseek-v4-flash",
22
+ name: "DeepSeek V4 Flash",
23
+ api: "openai-completions",
24
+ baseUrl: v1,
25
+ reasoning: true,
26
+ input: ["text"],
27
+ cost: { input: 0.1475, output: 0.295, cacheRead: 0.00295, cacheWrite: 0 },
28
+ contextWindow: 1000000,
29
+ maxTokens: 384000,
30
+ compat: DEEPSEEK_COMPAT,
31
+ thinkingLevelMap: {
32
+ minimal: null,
33
+ low: null,
34
+ medium: null,
35
+ high: "high",
36
+ xhigh: "max",
37
+ max: "max",
38
+ },
39
+ },
40
+ {
41
+ id: "deepseek-v4-pro",
42
+ name: "DeepSeek V4 Pro",
43
+ api: "openai-completions",
44
+ baseUrl: v1,
45
+ reasoning: true,
46
+ input: ["text"],
47
+ cost: {
48
+ input: 0.4425,
49
+ output: 0.885,
50
+ cacheRead: 0.0036875,
51
+ cacheWrite: 0,
52
+ },
53
+ contextWindow: 1000000,
54
+ maxTokens: 384000,
55
+ compat: DEEPSEEK_COMPAT,
56
+ thinkingLevelMap: {
57
+ minimal: null,
58
+ low: null,
59
+ medium: null,
60
+ high: "high",
61
+ xhigh: "max",
62
+ max: "max",
63
+ },
64
+ },
65
+ ];
66
+ }
67
+
68
+ // DeepSeek 思维链:`thinking.type` + `reasoning_effort`(high/max 两档)。
69
+ function applyDeepSeek(writer: PayloadWriter, level: ThinkingLevel): void {
70
+ writer.remove("reasoning_effort");
71
+ if (level === "off") {
72
+ writer.setThinking({ type: "disabled" });
73
+ return;
74
+ }
75
+ writer.setThinking({ type: "enabled" });
76
+ writer.set("reasoning_effort", isMaximum(level) ? "max" : "high");
77
+ }
78
+
79
+ export const deepseekThinking: Record<string, ThinkingApplier> = {
80
+ "deepseek-v4-flash": (w, c) => applyDeepSeek(w, c.thinkingLevel),
81
+ "deepseek-v4-pro": (w, c) => applyDeepSeek(w, c.thinkingLevel),
82
+ };
@@ -0,0 +1,148 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import { isAtLeastHigh, type PayloadWriter, type ThinkingApplier, type ThinkingLevel } from "../_tools.ts";
3
+
4
+ /**
5
+ * Google Gemini 系列(google-generative-ai 协议)。
6
+ * 官方文档:https://ai.google.dev/gemini-api/docs
7
+ */
8
+ export function geminiModels(root: string): ProviderModelConfig[] {
9
+ const gemini = `${root}/gemini`;
10
+ return [
11
+ {
12
+ id: "gemini-flash",
13
+ name: "Gemini 3 Flash",
14
+ api: "google-generative-ai",
15
+ baseUrl: gemini,
16
+ reasoning: true,
17
+ input: ["text", "image"],
18
+ cost: { input: 0.3, output: 2.5, cacheRead: 0.03, cacheWrite: 0 },
19
+ contextWindow: 1048576,
20
+ maxTokens: 65536,
21
+ },
22
+ {
23
+ id: "gemini-pro",
24
+ name: "Gemini 3.1 Pro",
25
+ api: "google-generative-ai",
26
+ baseUrl: gemini,
27
+ reasoning: true,
28
+ input: ["text", "image"],
29
+ cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 },
30
+ contextWindow: 1048576,
31
+ maxTokens: 65536,
32
+ },
33
+ {
34
+ id: "gemini-3.5-flash",
35
+ name: "Gemini 3.5 Flash",
36
+ api: "google-generative-ai",
37
+ baseUrl: gemini,
38
+ reasoning: true,
39
+ input: ["text", "image"],
40
+ // 官方缓存存储按小时计费,无法映射为单价,置 0。
41
+ cost: { input: 1.5, output: 9, cacheRead: 0.15, cacheWrite: 0 },
42
+ contextWindow: 1048576,
43
+ maxTokens: 65536,
44
+ },
45
+ {
46
+ id: "gemini-3.5-flash-low",
47
+ name: "Gemini 3.5 Flash",
48
+ api: "google-generative-ai",
49
+ baseUrl: gemini,
50
+ reasoning: true,
51
+ input: ["text", "image"],
52
+ // 网关思考档位别名,规格继承 gemini-3.5-flash。
53
+ cost: { input: 1.5, output: 9, cacheRead: 0.15, cacheWrite: 0 },
54
+ contextWindow: 1048576,
55
+ maxTokens: 65536,
56
+ },
57
+ {
58
+ id: "gemini-3.5-flash-extra-low",
59
+ name: "Gemini 3.5 Flash",
60
+ api: "google-generative-ai",
61
+ baseUrl: gemini,
62
+ reasoning: true,
63
+ input: ["text", "image"],
64
+ // 网关思考档位别名,规格继承 gemini-3.5-flash。
65
+ cost: { input: 1.5, output: 9, cacheRead: 0.15, cacheWrite: 0 },
66
+ contextWindow: 1048576,
67
+ maxTokens: 65536,
68
+ },
69
+ {
70
+ id: "gemini-3.1-pro-low",
71
+ name: "Gemini 3.1 Pro Preview",
72
+ api: "google-generative-ai",
73
+ baseUrl: gemini,
74
+ reasoning: true,
75
+ input: ["text", "image"],
76
+ // 网关思考档位别名(low),规格继承 gemini-3.1-pro-preview。
77
+ cost: { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 0 },
78
+ contextWindow: 1048576,
79
+ maxTokens: 65536,
80
+ },
81
+ {
82
+ id: "gemini-2.5-pro",
83
+ name: "Gemini 2.5 Pro",
84
+ api: "google-generative-ai",
85
+ baseUrl: gemini,
86
+ reasoning: true,
87
+ input: ["text", "image"],
88
+ cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 },
89
+ contextWindow: 1048576,
90
+ maxTokens: 65536,
91
+ },
92
+ {
93
+ id: "gemini-2.5-flash",
94
+ name: "Gemini 2.5 Flash",
95
+ api: "google-generative-ai",
96
+ baseUrl: gemini,
97
+ reasoning: true,
98
+ input: ["text", "image"],
99
+ cost: { input: 0.3, output: 2.5, cacheRead: 0.03, cacheWrite: 0 },
100
+ contextWindow: 1048576,
101
+ maxTokens: 65536,
102
+ },
103
+ {
104
+ id: "gemini-2.5-flash-lite",
105
+ name: "Gemini 2.5 Flash-Lite",
106
+ api: "google-generative-ai",
107
+ baseUrl: gemini,
108
+ reasoning: true,
109
+ input: ["text", "image"],
110
+ cost: { input: 0.1, output: 0.4, cacheRead: 0.01, cacheWrite: 0 },
111
+ contextWindow: 1048576,
112
+ maxTokens: 65536,
113
+ },
114
+ ];
115
+ }
116
+
117
+ // Gemini 思维链:`config.thinkingConfig`(includeThoughts/thinkingLevel/thinkingBudget)。
118
+ function applyGeminiFlash(writer: PayloadWriter, level: ThinkingLevel): void {
119
+ writer.remove("reasoning_effort");
120
+ if (level === "off") {
121
+ writer.setGoogleThinking({ includeThoughts: false, thinkingBudget: 0 }, ["thinkingLevel"]);
122
+ return;
123
+ }
124
+ const budget = level === "max" ? 24576 : 16000;
125
+ writer.setGoogleThinking({ includeThoughts: true, thinkingBudget: budget }, ["thinkingLevel"]);
126
+ }
127
+
128
+ function applyGeminiPro(writer: PayloadWriter, level: ThinkingLevel): void {
129
+ writer.remove("reasoning_effort");
130
+ const thinkingLevel = level === "off" || level === "minimal" || level === "low"
131
+ ? "LOW"
132
+ : level === "medium"
133
+ ? "MEDIUM"
134
+ : "HIGH";
135
+ writer.setGoogleThinking({ includeThoughts: level !== "off", thinkingLevel }, ["thinkingBudget"]);
136
+ }
137
+
138
+ export const geminiThinking: Record<string, ThinkingApplier> = {
139
+ "gemini-flash": (w, c) => applyGeminiFlash(w, c.thinkingLevel),
140
+ "gemini-3.5-flash": (w, c) => applyGeminiFlash(w, c.thinkingLevel),
141
+ "gemini-3.5-flash-low": (w, c) => applyGeminiFlash(w, c.thinkingLevel),
142
+ "gemini-3.5-flash-extra-low": (w, c) => applyGeminiFlash(w, c.thinkingLevel),
143
+ "gemini-2.5-flash": (w, c) => applyGeminiFlash(w, c.thinkingLevel),
144
+ "gemini-2.5-flash-lite": (w, c) => applyGeminiFlash(w, c.thinkingLevel),
145
+ "gemini-pro": (w, c) => applyGeminiPro(w, c.thinkingLevel),
146
+ "gemini-3.1-pro-low": (w, c) => applyGeminiPro(w, c.thinkingLevel),
147
+ "gemini-2.5-pro": (w, c) => applyGeminiPro(w, c.thinkingLevel),
148
+ };
@@ -0,0 +1,157 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import { OPENAI_COMPLETIONS_COMPAT } from "./_protocols.ts";
3
+ import { isMaximum, type PayloadWriter, type ThinkingApplier, type ThinkingLevel } from "../_tools.ts";
4
+
5
+ /**
6
+ * 智谱 AI(Zhipu)GLM 系列。
7
+ * 官方文档:https://open.bigmodel.cn/(国际站 docs.z.ai)
8
+ */
9
+ export function glmModels(root: string): ProviderModelConfig[] {
10
+ const v1 = `${root}/v1`;
11
+ return [
12
+ {
13
+ id: "glm-5.2",
14
+ name: "GLM 5.2",
15
+ api: "openai-completions",
16
+ baseUrl: v1,
17
+ reasoning: true,
18
+ thinkingLevelMap: {
19
+ low: "low",
20
+ medium: "medium",
21
+ high: "high",
22
+ xhigh: "xhigh",
23
+ max: "max",
24
+ },
25
+ input: ["text"],
26
+ cost: { input: 1.18, output: 4.13, cacheRead: 0.295, cacheWrite: 0 },
27
+ contextWindow: 1000000,
28
+ maxTokens: 131072,
29
+ compat: OPENAI_COMPLETIONS_COMPAT,
30
+ },
31
+ {
32
+ id: "glm-5.1",
33
+ name: "GLM 5.1",
34
+ api: "openai-completions",
35
+ baseUrl: v1,
36
+ reasoning: true,
37
+ input: ["text"],
38
+ cost: { input: 0.885, output: 3.54, cacheRead: 0.19175, cacheWrite: 0 },
39
+ contextWindow: 200000,
40
+ maxTokens: 65536,
41
+ compat: OPENAI_COMPLETIONS_COMPAT,
42
+ },
43
+ {
44
+ id: "glm-5",
45
+ name: "GLM-5",
46
+ api: "openai-completions",
47
+ baseUrl: v1,
48
+ reasoning: true,
49
+ thinkingLevelMap: {
50
+ low: "low",
51
+ medium: "medium",
52
+ high: "high",
53
+ xhigh: "xhigh",
54
+ max: "max",
55
+ },
56
+ input: ["text"],
57
+ cost: { input: 1, output: 3.2, cacheRead: 0.2, cacheWrite: 0 },
58
+ contextWindow: 200000,
59
+ maxTokens: 131072,
60
+ compat: OPENAI_COMPLETIONS_COMPAT,
61
+ },
62
+ {
63
+ id: "glm-5-turbo",
64
+ name: "GLM-5-Turbo",
65
+ api: "openai-completions",
66
+ baseUrl: v1,
67
+ reasoning: true,
68
+ thinkingLevelMap: {
69
+ low: "low",
70
+ medium: "medium",
71
+ high: "high",
72
+ xhigh: "xhigh",
73
+ max: "max",
74
+ },
75
+ input: ["text"],
76
+ cost: { input: 1.2, output: 4, cacheRead: 0.24, cacheWrite: 0 },
77
+ contextWindow: 200000,
78
+ maxTokens: 131072,
79
+ compat: OPENAI_COMPLETIONS_COMPAT,
80
+ },
81
+ {
82
+ id: "glm-4.7",
83
+ name: "GLM-4.7",
84
+ api: "openai-completions",
85
+ baseUrl: v1,
86
+ reasoning: true,
87
+ input: ["text"],
88
+ cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
89
+ contextWindow: 200000,
90
+ maxTokens: 131072,
91
+ compat: OPENAI_COMPLETIONS_COMPAT,
92
+ },
93
+ {
94
+ id: "glm-4.6",
95
+ name: "GLM-4.6",
96
+ api: "openai-completions",
97
+ baseUrl: v1,
98
+ reasoning: true,
99
+ input: ["text"],
100
+ cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
101
+ contextWindow: 200000,
102
+ maxTokens: 131072,
103
+ compat: OPENAI_COMPLETIONS_COMPAT,
104
+ },
105
+ {
106
+ id: "glm-4.5",
107
+ name: "GLM-4.5",
108
+ api: "openai-completions",
109
+ baseUrl: v1,
110
+ reasoning: true,
111
+ input: ["text"],
112
+ cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
113
+ contextWindow: 128000,
114
+ maxTokens: 98304,
115
+ compat: OPENAI_COMPLETIONS_COMPAT,
116
+ },
117
+ {
118
+ id: "glm-4.5-air",
119
+ name: "GLM-4.5-Air",
120
+ api: "openai-completions",
121
+ baseUrl: v1,
122
+ reasoning: true,
123
+ input: ["text"],
124
+ cost: { input: 0.2, output: 1.1, cacheRead: 0.03, cacheWrite: 0 },
125
+ contextWindow: 128000,
126
+ maxTokens: 98304,
127
+ compat: OPENAI_COMPLETIONS_COMPAT,
128
+ },
129
+ ];
130
+ }
131
+
132
+ // GLM 思维链:`tool_stream=true` 仅在流式请求时附加;高级档位加 `clear_thinking=false`。
133
+ function applyGlm(writer: PayloadWriter, level: ThinkingLevel): void {
134
+ if (writer.get("stream") === true) writer.set("tool_stream", true);
135
+ if (level === "off") {
136
+ writer.setThinking({ type: "disabled" });
137
+ writer.set("reasoning_effort", "none");
138
+ return;
139
+ }
140
+
141
+ writer.setThinking({ type: "enabled" });
142
+ if (level === "high" || isMaximum(level)) {
143
+ writer.setThinking({ clear_thinking: false });
144
+ writer.set("reasoning_effort", isMaximum(level) ? "max" : "high");
145
+ }
146
+ }
147
+
148
+ export const glmThinking: Record<string, ThinkingApplier> = {
149
+ "glm-5.2": (w, c) => applyGlm(w, c.thinkingLevel),
150
+ "glm-5.1": (w, c) => applyGlm(w, c.thinkingLevel),
151
+ "glm-5": (w, c) => applyGlm(w, c.thinkingLevel),
152
+ "glm-5-turbo": (w, c) => applyGlm(w, c.thinkingLevel),
153
+ "glm-4.7": (w, c) => applyGlm(w, c.thinkingLevel),
154
+ "glm-4.6": (w, c) => applyGlm(w, c.thinkingLevel),
155
+ "glm-4.5": (w, c) => applyGlm(w, c.thinkingLevel),
156
+ "glm-4.5-air": (w, c) => applyGlm(w, c.thinkingLevel),
157
+ };
@@ -0,0 +1,124 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import { OPENAI_COMPLETIONS_COMPAT } from "./_protocols.ts";
3
+ import { applyEnabledThinking, type PayloadWriter, type ThinkingApplier, type ThinkingLevel } from "../_tools.ts";
4
+
5
+ /**
6
+ * 月之暗面(Moonshot)Kimi 系列。
7
+ * 官方文档:https://platform.moonshot.cn/docs
8
+ */
9
+ export function kimiModels(root: string): ProviderModelConfig[] {
10
+ const v1 = `${root}/v1`;
11
+ return [
12
+ {
13
+ id: "kimi-for-coding",
14
+ name: "Kimi K2.7 Code",
15
+ api: "openai-completions",
16
+ baseUrl: v1,
17
+ reasoning: true,
18
+ input: ["text", "image"],
19
+ cost: {
20
+ input: 0.95875,
21
+ output: 3.9825,
22
+ cacheRead: 0.19175,
23
+ cacheWrite: 0,
24
+ },
25
+ contextWindow: 262144,
26
+ maxTokens: 32768,
27
+ compat: OPENAI_COMPLETIONS_COMPAT,
28
+ },
29
+ {
30
+ id: "kimi-k3",
31
+ name: "Kimi K3",
32
+ api: "openai-completions",
33
+ baseUrl: v1,
34
+ reasoning: true,
35
+ thinkingLevelMap: {
36
+ low: "low",
37
+ medium: "medium",
38
+ high: "high",
39
+ xhigh: "xhigh",
40
+ max: "max",
41
+ },
42
+ input: ["text", "image"],
43
+ cost: { input: 3, output: 15, cacheRead: 2, cacheWrite: 0 },
44
+ contextWindow: 1000000,
45
+ maxTokens: 131072,
46
+ compat: OPENAI_COMPLETIONS_COMPAT,
47
+ },
48
+ {
49
+ id: "kimi-k2.7-code",
50
+ name: "Kimi K2.7 Code",
51
+ api: "openai-completions",
52
+ baseUrl: v1,
53
+ reasoning: true,
54
+ input: ["text", "image"],
55
+ cost: { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 },
56
+ contextWindow: 262144,
57
+ // 官方未公布最大输出上限,保守取上下文窗口。
58
+ maxTokens: 262144,
59
+ compat: OPENAI_COMPLETIONS_COMPAT,
60
+ },
61
+ {
62
+ id: "kimi-k2.7-code-highspeed",
63
+ name: "Kimi K2.7 Code HighSpeed",
64
+ api: "openai-completions",
65
+ baseUrl: v1,
66
+ reasoning: true,
67
+ input: ["text", "image"],
68
+ cost: { input: 1.9, output: 8, cacheRead: 0.38, cacheWrite: 0 },
69
+ contextWindow: 262144,
70
+ // 官方未公布最大输出上限,保守取上下文窗口。
71
+ maxTokens: 262144,
72
+ compat: OPENAI_COMPLETIONS_COMPAT,
73
+ },
74
+ {
75
+ id: "kimi-k2.6",
76
+ name: "Kimi K2.6",
77
+ api: "openai-completions",
78
+ baseUrl: v1,
79
+ reasoning: true,
80
+ input: ["text", "image"],
81
+ cost: { input: 0.95, output: 4, cacheRead: 0.16, cacheWrite: 0 },
82
+ contextWindow: 262144,
83
+ // 官方未公布最大输出上限,保守取上下文窗口。
84
+ maxTokens: 262144,
85
+ compat: OPENAI_COMPLETIONS_COMPAT,
86
+ },
87
+ {
88
+ id: "kimi-k2.5",
89
+ name: "Kimi K2.5",
90
+ api: "openai-completions",
91
+ baseUrl: v1,
92
+ reasoning: true,
93
+ input: ["text", "image"],
94
+ cost: { input: 0.6, output: 3, cacheRead: 0.1, cacheWrite: 0 },
95
+ contextWindow: 262144,
96
+ // 官方未公布最大输出上限,保守取上下文窗口。
97
+ maxTokens: 262144,
98
+ compat: OPENAI_COMPLETIONS_COMPAT,
99
+ },
100
+ ];
101
+ }
102
+
103
+ // Kimi K3 思维链:移除 `thinking` 字段,改用 `reasoning_effort` 表达深度。
104
+ function applyKimiK3(writer: PayloadWriter, level: ThinkingLevel): void {
105
+ writer.remove("thinking");
106
+ if (level === "off") {
107
+ writer.remove("reasoning_effort");
108
+ return;
109
+ }
110
+ if (level === "minimal" || level === "low") {
111
+ writer.set("reasoning_effort", "low");
112
+ return;
113
+ }
114
+ writer.set("reasoning_effort", level === "max" ? "max" : "high");
115
+ }
116
+
117
+ export const kimiThinking: Record<string, ThinkingApplier> = {
118
+ "kimi-for-coding": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
119
+ "kimi-k3": (w, c) => applyKimiK3(w, c.thinkingLevel),
120
+ "kimi-k2.7-code": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
121
+ "kimi-k2.7-code-highspeed": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
122
+ "kimi-k2.6": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
123
+ "kimi-k2.5": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
124
+ };
@@ -0,0 +1,30 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import { OPENAI_COMPLETIONS_COMPAT } from "./_protocols.ts";
3
+ import { applyEnabledThinking, type ThinkingApplier } from "../_tools.ts";
4
+
5
+ /**
6
+ * LongCat 2.0(龙猫)。
7
+ * 官方文档:https://longcat.chat/platform/docs/zh/
8
+ */
9
+ export function longcatModels(root: string): ProviderModelConfig[] {
10
+ const v1 = `${root}/v1`;
11
+ return [
12
+ {
13
+ id: "longcat-2.0",
14
+ name: "LongCat-2.0",
15
+ api: "openai-completions",
16
+ baseUrl: v1,
17
+ reasoning: true,
18
+ input: ["text"],
19
+ cost: { input: 0.295, output: 1.18, cacheRead: 0.0059, cacheWrite: 0 },
20
+ contextWindow: 1000000,
21
+ maxTokens: 131072,
22
+ compat: OPENAI_COMPLETIONS_COMPAT,
23
+ },
24
+ ];
25
+ }
26
+
27
+ // OC/网关兼容策略:LongCat 的公开 HTTP thinking schema 未验证,用通用开关式。
28
+ export const longcatThinking: Record<string, ThinkingApplier> = {
29
+ "longcat-2.0": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
30
+ };
@@ -0,0 +1,47 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import { OPENAI_COMPLETIONS_COMPAT } from "./_protocols.ts";
3
+ import { applyEnabledThinking, type ThinkingApplier } from "../_tools.ts";
4
+
5
+ /**
6
+ * 小米(Xiaomi)MiMo 系列。
7
+ * 官方文档:https://platform.xiaomimimo.com/docs/
8
+ */
9
+ export function mimoModels(root: string): ProviderModelConfig[] {
10
+ const v1 = `${root}/v1`;
11
+ return [
12
+ {
13
+ id: "mimo-v2.5-pro",
14
+ name: "MiMo V2.5 Pro",
15
+ api: "openai-completions",
16
+ baseUrl: v1,
17
+ reasoning: true,
18
+ input: ["text"],
19
+ cost: {
20
+ input: 0.4425,
21
+ output: 0.885,
22
+ cacheRead: 0.0036875,
23
+ cacheWrite: 0,
24
+ },
25
+ contextWindow: 1000000,
26
+ maxTokens: 131072,
27
+ compat: OPENAI_COMPLETIONS_COMPAT,
28
+ },
29
+ {
30
+ id: "mimo-v2.5",
31
+ name: "MiMo V2.5",
32
+ api: "openai-completions",
33
+ baseUrl: v1,
34
+ reasoning: true,
35
+ input: ["text", "image"],
36
+ cost: { input: 0.1475, output: 0.295, cacheRead: 0.00295, cacheWrite: 0 },
37
+ contextWindow: 1000000,
38
+ maxTokens: 131072,
39
+ compat: OPENAI_COMPLETIONS_COMPAT,
40
+ },
41
+ ];
42
+ }
43
+
44
+ export const mimoThinking: Record<string, ThinkingApplier> = {
45
+ "mimo-v2.5-pro": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
46
+ "mimo-v2.5": (w, c) => applyEnabledThinking(w, c.thinkingLevel),
47
+ };
@@ -0,0 +1,84 @@
1
+ import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
2
+ import { OPENAI_COMPLETIONS_COMPAT } from "./_protocols.ts";
3
+ import { type PayloadWriter, type ThinkingApplier, type ThinkingLevel } from "../_tools.ts";
4
+
5
+ /**
6
+ * MiniMax 系列。
7
+ * 官方文档:https://platform.minimaxi.com/(国际站 platform.minimax.io)
8
+ */
9
+ export function minimaxModels(root: string): ProviderModelConfig[] {
10
+ const v1 = `${root}/v1`;
11
+ return [
12
+ {
13
+ id: "minimax-m3",
14
+ name: "Minimax M3",
15
+ api: "openai-completions",
16
+ baseUrl: v1,
17
+ reasoning: true,
18
+ input: ["text", "image"],
19
+ cost: {
20
+ input: 0.30975,
21
+ output: 1.239,
22
+ cacheRead: 0.06195,
23
+ cacheWrite: 0,
24
+ },
25
+ contextWindow: 1000000,
26
+ maxTokens: 500000,
27
+ compat: OPENAI_COMPLETIONS_COMPAT,
28
+ },
29
+ {
30
+ id: "minimax-m2.7",
31
+ name: "MiniMax-M2.7",
32
+ api: "openai-completions",
33
+ baseUrl: v1,
34
+ reasoning: true,
35
+ input: ["text"],
36
+ cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0.375 },
37
+ contextWindow: 204800,
38
+ // 官方未公布最大输出上限,保守取上下文窗口。
39
+ maxTokens: 204800,
40
+ compat: OPENAI_COMPLETIONS_COMPAT,
41
+ },
42
+ {
43
+ id: "minimax-m2.5",
44
+ name: "MiniMax-M2.5",
45
+ api: "openai-completions",
46
+ baseUrl: v1,
47
+ reasoning: true,
48
+ input: ["text"],
49
+ cost: { input: 0.3, output: 1.2, cacheRead: 0.03, cacheWrite: 0.375 },
50
+ contextWindow: 204800,
51
+ // 官方未公布最大输出上限,保守取上下文窗口。
52
+ maxTokens: 204800,
53
+ compat: OPENAI_COMPLETIONS_COMPAT,
54
+ },
55
+ {
56
+ id: "minimax-m2.1",
57
+ name: "MiniMax-M2.1",
58
+ api: "openai-completions",
59
+ baseUrl: v1,
60
+ reasoning: true,
61
+ input: ["text"],
62
+ cost: { input: 0.3, output: 1.2, cacheRead: 0.03, cacheWrite: 0.375 },
63
+ contextWindow: 204800,
64
+ // 官方未公布最大输出上限,保守取上下文窗口。
65
+ maxTokens: 204800,
66
+ compat: OPENAI_COMPLETIONS_COMPAT,
67
+ },
68
+ ];
69
+ }
70
+
71
+ // MiniMax 思维链:`reasoning_split=true`,档位映射 disabled/adaptive。
72
+ // M2.x 沿用 M3 策略(同族,未逐一验证)。
73
+ function applyMiniMax(writer: PayloadWriter, level: ThinkingLevel): void {
74
+ writer.remove("reasoning_effort");
75
+ writer.set("reasoning_split", true);
76
+ writer.setThinking({ type: level === "off" ? "disabled" : "adaptive" });
77
+ }
78
+
79
+ export const minimaxThinking: Record<string, ThinkingApplier> = {
80
+ "minimax-m3": (w, c) => applyMiniMax(w, c.thinkingLevel),
81
+ "minimax-m2.7": (w, c) => applyMiniMax(w, c.thinkingLevel),
82
+ "minimax-m2.5": (w, c) => applyMiniMax(w, c.thinkingLevel),
83
+ "minimax-m2.1": (w, c) => applyMiniMax(w, c.thinkingLevel),
84
+ };