rhachet-brains-xai 0.1.3 → 0.2.0
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/dist/contract/sdk/index.js +8 -5
- package/dist/contract/sdk/index.js.map +1 -1
- package/dist/domain.operations/atom/BrainAtom.config.d.ts +26 -0
- package/dist/domain.operations/atom/BrainAtom.config.js +305 -0
- package/dist/domain.operations/atom/BrainAtom.config.js.map +1 -0
- package/dist/domain.operations/atom/genBrainAtom.d.ts +6 -9
- package/dist/domain.operations/atom/genBrainAtom.js +47 -37
- package/dist/domain.operations/atom/genBrainAtom.js.map +1 -1
- package/package.json +9 -7
- package/readme.md +14 -10
- package/dist/infra/schema/asJsonSchema.d.ts +0 -13
- package/dist/infra/schema/asJsonSchema.js +0 -18
- package/dist/infra/schema/asJsonSchema.js.map +0 -1
|
@@ -8,11 +8,14 @@ const genBrainAtom_1 = require("../../domain.operations/atom/genBrainAtom");
|
|
|
8
8
|
*/
|
|
9
9
|
const getBrainAtomsByXAI = () => {
|
|
10
10
|
return [
|
|
11
|
-
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok
|
|
12
|
-
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok
|
|
13
|
-
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok
|
|
14
|
-
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok
|
|
15
|
-
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok
|
|
11
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/code-fast-1' }),
|
|
12
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/3' }),
|
|
13
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/3-mini' }),
|
|
14
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/4' }),
|
|
15
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/4-fast-wout-reason' }),
|
|
16
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/4-fast-with-reason' }),
|
|
17
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/4.1-fast-wout-reason' }),
|
|
18
|
+
(0, genBrainAtom_1.genBrainAtom)({ slug: 'xai/grok/4.1-fast-with-reason' }),
|
|
16
19
|
];
|
|
17
20
|
};
|
|
18
21
|
exports.getBrainAtomsByXAI = getBrainAtomsByXAI;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdk/index.ts"],"names":[],"mappings":";;;AAEA,4EAAyE;AAEzE;;;GAGG;AACI,MAAM,kBAAkB,GAAG,GAAgB,EAAE;IAClD,OAAO;QACL,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;QAC9C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QACpC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;QACzC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QACpC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdk/index.ts"],"names":[],"mappings":";;;AAEA,4EAAyE;AAEzE;;;GAGG;AACI,MAAM,kBAAkB,GAAG,GAAgB,EAAE;IAClD,OAAO;QACL,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;QAC9C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QACpC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;QACzC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QACpC,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC;QACrD,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC;QACrD,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,+BAA+B,EAAE,CAAC;QACvD,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,+BAA+B,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B;AAEF,sCAAsC;AACtC,0EAAyE;AAAhE,4GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BrainSpec } from 'rhachet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = atom config type
|
|
4
|
+
* .why = shared type for model configs
|
|
5
|
+
*/
|
|
6
|
+
export type BrainAtomConfig = {
|
|
7
|
+
model: string;
|
|
8
|
+
description: string;
|
|
9
|
+
spec: BrainSpec;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* .what = supported xai atom slugs
|
|
13
|
+
* .why = enables type-safe slug specification with model variants
|
|
14
|
+
*/
|
|
15
|
+
export type XaiBrainAtomSlug = 'xai/grok/code-fast-1' | 'xai/grok/3' | 'xai/grok/3-mini' | 'xai/grok/4' | 'xai/grok/4-fast-wout-reason' | 'xai/grok/4-fast-with-reason' | 'xai/grok/4.1-fast-wout-reason' | 'xai/grok/4.1-fast-with-reason';
|
|
16
|
+
/**
|
|
17
|
+
* .what = model configuration by slug
|
|
18
|
+
* .why = maps slugs to api model names, descriptions, and specs
|
|
19
|
+
*
|
|
20
|
+
* .sources:
|
|
21
|
+
* - rates: https://docs.x.ai/docs/models
|
|
22
|
+
* - grok-code-fast-1: https://x.ai/news/grok-code-fast-1
|
|
23
|
+
* - grok-4 benchmarks: https://x.ai/news/grok-4
|
|
24
|
+
* - api docs: https://docs.x.ai/docs
|
|
25
|
+
*/
|
|
26
|
+
export declare const CONFIG_BY_ATOM_SLUG: Record<XaiBrainAtomSlug, BrainAtomConfig>;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONFIG_BY_ATOM_SLUG = void 0;
|
|
4
|
+
const iso_price_1 = require("iso-price");
|
|
5
|
+
const rhachet_1 = require("rhachet");
|
|
6
|
+
/**
|
|
7
|
+
* .what = model configuration by slug
|
|
8
|
+
* .why = maps slugs to api model names, descriptions, and specs
|
|
9
|
+
*
|
|
10
|
+
* .sources:
|
|
11
|
+
* - rates: https://docs.x.ai/docs/models
|
|
12
|
+
* - grok-code-fast-1: https://x.ai/news/grok-code-fast-1
|
|
13
|
+
* - grok-4 benchmarks: https://x.ai/news/grok-4
|
|
14
|
+
* - api docs: https://docs.x.ai/docs
|
|
15
|
+
*/
|
|
16
|
+
exports.CONFIG_BY_ATOM_SLUG = {
|
|
17
|
+
/**
|
|
18
|
+
* grok-code-fast-1
|
|
19
|
+
* .sources:
|
|
20
|
+
* - rates: https://x.ai/news/grok-code-fast-1 ($0.20/1M input, $1.50/1M output, $0.02/1M cached)
|
|
21
|
+
* - context: https://x.ai/news/grok-code-fast-1 (256K)
|
|
22
|
+
* - cutoff: https://x.ai/news/grok-code-fast-1 (march 2025)
|
|
23
|
+
* - swe-bench: https://x.ai/news/grok-code-fast-1 (70.8%)
|
|
24
|
+
*/
|
|
25
|
+
'xai/grok/code-fast-1': {
|
|
26
|
+
model: 'grok-code-fast-1',
|
|
27
|
+
description: 'grok-code-fast-1 - optimized for agentic code (256K)',
|
|
28
|
+
spec: new rhachet_1.BrainSpec({
|
|
29
|
+
cost: {
|
|
30
|
+
time: {
|
|
31
|
+
speed: { tokens: 200, per: { seconds: 1 } },
|
|
32
|
+
latency: { seconds: 0.5 },
|
|
33
|
+
},
|
|
34
|
+
cash: {
|
|
35
|
+
per: 'token',
|
|
36
|
+
cache: {
|
|
37
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.02', by: 1000000 }), // $0.02/1M cached
|
|
38
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
39
|
+
},
|
|
40
|
+
input: (0, iso_price_1.dividePrice)({ of: '$0.20', by: 1000000 }), // $0.20/1M tokens
|
|
41
|
+
output: (0, iso_price_1.dividePrice)({ of: '$1.50', by: 1000000 }), // $1.50/1M tokens
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
gain: {
|
|
45
|
+
size: { context: { tokens: 256000 } }, // 256K context
|
|
46
|
+
grades: { swe: 70.8 }, // 70.8% swe-bench verified
|
|
47
|
+
cutoff: '2025-03-01', // march 2025
|
|
48
|
+
domain: 'SOFTWARE',
|
|
49
|
+
skills: { tooluse: true },
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* grok-3
|
|
55
|
+
* .sources:
|
|
56
|
+
* - rates: https://docs.x.ai/docs/models ($3/1M input, $15/1M output, $0.75/1M cached)
|
|
57
|
+
* - context: https://docs.x.ai/docs/models (131K)
|
|
58
|
+
* - cutoff: https://x.ai/news/grok-3 (november 2024)
|
|
59
|
+
*/
|
|
60
|
+
'xai/grok/3': {
|
|
61
|
+
model: 'grok-3-beta',
|
|
62
|
+
description: 'grok-3 - balanced (131K)',
|
|
63
|
+
spec: new rhachet_1.BrainSpec({
|
|
64
|
+
cost: {
|
|
65
|
+
time: {
|
|
66
|
+
speed: { tokens: 100, per: { seconds: 1 } },
|
|
67
|
+
latency: { seconds: 1 },
|
|
68
|
+
},
|
|
69
|
+
cash: {
|
|
70
|
+
per: 'token',
|
|
71
|
+
cache: {
|
|
72
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.75', by: 1000000 }), // $0.75/1M cached
|
|
73
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
74
|
+
},
|
|
75
|
+
input: (0, iso_price_1.dividePrice)({ of: '$3', by: 1000000 }), // $3/1M tokens
|
|
76
|
+
output: (0, iso_price_1.dividePrice)({ of: '$15', by: 1000000 }), // $15/1M tokens
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
gain: {
|
|
80
|
+
size: { context: { tokens: 131000 } }, // 131K context
|
|
81
|
+
grades: {},
|
|
82
|
+
cutoff: '2024-11-01', // november 2024
|
|
83
|
+
domain: 'ALL',
|
|
84
|
+
skills: { tooluse: true },
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* grok-3-mini
|
|
90
|
+
* .sources:
|
|
91
|
+
* - rates: https://docs.x.ai/docs/models ($0.30/1M input, $0.50/1M output, $0.075/1M cached)
|
|
92
|
+
* - context: https://docs.x.ai/docs/models (131K)
|
|
93
|
+
* - cutoff: https://x.ai/news/grok-3 (november 2024)
|
|
94
|
+
*/
|
|
95
|
+
'xai/grok/3-mini': {
|
|
96
|
+
model: 'grok-3-mini-beta',
|
|
97
|
+
description: 'grok-3-mini - fast and cost-effective (131K)',
|
|
98
|
+
spec: new rhachet_1.BrainSpec({
|
|
99
|
+
cost: {
|
|
100
|
+
time: {
|
|
101
|
+
speed: { tokens: 150, per: { seconds: 1 } },
|
|
102
|
+
latency: { seconds: 0.5 },
|
|
103
|
+
},
|
|
104
|
+
cash: {
|
|
105
|
+
per: 'token',
|
|
106
|
+
cache: {
|
|
107
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.075', by: 1000000 }), // $0.075/1M cached
|
|
108
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
109
|
+
},
|
|
110
|
+
input: (0, iso_price_1.dividePrice)({ of: '$0.30', by: 1000000 }), // $0.30/1M tokens
|
|
111
|
+
output: (0, iso_price_1.dividePrice)({ of: '$0.50', by: 1000000 }), // $0.50/1M tokens
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
gain: {
|
|
115
|
+
size: { context: { tokens: 131000 } }, // 131K context
|
|
116
|
+
grades: {},
|
|
117
|
+
cutoff: '2024-11-01', // november 2024
|
|
118
|
+
domain: 'ALL',
|
|
119
|
+
skills: { tooluse: true },
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* grok-4
|
|
125
|
+
* .sources:
|
|
126
|
+
* - rates: https://docs.x.ai/docs/models ($3/1M input, $15/1M output, $0.75/1M cached)
|
|
127
|
+
* - context: https://docs.x.ai/docs/models (256K)
|
|
128
|
+
* - benchmarks: https://x.ai/news/grok-4 (72-75% swe-bench, 86.6% mmlu, 88% gpqa diamond)
|
|
129
|
+
* - benchmarks: https://x.com/ArtificialAnlys/status/1943166841150644622 (94% aime 2024)
|
|
130
|
+
* - cutoff: https://x.ai/news/grok-4 (july 2025)
|
|
131
|
+
*/
|
|
132
|
+
'xai/grok/4': {
|
|
133
|
+
model: 'grok-4-07-09',
|
|
134
|
+
description: 'grok-4 - advanced (256K)',
|
|
135
|
+
spec: new rhachet_1.BrainSpec({
|
|
136
|
+
cost: {
|
|
137
|
+
time: {
|
|
138
|
+
speed: { tokens: 80, per: { seconds: 1 } },
|
|
139
|
+
latency: { seconds: 1.5 },
|
|
140
|
+
},
|
|
141
|
+
cash: {
|
|
142
|
+
per: 'token',
|
|
143
|
+
cache: {
|
|
144
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.75', by: 1000000 }), // $0.75/1M cached
|
|
145
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
146
|
+
},
|
|
147
|
+
input: (0, iso_price_1.dividePrice)({ of: '$3', by: 1000000 }), // $3/1M tokens
|
|
148
|
+
output: (0, iso_price_1.dividePrice)({ of: '$15', by: 1000000 }), // $15/1M tokens
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
gain: {
|
|
152
|
+
size: { context: { tokens: 256000 } }, // 256K context
|
|
153
|
+
grades: { swe: 75, mmlu: 86.6, gpqa: 88, aime: 94 }, // todo: remove as any next time you see this. the dep will already have been published.
|
|
154
|
+
cutoff: '2025-07-01', // july 2025
|
|
155
|
+
domain: 'ALL',
|
|
156
|
+
skills: { tooluse: true },
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
/**
|
|
161
|
+
* grok-4-fast-wout-reason (non-reasoning)
|
|
162
|
+
* .sources:
|
|
163
|
+
* - rates: https://x.com/xai/status/1969183335797715149 ($0.20/1M input, $0.50/1M output, $0.05/1M cached)
|
|
164
|
+
* - context: https://x.ai/news/grok-4-fast (2M)
|
|
165
|
+
* - cutoff: https://x.ai/news/grok-4 (july 2025)
|
|
166
|
+
*/
|
|
167
|
+
'xai/grok/4-fast-wout-reason': {
|
|
168
|
+
model: 'grok-4-fast-non-reasoning',
|
|
169
|
+
description: 'grok-4-fast non-reasoning - fast responses (2M)',
|
|
170
|
+
spec: new rhachet_1.BrainSpec({
|
|
171
|
+
cost: {
|
|
172
|
+
time: {
|
|
173
|
+
speed: { tokens: 300, per: { seconds: 1 } },
|
|
174
|
+
latency: { seconds: 0.3 },
|
|
175
|
+
},
|
|
176
|
+
cash: {
|
|
177
|
+
per: 'token',
|
|
178
|
+
cache: {
|
|
179
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.05', by: 1000000 }), // $0.05/1M cached
|
|
180
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
181
|
+
},
|
|
182
|
+
input: (0, iso_price_1.dividePrice)({ of: '$0.20', by: 1000000 }), // $0.20/1M tokens
|
|
183
|
+
output: (0, iso_price_1.dividePrice)({ of: '$0.50', by: 1000000 }), // $0.50/1M tokens
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
gain: {
|
|
187
|
+
size: { context: { tokens: 2000000 } }, // 2M context
|
|
188
|
+
grades: {},
|
|
189
|
+
cutoff: '2025-07-01', // july 2025
|
|
190
|
+
domain: 'ALL',
|
|
191
|
+
skills: { tooluse: true },
|
|
192
|
+
},
|
|
193
|
+
}),
|
|
194
|
+
},
|
|
195
|
+
/**
|
|
196
|
+
* grok-4-fast-with-reason (reasoning)
|
|
197
|
+
* .sources:
|
|
198
|
+
* - rates: https://x.com/xai/status/1969183335797715149 ($0.20/1M input, $0.50/1M output, $0.05/1M cached)
|
|
199
|
+
* - context: https://x.ai/news/grok-4-fast (2M)
|
|
200
|
+
* - cutoff: https://x.ai/news/grok-4 (july 2025)
|
|
201
|
+
* - note: uses chain-of-thought, consumes more tokens but better for complex tasks
|
|
202
|
+
*/
|
|
203
|
+
'xai/grok/4-fast-with-reason': {
|
|
204
|
+
model: 'grok-4-fast-reasoning',
|
|
205
|
+
description: 'grok-4-fast reasoning - chain-of-thought (2M)',
|
|
206
|
+
spec: new rhachet_1.BrainSpec({
|
|
207
|
+
cost: {
|
|
208
|
+
time: {
|
|
209
|
+
speed: { tokens: 150, per: { seconds: 1 } },
|
|
210
|
+
latency: { seconds: 0.5 },
|
|
211
|
+
},
|
|
212
|
+
cash: {
|
|
213
|
+
per: 'token',
|
|
214
|
+
cache: {
|
|
215
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.05', by: 1000000 }), // $0.05/1M cached
|
|
216
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
217
|
+
},
|
|
218
|
+
input: (0, iso_price_1.dividePrice)({ of: '$0.20', by: 1000000 }), // $0.20/1M tokens
|
|
219
|
+
output: (0, iso_price_1.dividePrice)({ of: '$0.50', by: 1000000 }), // $0.50/1M tokens
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
gain: {
|
|
223
|
+
size: { context: { tokens: 2000000 } }, // 2M context
|
|
224
|
+
grades: {},
|
|
225
|
+
cutoff: '2025-07-01', // july 2025
|
|
226
|
+
domain: 'ALL',
|
|
227
|
+
skills: { tooluse: true },
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
230
|
+
},
|
|
231
|
+
/**
|
|
232
|
+
* grok-4.1-fast-wout-reason (non-reasoning)
|
|
233
|
+
* .sources:
|
|
234
|
+
* - rates: https://blog.galaxy.ai/model/grok-4-1-fast ($0.20/1M input, $0.50/1M output, $0.05/1M cached)
|
|
235
|
+
* - context: https://x.ai/news/grok-4-1-fast (2M)
|
|
236
|
+
* - release: https://x.ai/news/grok-4-1-fast (november 2025)
|
|
237
|
+
* - note: successor to grok-4-fast, better tool call and lower hallucination
|
|
238
|
+
*/
|
|
239
|
+
'xai/grok/4.1-fast-wout-reason': {
|
|
240
|
+
model: 'grok-4-1-fast-non-reasoning',
|
|
241
|
+
description: 'grok-4.1-fast non-reasoning - best tool call (2M)',
|
|
242
|
+
spec: new rhachet_1.BrainSpec({
|
|
243
|
+
cost: {
|
|
244
|
+
time: {
|
|
245
|
+
speed: { tokens: 300, per: { seconds: 1 } },
|
|
246
|
+
latency: { seconds: 0.3 },
|
|
247
|
+
},
|
|
248
|
+
cash: {
|
|
249
|
+
per: 'token',
|
|
250
|
+
cache: {
|
|
251
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.05', by: 1000000 }), // $0.05/1M cached
|
|
252
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
253
|
+
},
|
|
254
|
+
input: (0, iso_price_1.dividePrice)({ of: '$0.20', by: 1000000 }), // $0.20/1M tokens
|
|
255
|
+
output: (0, iso_price_1.dividePrice)({ of: '$0.50', by: 1000000 }), // $0.50/1M tokens
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
gain: {
|
|
259
|
+
size: { context: { tokens: 2000000 } }, // 2M context
|
|
260
|
+
grades: {},
|
|
261
|
+
cutoff: '2025-11-01', // november 2025
|
|
262
|
+
domain: 'ALL',
|
|
263
|
+
skills: { tooluse: true },
|
|
264
|
+
},
|
|
265
|
+
}),
|
|
266
|
+
},
|
|
267
|
+
/**
|
|
268
|
+
* grok-4.1-fast-with-reason (reasoning)
|
|
269
|
+
* .sources:
|
|
270
|
+
* - rates: https://blog.galaxy.ai/model/grok-4-1-fast ($0.20/1M input, $0.50/1M output, $0.05/1M cached)
|
|
271
|
+
* - context: https://x.ai/news/grok-4-1-fast (2M)
|
|
272
|
+
* - release: https://x.ai/news/grok-4-1-fast (november 2025)
|
|
273
|
+
* - benchmark: https://llm-stats.com/models/grok-4-1-fast-reasoning (64 intelligence, ~79% swe-bench)
|
|
274
|
+
* - note: near grok-4 capability at 1/15th price
|
|
275
|
+
*/
|
|
276
|
+
'xai/grok/4.1-fast-with-reason': {
|
|
277
|
+
model: 'grok-4-1-fast-reasoning',
|
|
278
|
+
description: 'grok-4.1-fast reasoning - near grok-4 capability (2M)',
|
|
279
|
+
spec: new rhachet_1.BrainSpec({
|
|
280
|
+
cost: {
|
|
281
|
+
time: {
|
|
282
|
+
speed: { tokens: 150, per: { seconds: 1 } },
|
|
283
|
+
latency: { seconds: 0.5 },
|
|
284
|
+
},
|
|
285
|
+
cash: {
|
|
286
|
+
per: 'token',
|
|
287
|
+
cache: {
|
|
288
|
+
get: (0, iso_price_1.dividePrice)({ of: '$0.05', by: 1000000 }), // $0.05/1M cached
|
|
289
|
+
set: (0, iso_price_1.asIsoPrice)('$0'),
|
|
290
|
+
},
|
|
291
|
+
input: (0, iso_price_1.dividePrice)({ of: '$0.20', by: 1000000 }), // $0.20/1M tokens
|
|
292
|
+
output: (0, iso_price_1.dividePrice)({ of: '$0.50', by: 1000000 }), // $0.50/1M tokens
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
gain: {
|
|
296
|
+
size: { context: { tokens: 2000000 } }, // 2M context
|
|
297
|
+
grades: { swe: 79 }, // ~79% swe-bench
|
|
298
|
+
cutoff: '2025-11-01', // november 2025
|
|
299
|
+
domain: 'ALL',
|
|
300
|
+
skills: { tooluse: true },
|
|
301
|
+
},
|
|
302
|
+
}),
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
//# sourceMappingURL=BrainAtom.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrainAtom.config.js","sourceRoot":"","sources":["../../../src/domain.operations/atom/BrainAtom.config.ts"],"names":[],"mappings":";;;AAAA,yCAAoD;AACpD,qCAAoC;AA0BpC;;;;;;;;;GASG;AACU,QAAA,mBAAmB,GAA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@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { BrainAtom } from 'rhachet';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* .why = enables type-safe slug specification with model variants
|
|
5
|
-
*/
|
|
6
|
-
export type XAIAtomSlug = 'xai/grok-code-fast-1' | 'xai/grok-3' | 'xai/grok-3-mini' | 'xai/grok-4' | 'xai/grok-4-fast';
|
|
2
|
+
import { type XaiBrainAtomSlug } from './BrainAtom.config';
|
|
3
|
+
export type { XaiBrainAtomSlug } from './BrainAtom.config';
|
|
7
4
|
/**
|
|
8
5
|
* .what = factory to generate xai brain atom instances
|
|
9
6
|
* .why = enables model variant selection via slug
|
|
@@ -11,10 +8,10 @@ export type XAIAtomSlug = 'xai/grok-code-fast-1' | 'xai/grok-3' | 'xai/grok-3-mi
|
|
|
11
8
|
* .note = xai api is openai-compatible with baseURL override
|
|
12
9
|
*
|
|
13
10
|
* .example
|
|
14
|
-
* genBrainAtom({ slug: 'xai/grok
|
|
15
|
-
* genBrainAtom({ slug: 'xai/grok
|
|
16
|
-
* genBrainAtom({ slug: 'xai/grok
|
|
11
|
+
* genBrainAtom({ slug: 'xai/grok/code-fast-1' })
|
|
12
|
+
* genBrainAtom({ slug: 'xai/grok/3-mini' }) // fast + cheap
|
|
13
|
+
* genBrainAtom({ slug: 'xai/grok/4' }) // advanced
|
|
17
14
|
*/
|
|
18
15
|
export declare const genBrainAtom: (input: {
|
|
19
|
-
slug:
|
|
16
|
+
slug: XaiBrainAtomSlug;
|
|
20
17
|
}) => BrainAtom;
|
|
@@ -6,38 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.genBrainAtom = void 0;
|
|
7
7
|
const openai_1 = __importDefault(require("openai"));
|
|
8
8
|
const rhachet_1 = require("rhachet");
|
|
9
|
+
const calcBrainOutputCost_1 = require("rhachet/dist/domain.operations/brainCost/calcBrainOutputCost");
|
|
9
10
|
const zod_1 = require("zod");
|
|
10
|
-
|
|
11
|
-
* .what = model configuration by slug
|
|
12
|
-
* .why = maps slugs to API model names, descriptions, and context sizes
|
|
13
|
-
*/
|
|
14
|
-
const CONFIG_BY_SLUG = {
|
|
15
|
-
'xai/grok-code-fast-1': {
|
|
16
|
-
model: 'grok-code-fast-1',
|
|
17
|
-
description: 'grok-code-fast-1 - optimized for agentic coding (256K)',
|
|
18
|
-
context: 256000,
|
|
19
|
-
},
|
|
20
|
-
'xai/grok-3': {
|
|
21
|
-
model: 'grok-3-beta',
|
|
22
|
-
description: 'grok-3 - balanced reasoning (131K)',
|
|
23
|
-
context: 131000,
|
|
24
|
-
},
|
|
25
|
-
'xai/grok-3-mini': {
|
|
26
|
-
model: 'grok-3-mini-beta',
|
|
27
|
-
description: 'grok-3-mini - fast and cost-effective (131K)',
|
|
28
|
-
context: 131000,
|
|
29
|
-
},
|
|
30
|
-
'xai/grok-4': {
|
|
31
|
-
model: 'grok-4-07-09',
|
|
32
|
-
description: 'grok-4 - advanced reasoning (256K)',
|
|
33
|
-
context: 256000,
|
|
34
|
-
},
|
|
35
|
-
'xai/grok-4-fast': {
|
|
36
|
-
model: 'grok-4-fast-reasoning',
|
|
37
|
-
description: 'grok-4-fast - frontier with reasoning (2M)',
|
|
38
|
-
context: 2000000,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
11
|
+
const BrainAtom_config_1 = require("./BrainAtom.config");
|
|
41
12
|
/**
|
|
42
13
|
* .what = factory to generate xai brain atom instances
|
|
43
14
|
* .why = enables model variant selection via slug
|
|
@@ -45,21 +16,24 @@ const CONFIG_BY_SLUG = {
|
|
|
45
16
|
* .note = xai api is openai-compatible with baseURL override
|
|
46
17
|
*
|
|
47
18
|
* .example
|
|
48
|
-
* genBrainAtom({ slug: 'xai/grok
|
|
49
|
-
* genBrainAtom({ slug: 'xai/grok
|
|
50
|
-
* genBrainAtom({ slug: 'xai/grok
|
|
19
|
+
* genBrainAtom({ slug: 'xai/grok/code-fast-1' })
|
|
20
|
+
* genBrainAtom({ slug: 'xai/grok/3-mini' }) // fast + cheap
|
|
21
|
+
* genBrainAtom({ slug: 'xai/grok/4' }) // advanced
|
|
51
22
|
*/
|
|
52
23
|
const genBrainAtom = (input) => {
|
|
53
|
-
const config =
|
|
24
|
+
const config = BrainAtom_config_1.CONFIG_BY_ATOM_SLUG[input.slug];
|
|
54
25
|
return new rhachet_1.BrainAtom({
|
|
55
26
|
repo: 'xai',
|
|
56
27
|
slug: input.slug,
|
|
57
28
|
description: config.description,
|
|
29
|
+
spec: config.spec,
|
|
58
30
|
/**
|
|
59
31
|
* .what = stateless inference (no tool use)
|
|
60
|
-
* .why = provides direct model access for
|
|
32
|
+
* .why = provides direct model access for tasks
|
|
61
33
|
*/
|
|
62
34
|
ask: async (askInput, context) => {
|
|
35
|
+
// track start time for elapsed duration
|
|
36
|
+
const startedAt = Date.now();
|
|
63
37
|
// compose system prompt from briefs
|
|
64
38
|
const systemPrompt = askInput.role.briefs
|
|
65
39
|
? await (0, rhachet_1.castBriefsToPrompt)({ briefs: askInput.role.briefs })
|
|
@@ -95,7 +69,43 @@ const genBrainAtom = (input) => {
|
|
|
95
69
|
const content = response.choices[0]?.message?.content ?? '';
|
|
96
70
|
// parse JSON response and validate via schema
|
|
97
71
|
const parsed = JSON.parse(content);
|
|
98
|
-
|
|
72
|
+
const output = askInput.schema.output.parse(parsed);
|
|
73
|
+
// calculate elapsed time
|
|
74
|
+
const elapsedMs = Date.now() - startedAt;
|
|
75
|
+
// extract token usage from response
|
|
76
|
+
const tokensInput = response.usage?.prompt_tokens ?? 0;
|
|
77
|
+
const tokensOutput = response.usage?.completion_tokens ?? 0;
|
|
78
|
+
const tokensCached = response.usage?.prompt_tokens_details?.cached_tokens ?? 0;
|
|
79
|
+
// calculate character counts
|
|
80
|
+
const charsInput = (systemPrompt?.length ?? 0) + askInput.prompt.length;
|
|
81
|
+
const charsOutput = content.length;
|
|
82
|
+
// define size for metrics and cost calculation
|
|
83
|
+
const size = {
|
|
84
|
+
tokens: {
|
|
85
|
+
input: tokensInput,
|
|
86
|
+
output: tokensOutput,
|
|
87
|
+
cache: { get: tokensCached, set: 0 },
|
|
88
|
+
},
|
|
89
|
+
chars: {
|
|
90
|
+
input: charsInput,
|
|
91
|
+
output: charsOutput,
|
|
92
|
+
cache: { get: 0, set: 0 },
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
// calculate cash costs via rhachet utility
|
|
96
|
+
const { cash } = (0, calcBrainOutputCost_1.calcBrainOutputCost)({
|
|
97
|
+
for: { tokens: size.tokens },
|
|
98
|
+
with: { cost: { cash: config.spec.cost.cash } },
|
|
99
|
+
});
|
|
100
|
+
// build metrics
|
|
101
|
+
const metrics = new rhachet_1.BrainOutputMetrics({
|
|
102
|
+
size,
|
|
103
|
+
cost: {
|
|
104
|
+
time: { milliseconds: elapsedMs },
|
|
105
|
+
cash,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
return new rhachet_1.BrainOutput({ output, metrics });
|
|
99
109
|
},
|
|
100
110
|
});
|
|
101
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genBrainAtom.js","sourceRoot":"","sources":["../../../src/domain.operations/atom/genBrainAtom.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"genBrainAtom.js","sourceRoot":"","sources":["../../../src/domain.operations/atom/genBrainAtom.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,qCAKiB;AACjB,sGAAmG;AAInG,6BAAwB;AAExB,yDAAgF;AAKhF;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,CAAC,KAAiC,EAAa,EAAE;IAC3E,MAAM,MAAM,GAAG,sCAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,IAAI,mBAAS,CAAC;QACnB,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,IAAI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AAE,IAAI,EAAE,GAAG,IAAA,yCAAmB,EAAC;gBACnC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;gBAC5B,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE;aAChD,CAAC,CAAC;YAEH,gBAAgB;YAChB,MAAM,OAAO,GAAG,IAAI,4BAAkB,CAAC;gBACrC,IAAI;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE;oBACjC,IAAI;iBACL;aACF,CAAC,CAAC;YAEH,OAAO,IAAI,qBAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AArHW,QAAA,YAAY,gBAqHvB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "rhachet-brains-xai",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "rhachet brain.atom adapter for xai grok models",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.2.0",
|
|
6
6
|
"repository": "ehmpathy/rhachet-brains-xai",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/rhachet-brains-xai",
|
|
8
8
|
"keywords": [
|
|
@@ -53,12 +53,13 @@
|
|
|
53
53
|
"preversion": "npm run prepush",
|
|
54
54
|
"postversion": "git push origin HEAD --tags --no-verify",
|
|
55
55
|
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
56
|
-
"prepare:rhachet": "rhachet init --
|
|
56
|
+
"prepare:rhachet": "rhachet init --roles behaver mechanic reviewer --hooks",
|
|
57
57
|
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"domain-objects": "0.31.9",
|
|
61
61
|
"helpful-errors": "1.5.3",
|
|
62
|
+
"iso-price": "1.1.1",
|
|
62
63
|
"openai": "5.8.2",
|
|
63
64
|
"rhachet-artifact": "1.0.1",
|
|
64
65
|
"rhachet-artifact-git": "1.1.5",
|
|
@@ -87,11 +88,12 @@
|
|
|
87
88
|
"esbuild-register": "3.6.0",
|
|
88
89
|
"husky": "8.0.3",
|
|
89
90
|
"jest": "30.2.0",
|
|
90
|
-
"rhachet": "1.
|
|
91
|
-
"rhachet-
|
|
92
|
-
"rhachet-roles-
|
|
93
|
-
"rhachet-roles-
|
|
94
|
-
"
|
|
91
|
+
"rhachet": "1.26.2",
|
|
92
|
+
"rhachet-brains-anthropic": "0.3.0",
|
|
93
|
+
"rhachet-roles-bhrain": "0.5.11",
|
|
94
|
+
"rhachet-roles-bhuild": "0.6.10",
|
|
95
|
+
"rhachet-roles-ehmpathy": "1.17.29",
|
|
96
|
+
"test-fns": "1.10.0",
|
|
95
97
|
"tsc-alias": "1.8.10",
|
|
96
98
|
"tsx": "4.20.6",
|
|
97
99
|
"typescript": "5.4.5",
|
package/readme.md
CHANGED
|
@@ -15,17 +15,17 @@ import { genBrainAtom } from 'rhachet-brains-xai';
|
|
|
15
15
|
import { z } from 'zod';
|
|
16
16
|
|
|
17
17
|
// create a brain atom for direct model inference
|
|
18
|
-
const brainAtom = genBrainAtom({ slug: 'xai/grok
|
|
18
|
+
const brainAtom = genBrainAtom({ slug: 'xai/grok/code-fast-1' });
|
|
19
19
|
|
|
20
20
|
// simple string output
|
|
21
|
-
const explanation = await brainAtom.ask({
|
|
21
|
+
const { output: explanation } = await brainAtom.ask({
|
|
22
22
|
role: { briefs: [] },
|
|
23
23
|
prompt: 'explain this code',
|
|
24
24
|
schema: { output: z.string() },
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
// structured object output
|
|
28
|
-
const { summary, issues } = await brainAtom.ask({
|
|
28
|
+
const { output: { summary, issues } } = await brainAtom.ask({
|
|
29
29
|
role: { briefs: [] },
|
|
30
30
|
prompt: 'analyze this code',
|
|
31
31
|
schema: { output: z.object({ summary: z.string(), issues: z.array(z.string()) }) },
|
|
@@ -38,13 +38,16 @@ const { summary, issues } = await brainAtom.ask({
|
|
|
38
38
|
|
|
39
39
|
stateless inference without tool use.
|
|
40
40
|
|
|
41
|
-
| slug
|
|
42
|
-
|
|
|
43
|
-
| `xai/grok
|
|
44
|
-
| `xai/grok
|
|
45
|
-
| `xai/grok
|
|
46
|
-
| `xai/grok
|
|
47
|
-
| `xai/grok
|
|
41
|
+
| slug | model | context | cutoff | input | output | cache |
|
|
42
|
+
| ------------------------------- | --------------------------- | ------- | -------- | -------- | -------- | --------- |
|
|
43
|
+
| `xai/grok/code-fast-1` | grok-code-fast-1 | 256K | mar 2025 | $0.20/1M | $1.50/1M | $0.02/1M |
|
|
44
|
+
| `xai/grok/3` | grok-3-beta | 131K | nov 2024 | $3/1M | $15/1M | $0.75/1M |
|
|
45
|
+
| `xai/grok/3-mini` | grok-3-mini-beta | 131K | nov 2024 | $0.30/1M | $0.50/1M | $0.075/1M |
|
|
46
|
+
| `xai/grok/4` | grok-4-07-09 | 256K | jul 2025 | $3/1M | $15/1M | $0.75/1M |
|
|
47
|
+
| `xai/grok/4-fast-wout-reason` | grok-4-fast-non-reasoning | 2M | jul 2025 | $0.20/1M | $0.50/1M | $0.05/1M |
|
|
48
|
+
| `xai/grok/4-fast-with-reason` | grok-4-fast-reasoning | 2M | jul 2025 | $0.20/1M | $0.50/1M | $0.05/1M |
|
|
49
|
+
| `xai/grok/4.1-fast-wout-reason` | grok-4-1-fast-non-reasoning | 2M | nov 2025 | $0.20/1M | $0.50/1M | $0.05/1M |
|
|
50
|
+
| `xai/grok/4.1-fast-with-reason` | grok-4-1-fast-reasoning | 2M | nov 2025 | $0.20/1M | $0.50/1M | $0.05/1M |
|
|
48
51
|
|
|
49
52
|
## environment
|
|
50
53
|
|
|
@@ -55,3 +58,4 @@ requires `XAI_API_KEY` environment variable.
|
|
|
55
58
|
- [xAI API Documentation](https://docs.x.ai/docs/overview)
|
|
56
59
|
- [xAI Models](https://docs.x.ai/docs/models)
|
|
57
60
|
- [Grok Code Fast 1](https://x.ai/news/grok-code-fast-1)
|
|
61
|
+
- [Grok 4](https://x.ai/news/grok-4)
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* .what = convert a zod schema to JSON schema for native SDK enforcement
|
|
4
|
-
* .why = enables native structured output support in SDKs, reducing
|
|
5
|
-
* token waste on validation retries
|
|
6
|
-
*
|
|
7
|
-
* .note = different SDKs require different conversion options:
|
|
8
|
-
* - claude-agent-sdk: { $refStrategy: 'root' }
|
|
9
|
-
* - codex-sdk: { target: 'openAi' }
|
|
10
|
-
*/
|
|
11
|
-
export declare const asJsonSchema: (input: {
|
|
12
|
-
schema: z.ZodSchema;
|
|
13
|
-
}) => object;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asJsonSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
/**
|
|
6
|
-
* .what = convert a zod schema to JSON schema for native SDK enforcement
|
|
7
|
-
* .why = enables native structured output support in SDKs, reducing
|
|
8
|
-
* token waste on validation retries
|
|
9
|
-
*
|
|
10
|
-
* .note = different SDKs require different conversion options:
|
|
11
|
-
* - claude-agent-sdk: { $refStrategy: 'root' }
|
|
12
|
-
* - codex-sdk: { target: 'openAi' }
|
|
13
|
-
*/
|
|
14
|
-
const asJsonSchema = (input) => {
|
|
15
|
-
return zod_1.z.toJSONSchema(input.schema, { target: 'openAi' });
|
|
16
|
-
};
|
|
17
|
-
exports.asJsonSchema = asJsonSchema;
|
|
18
|
-
//# sourceMappingURL=asJsonSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asJsonSchema.js","sourceRoot":"","sources":["../../../src/infra/schema/asJsonSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;;;;;;;GAQG;AACI,MAAM,YAAY,GAAG,CAAC,KAA8B,EAAU,EAAE;IACrE,OAAO,OAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB"}
|