modelmix 5.1.1 → 5.1.4
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.
- package/README.md +8 -2
- package/demo/free.js +2 -3
- package/demo/short.js +4 -2
- package/effort.js +13 -4
- package/index.d.ts +2 -0
- package/index.js +517 -2843
- package/lib/content-cache.js +31 -0
- package/lib/model-chain.js +51 -0
- package/lib/object-utils.js +7 -0
- package/lib/provider-debug.js +23 -0
- package/lib/providers/anthropic.js +337 -0
- package/lib/providers/base.js +409 -0
- package/lib/providers/google.js +293 -0
- package/lib/providers/openai-compatible.js +338 -0
- package/lib/providers/openai.js +622 -0
- package/lib/providers.js +26 -0
- package/lib/template-engine.js +168 -0
- package/lib/token-usage.js +301 -0
- package/package.json +1 -1
- package/skills/modelmix/SKILL.md +4 -4
- package/test/effort.test.js +37 -0
- package/test/glm.test.js +21 -1
- package/test/model-chain.test.js +12 -0
- package/test/public-api.test.js +54 -0
- package/test/qwen.test.js +20 -0
- package/test/tokens.test.js +20 -0
package/README.md
CHANGED
|
@@ -117,9 +117,9 @@ const ETH = ModelMix.new()
|
|
|
117
117
|
console.log(ETH.price);
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
**This example uses providers with free quotas (
|
|
120
|
+
**This example uses providers with free quotas (Groq, Cerebras, and Together). OpenRouter is disabled because its GPT-OSS 120B route is no longer free. If one model runs out of quota, ModelMix automatically falls back to the next model in the chain.**
|
|
121
121
|
```javascript
|
|
122
|
-
ModelMix.new()
|
|
122
|
+
ModelMix.new({ mix: { openrouter: false } })
|
|
123
123
|
.gptOss()
|
|
124
124
|
.kimiK25()
|
|
125
125
|
.hermes3()
|
|
@@ -175,8 +175,10 @@ ModelMix provides convenient shorthand methods for quickly accessing different A
|
|
|
175
175
|
| `qwen36plus()` | Fireworks | qwen3p6-plus | [\$0.50][10] | [\$3.00][10] |
|
|
176
176
|
| `qwen37plus()` | Fireworks | models/qwen3p7-plus | [\$0.40][10] | [\$1.60][10] |
|
|
177
177
|
| `qwen38max()` | Fireworks | qwen3p8-2p4t-a95b | [\$2.00][10] | [\$6.00][10] |
|
|
178
|
+
| `qwen3827b()` | OpenRouter | qwen/qwen3.8-27b | [\$0.45][15] | [\$3.20][15] |
|
|
178
179
|
| `deepseekV4Flash()` | Fireworks | models/deepseek-v4-flash | [\$0.14][10] | [\$0.28][10] |
|
|
179
180
|
| `deepseekV4Pro()` | Fireworks | models/deepseek-v4-pro-0813 | [\$1.32][12] | [\$3.96][12] |
|
|
181
|
+
| `GLM53()` | OpenRouter | z-ai/glm-5.3 | [\$1.40][16] | [\$4.40][16] |
|
|
180
182
|
| `GLM52()` | Together | zai-org/GLM-5.2 | [\$1.40][7] | [\$4.40][7] |
|
|
181
183
|
| `GLM51()` | Fireworks | models/glm-5p1 | [\$1.05][10] | [\$3.50][10] |
|
|
182
184
|
| `minimaxM3()` | MiniMax | MiniMax-M3 | [\$0.30][9] | [\$1.20][9] |
|
|
@@ -206,6 +208,8 @@ Gemini 3.7 Flash and 3.6 Flash use Google's introductory standard pricing throug
|
|
|
206
208
|
[12]: https://fireworks.ai/models/deepseek-ai/deepseek-v4-pro-0813 "DeepSeek V4 Pro 0813 Pricing"
|
|
207
209
|
[13]: https://openrouter.ai/nousresearch "Nous Research Models on OpenRouter"
|
|
208
210
|
[14]: https://openrouter.ai/qwen/qwen3.5-397b-a17b "Qwen3.5 397B A17B on OpenRouter"
|
|
211
|
+
[15]: https://openrouter.ai/qwen/qwen3.8-27b "Qwen3.8 27B on OpenRouter"
|
|
212
|
+
[16]: https://openrouter.ai/z-ai/glm-5.3 "GLM 5.3 on OpenRouter"
|
|
209
213
|
|
|
210
214
|
Each method accepts optional `options`, `config`, and (for multi-provider methods) `mix` parameters to customize behavior.
|
|
211
215
|
|
|
@@ -246,6 +250,8 @@ ModelMix.new().effort(-1).minimaxM3().addText('...').message();
|
|
|
246
250
|
|
|
247
251
|
- **Gemini:** Gemini 3+ uses bands 0–24 / 25–49 / 50–74 / 75–100. Gemini 3.7 Flash clamps these bands to `low` / `low` / `medium` / `high`; `-1` leaves its native `medium` default unchanged. Gemini 2.5 maps 0–100 to `thinkingBudget`.
|
|
248
252
|
- **GPT-5.6:** `100` maps to `max`; 80–99 remains `xhigh`.
|
|
253
|
+
- **Qwen 3.8 27B:** 0–39 / 40–79 / 80–100 map to `low` / `medium` / `xhigh`; `-1` leaves the native `xhigh` default unchanged.
|
|
254
|
+
- **GLM 5.3:** reasoning is mandatory; 0–39 / 40–79 / 80–100 map to `low` / `high` / `max`; `-1` leaves the native `max` default unchanged.
|
|
249
255
|
- **DeepSeek:** `↑` means thinking is enabled; `off` means it is disabled.
|
|
250
256
|
- **MiniMax:** `off` maps to `thinking.disabled`; `adaptive` maps to `thinking.type=adaptive`.
|
|
251
257
|
- **Anthropic:** Claude 5, Fable, Opus 4.6+, and Sonnet 4.6+ use adaptive thinking with `output_config.effort`. Sonnet 4.5 and Haiku 4.5 use `thinking.type=enabled` with `budget_tokens`.
|
package/demo/free.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { ModelMix } from '../index.js';
|
|
2
2
|
try { process.loadEnvFile(); } catch {}
|
|
3
3
|
|
|
4
|
-
const ai = ModelMix.new({ config: { debug: 2 } })
|
|
4
|
+
const ai = ModelMix.new({ config: { debug: 2 }, mix: { openrouter: false } })
|
|
5
5
|
.gptOss()
|
|
6
6
|
.kimiK25()
|
|
7
7
|
.hermes3()
|
|
8
8
|
.addText('What is the capital of France?');
|
|
9
9
|
|
|
10
10
|
const response = await ai.message();
|
|
11
|
-
console.log('Response from
|
|
12
|
-
|
|
11
|
+
console.log('Response from a free-tier provider:', response);
|
|
13
12
|
|
package/demo/short.js
CHANGED
|
@@ -15,8 +15,10 @@ const mmix = await ModelMix.new(setup)
|
|
|
15
15
|
.gpt5nano() // (fallback 3) OpenAI gpt-5-nano
|
|
16
16
|
.grok46() // (fallback 4) Grok grok-4.6
|
|
17
17
|
.qwen35397b() // (fallback 5) OpenRouter qwen/qwen3.5-397b-a17b
|
|
18
|
-
.
|
|
19
|
-
.
|
|
18
|
+
.qwen3827b() // (fallback 6) OpenRouter qwen/qwen3.8-27b
|
|
19
|
+
.GLM53() // (fallback 7) OpenRouter z-ai/glm-5.3
|
|
20
|
+
.hermes470b() // (fallback 8) OpenRouter nousresearch/hermes-4-70b
|
|
21
|
+
.hermes4405b() // (fallback 9) OpenRouter nousresearch/hermes-4-405b
|
|
20
22
|
.addText("What's your name?");
|
|
21
23
|
|
|
22
24
|
console.log(await mmix.message());
|
package/effort.js
CHANGED
|
@@ -34,12 +34,20 @@ const GEMINI_BANDS = [
|
|
|
34
34
|
[75, 100, 'high'],
|
|
35
35
|
];
|
|
36
36
|
|
|
37
|
+
const GLM53_BANDS = [
|
|
38
|
+
[0, 39, 'low'],
|
|
39
|
+
[40, 79, 'high'],
|
|
40
|
+
[80, 100, 'max'],
|
|
41
|
+
];
|
|
42
|
+
|
|
37
43
|
/** Exact model → supported OpenAI reasoning_effort values */
|
|
38
44
|
const OPENAI_MODEL_LEVELS = {
|
|
39
45
|
'gpt-5.6-sol': ['none', 'low', 'medium', 'high', 'xhigh', 'max'],
|
|
40
46
|
'gpt-5.6-terra': ['none', 'low', 'medium', 'high', 'xhigh', 'max'],
|
|
41
47
|
'gpt-5.6-luna': ['none', 'low', 'medium', 'high', 'xhigh', 'max'],
|
|
42
48
|
'accounts/fireworks/models/qwen3p8-2p4t-a95b': ['none', 'low', 'medium', 'high'],
|
|
49
|
+
'qwen/qwen3.8-27b': ['low', 'medium', 'xhigh'],
|
|
50
|
+
'z-ai/glm-5.3': ['low', 'high', 'max'],
|
|
43
51
|
'grok-4.6': ['low', 'medium', 'high', 'xhigh'],
|
|
44
52
|
'gpt-5': ['minimal', 'low', 'medium', 'high'],
|
|
45
53
|
'gpt-5-mini': ['minimal', 'low', 'medium', 'high'],
|
|
@@ -47,7 +55,6 @@ const OPENAI_MODEL_LEVELS = {
|
|
|
47
55
|
'gpt-5.3-codex': ['low', 'medium', 'high', 'xhigh'],
|
|
48
56
|
'gpt-oss-120b': ['low', 'medium', 'high'],
|
|
49
57
|
'openai/gpt-oss-120b': ['low', 'medium', 'high'],
|
|
50
|
-
'openai/gpt-oss-120b:free': ['low', 'medium', 'high'],
|
|
51
58
|
};
|
|
52
59
|
|
|
53
60
|
/**
|
|
@@ -378,9 +385,11 @@ function mapEffort(providerFamily, effort, modelKey) {
|
|
|
378
385
|
return null;
|
|
379
386
|
}
|
|
380
387
|
const supported = supportedOpenAILevels(modelKey);
|
|
381
|
-
const desired =
|
|
382
|
-
?
|
|
383
|
-
:
|
|
388
|
+
const desired = modelKey === 'z-ai/glm-5.3'
|
|
389
|
+
? levelFromBands(normalized, GLM53_BANDS)
|
|
390
|
+
: normalized === 100 && supported.includes('max')
|
|
391
|
+
? 'max'
|
|
392
|
+
: levelFromBands(normalized, OPENAI_BANDS);
|
|
384
393
|
const level = pickNearestLevel(desired, OPENAI_LEVEL_LADDER, supported);
|
|
385
394
|
return { reasoning_effort: level };
|
|
386
395
|
}
|
package/index.d.ts
CHANGED
|
@@ -501,6 +501,7 @@ export declare class ModelMix {
|
|
|
501
501
|
qwen36plus(args?: ModelAttachArgs): this;
|
|
502
502
|
qwen37plus(args?: ModelAttachArgs): this;
|
|
503
503
|
qwen38max(args?: ModelAttachArgs): this;
|
|
504
|
+
qwen3827b(args?: ModelAttachArgs): this;
|
|
504
505
|
hermes470b(args?: ModelAttachArgs): this;
|
|
505
506
|
hermes4405b(args?: ModelAttachArgs): this;
|
|
506
507
|
hermes3(args?: ModelAttachArgs): this;
|
|
@@ -517,6 +518,7 @@ export declare class ModelMix {
|
|
|
517
518
|
deepseekV4Flash(args?: ModelAttachArgs): this;
|
|
518
519
|
GLM51(args?: ModelAttachArgs): this;
|
|
519
520
|
GLM52(args?: ModelAttachArgs): this;
|
|
521
|
+
GLM53(args?: ModelAttachArgs): this;
|
|
520
522
|
|
|
521
523
|
addText(text: string, options?: RoleOptions): this;
|
|
522
524
|
addTextFromFile(filePath: string, options?: RoleOptions): this;
|