forked from BlockRunAI/ClawRouter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.ts
More file actions
320 lines (306 loc) · 6.56 KB
/
models.ts
File metadata and controls
320 lines (306 loc) · 6.56 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
/**
* BlockRun Model Definitions for OpenClaw
*
* Maps BlockRun's 30+ AI models to OpenClaw's ModelDefinitionConfig format.
* All models use the "openai-completions" API since BlockRun is OpenAI-compatible.
*
* Pricing is in USD per 1M tokens. Operators pay these rates via x402;
* they set their own markup when reselling to end users (Phase 2).
*/
import type { ModelDefinitionConfig, ModelProviderConfig } from "./types.js";
type BlockRunModel = {
id: string;
name: string;
inputPrice: number;
outputPrice: number;
contextWindow: number;
maxOutput: number;
reasoning?: boolean;
vision?: boolean;
};
export const BLOCKRUN_MODELS: BlockRunModel[] = [
// Smart routing meta-model — proxy replaces with actual model
// NOTE: Model IDs are WITHOUT provider prefix (OpenClaw adds "blockrun/" automatically)
{
id: "auto",
name: "BlockRun Smart Router",
inputPrice: 0,
outputPrice: 0,
contextWindow: 1_050_000,
maxOutput: 128_000,
},
// OpenAI GPT-5 Family
{
id: "openai/gpt-5.2",
name: "GPT-5.2",
inputPrice: 1.75,
outputPrice: 14.0,
contextWindow: 400000,
maxOutput: 128000,
reasoning: true,
vision: true,
},
{
id: "openai/gpt-5-mini",
name: "GPT-5 Mini",
inputPrice: 0.25,
outputPrice: 2.0,
contextWindow: 200000,
maxOutput: 65536,
},
{
id: "openai/gpt-5-nano",
name: "GPT-5 Nano",
inputPrice: 0.05,
outputPrice: 0.4,
contextWindow: 128000,
maxOutput: 32768,
},
{
id: "openai/gpt-5.2-pro",
name: "GPT-5.2 Pro",
inputPrice: 21.0,
outputPrice: 168.0,
contextWindow: 400000,
maxOutput: 128000,
reasoning: true,
},
// OpenAI GPT-4 Family
{
id: "openai/gpt-4.1",
name: "GPT-4.1",
inputPrice: 2.0,
outputPrice: 8.0,
contextWindow: 128000,
maxOutput: 16384,
vision: true,
},
{
id: "openai/gpt-4.1-mini",
name: "GPT-4.1 Mini",
inputPrice: 0.4,
outputPrice: 1.6,
contextWindow: 128000,
maxOutput: 16384,
},
{
id: "openai/gpt-4.1-nano",
name: "GPT-4.1 Nano",
inputPrice: 0.1,
outputPrice: 0.4,
contextWindow: 128000,
maxOutput: 16384,
},
{
id: "openai/gpt-4o",
name: "GPT-4o",
inputPrice: 2.5,
outputPrice: 10.0,
contextWindow: 128000,
maxOutput: 16384,
vision: true,
},
{
id: "openai/gpt-4o-mini",
name: "GPT-4o Mini",
inputPrice: 0.15,
outputPrice: 0.6,
contextWindow: 128000,
maxOutput: 16384,
},
// OpenAI O-series (Reasoning)
{
id: "openai/o1",
name: "o1",
inputPrice: 15.0,
outputPrice: 60.0,
contextWindow: 200000,
maxOutput: 100000,
reasoning: true,
},
{
id: "openai/o1-mini",
name: "o1-mini",
inputPrice: 1.1,
outputPrice: 4.4,
contextWindow: 128000,
maxOutput: 65536,
reasoning: true,
},
{
id: "openai/o3",
name: "o3",
inputPrice: 2.0,
outputPrice: 8.0,
contextWindow: 200000,
maxOutput: 100000,
reasoning: true,
},
{
id: "openai/o3-mini",
name: "o3-mini",
inputPrice: 1.1,
outputPrice: 4.4,
contextWindow: 128000,
maxOutput: 65536,
reasoning: true,
},
// o4-mini: Placeholder removed - model not yet released by OpenAI
// Anthropic
{
id: "anthropic/claude-haiku-4.5",
name: "Claude Haiku 4.5",
inputPrice: 1.0,
outputPrice: 5.0,
contextWindow: 200000,
maxOutput: 8192,
},
{
id: "anthropic/claude-sonnet-4",
name: "Claude Sonnet 4",
inputPrice: 3.0,
outputPrice: 15.0,
contextWindow: 200000,
maxOutput: 64000,
reasoning: true,
},
{
id: "anthropic/claude-opus-4",
name: "Claude Opus 4",
inputPrice: 15.0,
outputPrice: 75.0,
contextWindow: 200000,
maxOutput: 32000,
reasoning: true,
},
{
id: "anthropic/claude-opus-4.5",
name: "Claude Opus 4.5",
inputPrice: 5.0,
outputPrice: 25.0,
contextWindow: 200000,
maxOutput: 32000,
reasoning: true,
},
// Google
{
id: "google/gemini-3-pro-preview",
name: "Gemini 3 Pro Preview",
inputPrice: 2.0,
outputPrice: 12.0,
contextWindow: 1050000,
maxOutput: 65536,
reasoning: true,
vision: true,
},
{
id: "google/gemini-2.5-pro",
name: "Gemini 2.5 Pro",
inputPrice: 1.25,
outputPrice: 10.0,
contextWindow: 1050000,
maxOutput: 65536,
reasoning: true,
vision: true,
},
{
id: "google/gemini-2.5-flash",
name: "Gemini 2.5 Flash",
inputPrice: 0.15,
outputPrice: 0.6,
contextWindow: 1000000,
maxOutput: 65536,
},
// DeepSeek
{
id: "deepseek/deepseek-chat",
name: "DeepSeek V3.2 Chat",
inputPrice: 0.28,
outputPrice: 0.42,
contextWindow: 128000,
maxOutput: 8192,
},
{
id: "deepseek/deepseek-reasoner",
name: "DeepSeek V3.2 Reasoner",
inputPrice: 0.28,
outputPrice: 0.42,
contextWindow: 128000,
maxOutput: 8192,
reasoning: true,
},
// Moonshot / Kimi
{
id: "moonshot/kimi-k2.5",
name: "Kimi K2.5",
inputPrice: 0.5,
outputPrice: 2.4,
contextWindow: 262144,
maxOutput: 8192,
reasoning: true,
vision: true,
},
// xAI / Grok
{
id: "xai/grok-3",
name: "Grok 3",
inputPrice: 3.0,
outputPrice: 15.0,
contextWindow: 131072,
maxOutput: 16384,
reasoning: true,
},
{
id: "xai/grok-3-fast",
name: "Grok 3 Fast",
inputPrice: 5.0,
outputPrice: 25.0,
contextWindow: 131072,
maxOutput: 16384,
reasoning: true,
},
{
id: "xai/grok-3-mini",
name: "Grok 3 Mini",
inputPrice: 0.3,
outputPrice: 0.5,
contextWindow: 131072,
maxOutput: 16384,
},
];
/**
* Convert BlockRun model definitions to OpenClaw ModelDefinitionConfig format.
*/
function toOpenClawModel(m: BlockRunModel): ModelDefinitionConfig {
return {
id: m.id,
name: m.name,
api: "openai-completions",
reasoning: m.reasoning ?? false,
input: m.vision ? ["text", "image"] : ["text"],
cost: {
input: m.inputPrice,
output: m.outputPrice,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: m.contextWindow,
maxTokens: m.maxOutput,
};
}
/**
* All BlockRun models in OpenClaw format.
*/
export const OPENCLAW_MODELS: ModelDefinitionConfig[] = BLOCKRUN_MODELS.map(toOpenClawModel);
/**
* Build a ModelProviderConfig for BlockRun.
*
* @param baseUrl - The proxy's local base URL (e.g., "http://127.0.0.1:12345")
*/
export function buildProviderModels(baseUrl: string): ModelProviderConfig {
return {
baseUrl: `${baseUrl}/v1`,
api: "openai-completions",
models: OPENCLAW_MODELS,
};
}