rhachet-brains-togetherai 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Uladzimir Kasacheuski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ import type { BrainAtom } from 'rhachet';
2
+ /**
3
+ * .what = returns all brain atoms provided by together ai
4
+ * .why = enables consumers to register together ai atoms with genContextBrain
5
+ */
6
+ export declare const getBrainAtomsByTogetherAI: () => BrainAtom[];
7
+ export { genBrainAtom } from '../../domain.operations/atom/genBrainAtom';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.genBrainAtom = exports.getBrainAtomsByTogetherAI = void 0;
4
+ const genBrainAtom_1 = require("../../domain.operations/atom/genBrainAtom");
5
+ /**
6
+ * .what = returns all brain atoms provided by together ai
7
+ * .why = enables consumers to register together ai atoms with genContextBrain
8
+ */
9
+ const getBrainAtomsByTogetherAI = () => {
10
+ return [
11
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/qwen3/coder-next' }),
12
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/qwen3/coder-480b' }),
13
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/qwen3/235b' }),
14
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/deepseek/v3.1' }),
15
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/deepseek/r1' }),
16
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/kimi/k2' }),
17
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/kimi/k2.5' }),
18
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/llama4/maverick' }),
19
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/llama3.3/70b' }),
20
+ (0, genBrainAtom_1.genBrainAtom)({ slug: 'together/glm/4.7' }),
21
+ ];
22
+ };
23
+ exports.getBrainAtomsByTogetherAI = getBrainAtomsByTogetherAI;
24
+ // re-export factory for direct access
25
+ var genBrainAtom_2 = require("../../domain.operations/atom/genBrainAtom");
26
+ Object.defineProperty(exports, "genBrainAtom", { enumerable: true, get: function () { return genBrainAtom_2.genBrainAtom; } });
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/sdk/index.ts"],"names":[],"mappings":";;;AAEA,4EAAyE;AAEzE;;;GAGG;AACI,MAAM,yBAAyB,GAAG,GAAgB,EAAE;IACzD,OAAO;QACL,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,2BAA2B,EAAE,CAAC;QACnD,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,2BAA2B,EAAE,CAAC;QACnD,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;QAC7C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;QAChD,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;QAC9C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAC1C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;QAC5C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC;QAClD,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;QAC/C,IAAA,2BAAY,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,yBAAyB,6BAapC;AAEF,sCAAsC;AACtC,0EAAyE;AAAhE,4GAAA,YAAY,OAAA"}
@@ -0,0 +1,25 @@
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 together ai atom slugs
13
+ * .why = enables type-safe slug specification with model variants
14
+ */
15
+ export type TogetherBrainAtomSlug = 'together/qwen3/coder-next' | 'together/qwen3/coder-480b' | 'together/qwen3/235b' | 'together/deepseek/v3.1' | 'together/deepseek/r1' | 'together/kimi/k2' | 'together/kimi/k2.5' | 'together/llama4/maverick' | 'together/llama3.3/70b' | 'together/glm/4.7';
16
+ /**
17
+ * .what = model configuration by slug
18
+ * .why = maps slugs to api model names, descriptions, and specs
19
+ *
20
+ * .sources:
21
+ * - rates: https://www.together.ai/pricing
22
+ * - models: https://docs.together.ai/docs/serverless-models
23
+ * - api docs: https://docs.together.ai/reference/chat-completions-1
24
+ */
25
+ export declare const CONFIG_BY_ATOM_SLUG: Record<TogetherBrainAtomSlug, BrainAtomConfig>;
@@ -0,0 +1,369 @@
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://www.together.ai/pricing
12
+ * - models: https://docs.together.ai/docs/serverless-models
13
+ * - api docs: https://docs.together.ai/reference/chat-completions-1
14
+ */
15
+ exports.CONFIG_BY_ATOM_SLUG = {
16
+ /**
17
+ * qwen3-coder-next
18
+ * .sources:
19
+ * - rates: https://www.together.ai/pricing ($0.50/1M input, $1.20/1M output)
20
+ * - context: 262K
21
+ * - swe-bench: 74.2% verified
22
+ * - architecture: 80B total, 3B active (moe)
23
+ */
24
+ 'together/qwen3/coder-next': {
25
+ model: 'Qwen/Qwen3-Coder-Next-FP8',
26
+ description: 'qwen3-coder-next - best cost/performance for code (262K)',
27
+ spec: new rhachet_1.BrainSpec({
28
+ cost: {
29
+ time: {
30
+ speed: { tokens: 150, per: { seconds: 1 } },
31
+ latency: { seconds: 0.5 },
32
+ },
33
+ cash: {
34
+ per: 'token',
35
+ cache: {
36
+ get: (0, iso_price_1.asIsoPrice)('$0'), // no cache rate on together ai
37
+ set: (0, iso_price_1.asIsoPrice)('$0'),
38
+ },
39
+ input: (0, iso_price_1.dividePrice)({ of: '$0.50', by: 1000000 }), // $0.50/1M tokens
40
+ output: (0, iso_price_1.dividePrice)({ of: '$1.20', by: 1000000 }), // $1.20/1M tokens
41
+ },
42
+ },
43
+ gain: {
44
+ size: { context: { tokens: 262000 } }, // 262K context
45
+ grades: { swe: 74.2 }, // 74.2% swe-bench verified
46
+ cutoff: '2025-06-01',
47
+ domain: 'SOFTWARE',
48
+ skills: { tooluse: true },
49
+ },
50
+ }),
51
+ },
52
+ /**
53
+ * qwen3-coder-480b
54
+ * .sources:
55
+ * - rates: https://www.together.ai/pricing ($2.00/1M input, $2.00/1M output)
56
+ * - context: 262K
57
+ * - swe-bench: 69.6% verified
58
+ * - architecture: 480B total, 35B active (moe)
59
+ */
60
+ 'together/qwen3/coder-480b': {
61
+ model: 'Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8',
62
+ description: 'qwen3-coder-480b - large code model (262K)',
63
+ spec: new rhachet_1.BrainSpec({
64
+ cost: {
65
+ time: {
66
+ speed: { tokens: 80, per: { seconds: 1 } },
67
+ latency: { seconds: 1 },
68
+ },
69
+ cash: {
70
+ per: 'token',
71
+ cache: {
72
+ get: (0, iso_price_1.asIsoPrice)('$0'),
73
+ set: (0, iso_price_1.asIsoPrice)('$0'),
74
+ },
75
+ input: (0, iso_price_1.dividePrice)({ of: '$2.00', by: 1000000 }), // $2.00/1M tokens
76
+ output: (0, iso_price_1.dividePrice)({ of: '$2.00', by: 1000000 }), // $2.00/1M tokens
77
+ },
78
+ },
79
+ gain: {
80
+ size: { context: { tokens: 262000 } }, // 262K context
81
+ grades: { swe: 69.6 }, // 69.6% swe-bench verified
82
+ cutoff: '2025-06-01',
83
+ domain: 'SOFTWARE',
84
+ skills: { tooluse: true },
85
+ },
86
+ }),
87
+ },
88
+ /**
89
+ * qwen3-235b
90
+ * .sources:
91
+ * - rates: https://www.together.ai/pricing ($0.20/1M input, $0.60/1M output)
92
+ * - context: 131K
93
+ * - architecture: 235B total, 22B active (moe)
94
+ */
95
+ 'together/qwen3/235b': {
96
+ model: 'Qwen/Qwen3-235B-A22B-Instruct-2507-tput',
97
+ description: 'qwen3-235b - general purpose (131K)',
98
+ spec: new rhachet_1.BrainSpec({
99
+ cost: {
100
+ time: {
101
+ speed: { tokens: 120, per: { seconds: 1 } },
102
+ latency: { seconds: 0.5 },
103
+ },
104
+ cash: {
105
+ per: 'token',
106
+ cache: {
107
+ get: (0, iso_price_1.asIsoPrice)('$0'),
108
+ set: (0, iso_price_1.asIsoPrice)('$0'),
109
+ },
110
+ input: (0, iso_price_1.dividePrice)({ of: '$0.20', by: 1000000 }), // $0.20/1M tokens
111
+ output: (0, iso_price_1.dividePrice)({ of: '$0.60', by: 1000000 }), // $0.60/1M tokens
112
+ },
113
+ },
114
+ gain: {
115
+ size: { context: { tokens: 131000 } }, // 131K context
116
+ grades: {},
117
+ cutoff: '2025-07-01',
118
+ domain: 'ALL',
119
+ skills: { tooluse: true },
120
+ },
121
+ }),
122
+ },
123
+ /**
124
+ * deepseek-v3.1
125
+ * .sources:
126
+ * - rates: https://www.together.ai/pricing ($1.25/1M input, $1.25/1M output)
127
+ * - context: 128K
128
+ * - architecture: 671B total, 37B active (moe)
129
+ */
130
+ 'together/deepseek/v3.1': {
131
+ model: 'deepseek-ai/DeepSeek-V3.1',
132
+ description: 'deepseek-v3.1 - frontier open-source (128K)',
133
+ spec: new rhachet_1.BrainSpec({
134
+ cost: {
135
+ time: {
136
+ speed: { tokens: 100, per: { seconds: 1 } },
137
+ latency: { seconds: 1 },
138
+ },
139
+ cash: {
140
+ per: 'token',
141
+ cache: {
142
+ get: (0, iso_price_1.asIsoPrice)('$0'),
143
+ set: (0, iso_price_1.asIsoPrice)('$0'),
144
+ },
145
+ input: (0, iso_price_1.dividePrice)({ of: '$1.25', by: 1000000 }), // $1.25/1M tokens
146
+ output: (0, iso_price_1.dividePrice)({ of: '$1.25', by: 1000000 }), // $1.25/1M tokens
147
+ },
148
+ },
149
+ gain: {
150
+ size: { context: { tokens: 128000 } }, // 128K context
151
+ grades: {},
152
+ cutoff: '2025-03-01',
153
+ domain: 'ALL',
154
+ skills: { tooluse: true },
155
+ },
156
+ }),
157
+ },
158
+ /**
159
+ * deepseek-r1
160
+ * .sources:
161
+ * - rates: https://www.together.ai/pricing ($3.00/1M input, $7.00/1M output)
162
+ * - context: 128K
163
+ * - architecture: 671B total, 37B active (moe), chain-of-thought
164
+ */
165
+ 'together/deepseek/r1': {
166
+ model: 'deepseek-ai/DeepSeek-R1',
167
+ description: 'deepseek-r1 - chain-of-thought (128K)',
168
+ spec: new rhachet_1.BrainSpec({
169
+ cost: {
170
+ time: {
171
+ speed: { tokens: 60, per: { seconds: 1 } },
172
+ latency: { seconds: 1.5 },
173
+ },
174
+ cash: {
175
+ per: 'token',
176
+ cache: {
177
+ get: (0, iso_price_1.asIsoPrice)('$0'),
178
+ set: (0, iso_price_1.asIsoPrice)('$0'),
179
+ },
180
+ input: (0, iso_price_1.dividePrice)({ of: '$3.00', by: 1000000 }), // $3.00/1M tokens
181
+ output: (0, iso_price_1.dividePrice)({ of: '$7.00', by: 1000000 }), // $7.00/1M tokens
182
+ },
183
+ },
184
+ gain: {
185
+ size: { context: { tokens: 128000 } }, // 128K context
186
+ grades: {},
187
+ cutoff: '2025-03-01',
188
+ domain: 'ALL',
189
+ skills: { tooluse: true },
190
+ },
191
+ }),
192
+ },
193
+ /**
194
+ * kimi-k2
195
+ * .sources:
196
+ * - rates: https://www.together.ai/pricing ($1.00/1M input, $3.00/1M output)
197
+ * - context: 128K
198
+ * - architecture: 1T total (moe)
199
+ */
200
+ 'together/kimi/k2': {
201
+ model: 'moonshotai/Kimi-K2-Instruct',
202
+ description: 'kimi-k2 - large general purpose (128K)',
203
+ spec: new rhachet_1.BrainSpec({
204
+ cost: {
205
+ time: {
206
+ speed: { tokens: 80, per: { seconds: 1 } },
207
+ latency: { seconds: 1 },
208
+ },
209
+ cash: {
210
+ per: 'token',
211
+ cache: {
212
+ get: (0, iso_price_1.asIsoPrice)('$0'),
213
+ set: (0, iso_price_1.asIsoPrice)('$0'),
214
+ },
215
+ input: (0, iso_price_1.dividePrice)({ of: '$1.00', by: 1000000 }), // $1.00/1M tokens
216
+ output: (0, iso_price_1.dividePrice)({ of: '$3.00', by: 1000000 }), // $3.00/1M tokens
217
+ },
218
+ },
219
+ gain: {
220
+ size: { context: { tokens: 128000 } }, // 128K context
221
+ grades: {},
222
+ cutoff: '2025-06-01',
223
+ domain: 'ALL',
224
+ skills: { tooluse: true },
225
+ },
226
+ }),
227
+ },
228
+ /**
229
+ * kimi-k2.5
230
+ * .sources:
231
+ * - rates: https://www.together.ai/pricing ($0.50/1M input, $2.80/1M output)
232
+ * - context: 128K
233
+ * - swe-bench: 76.8% verified
234
+ */
235
+ 'together/kimi/k2.5': {
236
+ model: 'moonshotai/Kimi-K2.5',
237
+ description: 'kimi-k2.5 - best swe-bench on together ai (128K)',
238
+ spec: new rhachet_1.BrainSpec({
239
+ cost: {
240
+ time: {
241
+ speed: { tokens: 100, per: { seconds: 1 } },
242
+ latency: { seconds: 0.8 },
243
+ },
244
+ cash: {
245
+ per: 'token',
246
+ cache: {
247
+ get: (0, iso_price_1.asIsoPrice)('$0'),
248
+ set: (0, iso_price_1.asIsoPrice)('$0'),
249
+ },
250
+ input: (0, iso_price_1.dividePrice)({ of: '$0.50', by: 1000000 }), // $0.50/1M tokens
251
+ output: (0, iso_price_1.dividePrice)({ of: '$2.80', by: 1000000 }), // $2.80/1M tokens
252
+ },
253
+ },
254
+ gain: {
255
+ size: { context: { tokens: 128000 } }, // 128K context
256
+ grades: { swe: 76.8 }, // 76.8% swe-bench verified
257
+ cutoff: '2025-07-01',
258
+ domain: 'ALL',
259
+ skills: { tooluse: true },
260
+ },
261
+ }),
262
+ },
263
+ /**
264
+ * llama-4-maverick
265
+ * .sources:
266
+ * - rates: https://www.together.ai/pricing ($0.27/1M input, $0.85/1M output)
267
+ * - context: 1M
268
+ * - architecture: 17B active, 128 experts (moe)
269
+ */
270
+ 'together/llama4/maverick': {
271
+ model: 'meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8',
272
+ description: 'llama-4-maverick - large context (1M)',
273
+ spec: new rhachet_1.BrainSpec({
274
+ cost: {
275
+ time: {
276
+ speed: { tokens: 120, per: { seconds: 1 } },
277
+ latency: { seconds: 0.5 },
278
+ },
279
+ cash: {
280
+ per: 'token',
281
+ cache: {
282
+ get: (0, iso_price_1.asIsoPrice)('$0'),
283
+ set: (0, iso_price_1.asIsoPrice)('$0'),
284
+ },
285
+ input: (0, iso_price_1.dividePrice)({ of: '$0.27', by: 1000000 }), // $0.27/1M tokens
286
+ output: (0, iso_price_1.dividePrice)({ of: '$0.85', by: 1000000 }), // $0.85/1M tokens
287
+ },
288
+ },
289
+ gain: {
290
+ size: { context: { tokens: 1000000 } }, // 1M context
291
+ grades: {},
292
+ cutoff: '2025-03-01',
293
+ domain: 'ALL',
294
+ skills: { tooluse: true },
295
+ },
296
+ }),
297
+ },
298
+ /**
299
+ * llama-3.3-70b
300
+ * .sources:
301
+ * - rates: https://www.together.ai/pricing ($0.88/1M input, $0.88/1M output)
302
+ * - context: 128K
303
+ * - architecture: 70B dense
304
+ */
305
+ 'together/llama3.3/70b': {
306
+ model: 'meta-llama/Llama-3.3-70B-Instruct-Turbo',
307
+ description: 'llama-3.3-70b - balanced dense model (128K)',
308
+ spec: new rhachet_1.BrainSpec({
309
+ cost: {
310
+ time: {
311
+ speed: { tokens: 150, per: { seconds: 1 } },
312
+ latency: { seconds: 0.4 },
313
+ },
314
+ cash: {
315
+ per: 'token',
316
+ cache: {
317
+ get: (0, iso_price_1.asIsoPrice)('$0'),
318
+ set: (0, iso_price_1.asIsoPrice)('$0'),
319
+ },
320
+ input: (0, iso_price_1.dividePrice)({ of: '$0.88', by: 1000000 }), // $0.88/1M tokens
321
+ output: (0, iso_price_1.dividePrice)({ of: '$0.88', by: 1000000 }), // $0.88/1M tokens
322
+ },
323
+ },
324
+ gain: {
325
+ size: { context: { tokens: 128000 } }, // 128K context
326
+ grades: {},
327
+ cutoff: '2024-12-01',
328
+ domain: 'ALL',
329
+ skills: { tooluse: true },
330
+ },
331
+ }),
332
+ },
333
+ /**
334
+ * glm-4.7
335
+ * .sources:
336
+ * - rates: https://www.together.ai/pricing ($0.45/1M input, $2.00/1M output)
337
+ * - context: 128K
338
+ * - swe-bench: 73.8% verified
339
+ */
340
+ 'together/glm/4.7': {
341
+ model: 'zai-org/GLM-4.7',
342
+ description: 'glm-4.7 - strong code + general (128K)',
343
+ spec: new rhachet_1.BrainSpec({
344
+ cost: {
345
+ time: {
346
+ speed: { tokens: 100, per: { seconds: 1 } },
347
+ latency: { seconds: 0.8 },
348
+ },
349
+ cash: {
350
+ per: 'token',
351
+ cache: {
352
+ get: (0, iso_price_1.asIsoPrice)('$0'),
353
+ set: (0, iso_price_1.asIsoPrice)('$0'),
354
+ },
355
+ input: (0, iso_price_1.dividePrice)({ of: '$0.45', by: 1000000 }), // $0.45/1M tokens
356
+ output: (0, iso_price_1.dividePrice)({ of: '$2.00', by: 1000000 }), // $2.00/1M tokens
357
+ },
358
+ },
359
+ gain: {
360
+ size: { context: { tokens: 128000 } }, // 128K context
361
+ grades: { swe: 73.8 }, // 73.8% swe-bench verified
362
+ cutoff: '2025-06-01',
363
+ domain: 'ALL',
364
+ skills: { tooluse: true },
365
+ },
366
+ }),
367
+ },
368
+ };
369
+ //# 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;AA4BpC;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAG5B;IACF;;;;;;;OAOG;IACH,2BAA2B,EAAE;QAC3B,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,0DAA0D;QACvE,IAAI,EAAE,IAAI,mBAAS,CAAC;YAClB,IAAI,EAAE;gBACJ,IAAI,EAAE;oBACJ,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;oBAC3C,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;iBAC1B;gBACD,IAAI,EAAE;oBACJ,GAAG,EAAE,OAAO;oBACZ,KAAK,EAAE;wBACL,GAAG,EAAE,IAAA,sBAAU,EAAC,IAAI,CAAC,EAAE,+BAA+B;wBACtD,GAAG,EAAE,IAAA,sBAAU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MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;oBAC3C,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;iBAC1B;gBACD,IAAI,EAAE;oBACJ,GAAG,EAAE,OAAO;oBACZ,KAAK,EAAE;wBACL,GAAG,EAAE,IAAA,sBAAU,EAAC,IAAI,CAAC;wBACrB,GAAG,EAAE,IAAA,sBAAU,EAAC,IAAI,CAAC;qBACtB;oBACD,KAAK,EAAE,IAAA,uBAAW,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAS,EAAE,CAAC,EAAE,kBAAkB;oBACtE,MAAM,EAAE,IAAA,uBAAW,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAS,EAAE,CAAC,EAAE,kBAAkB;iBACxE;aACF;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAO,EAAE,EAAE,EAAE,eAAe;gBACvD,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,2BAA2B;gBAClD,MAAM,EAAE,YAAY;gBACpB,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;aAC1B;SACF,CAAC;KACH;CACF,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { BrainAtom } from 'rhachet/brains';
2
+ import { type TogetherBrainAtomSlug } from './BrainAtom.config';
3
+ export type { TogetherBrainAtomSlug } from './BrainAtom.config';
4
+ /**
5
+ * .what = factory to generate together ai brain atom instances
6
+ * .why = enables model variant selection via slug
7
+ *
8
+ * .note = together ai api is openai-compatible with baseURL override
9
+ *
10
+ * .example
11
+ * genBrainAtom({ slug: 'together/qwen3/coder-next' })
12
+ * genBrainAtom({ slug: 'together/llama3.3/70b' }) // fast + cheap
13
+ * genBrainAtom({ slug: 'together/kimi/k2.5' }) // best swe-bench
14
+ */
15
+ export declare const genBrainAtom: (input: {
16
+ slug: TogetherBrainAtomSlug;
17
+ }) => BrainAtom;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.genBrainAtom = void 0;
7
+ const openai_1 = __importDefault(require("openai"));
8
+ const brains_1 = require("rhachet/brains");
9
+ const zod_1 = require("zod");
10
+ const BrainAtom_config_1 = require("./BrainAtom.config");
11
+ /**
12
+ * .what = factory to generate together ai brain atom instances
13
+ * .why = enables model variant selection via slug
14
+ *
15
+ * .note = together ai api is openai-compatible with baseURL override
16
+ *
17
+ * .example
18
+ * genBrainAtom({ slug: 'together/qwen3/coder-next' })
19
+ * genBrainAtom({ slug: 'together/llama3.3/70b' }) // fast + cheap
20
+ * genBrainAtom({ slug: 'together/kimi/k2.5' }) // best swe-bench
21
+ */
22
+ const genBrainAtom = (input) => {
23
+ const config = BrainAtom_config_1.CONFIG_BY_ATOM_SLUG[input.slug];
24
+ return new brains_1.BrainAtom({
25
+ repo: 'together',
26
+ slug: input.slug,
27
+ description: config.description,
28
+ spec: config.spec,
29
+ /**
30
+ * .what = stateless inference (no tool use)
31
+ * .why = provides direct model access for tasks
32
+ *
33
+ * .note = supports continuation via `on.episode`
34
+ */
35
+ ask: async (askInput, context) => {
36
+ // track start time for elapsed duration
37
+ const startedAt = Date.now();
38
+ // compose system prompt from briefs
39
+ const systemPrompt = askInput.role.briefs
40
+ ? await (0, brains_1.castBriefsToPrompt)({ briefs: askInput.role.briefs })
41
+ : undefined;
42
+ // get openai client from context or create new one with together ai baseURL
43
+ const openai = context?.openai ??
44
+ new openai_1.default({
45
+ apiKey: process.env.TOGETHER_API_KEY,
46
+ baseURL: 'https://api.together.xyz/v1',
47
+ });
48
+ // build messages array with prior exchanges for continuation
49
+ const messages = [];
50
+ if (systemPrompt) {
51
+ messages.push({ role: 'system', content: systemPrompt });
52
+ }
53
+ if (askInput.on?.episode) {
54
+ for (const exchange of askInput.on.episode.exchanges) {
55
+ messages.push({ role: 'user', content: exchange.input });
56
+ messages.push({ role: 'assistant', content: exchange.output });
57
+ }
58
+ }
59
+ messages.push({ role: 'user', content: askInput.prompt });
60
+ // convert zod schema to json schema for structured output
61
+ const jsonSchema = zod_1.z.toJSONSchema(askInput.schema.output);
62
+ // call together ai api with strict json_schema response format
63
+ const response = await openai.chat.completions.create({
64
+ model: config.model,
65
+ messages,
66
+ response_format: {
67
+ type: 'json_schema',
68
+ json_schema: {
69
+ name: 'response',
70
+ strict: true,
71
+ schema: jsonSchema,
72
+ },
73
+ },
74
+ });
75
+ // extract content from response
76
+ const content = response.choices[0]?.message?.content ?? '';
77
+ // parse JSON response and validate via schema
78
+ const parsed = JSON.parse(content);
79
+ const output = askInput.schema.output.parse(parsed);
80
+ // calculate elapsed time
81
+ const elapsedMs = Date.now() - startedAt;
82
+ // extract token usage from response
83
+ const tokensInput = response.usage?.prompt_tokens ?? 0;
84
+ const tokensOutput = response.usage?.completion_tokens ?? 0;
85
+ const tokensCached = response.usage?.prompt_tokens_details?.cached_tokens ?? 0;
86
+ // calculate character counts
87
+ const charsInput = (systemPrompt?.length ?? 0) + askInput.prompt.length;
88
+ const charsOutput = content.length;
89
+ // define size for metrics and cost calculation
90
+ const size = {
91
+ tokens: {
92
+ input: tokensInput,
93
+ output: tokensOutput,
94
+ cache: { get: tokensCached, set: 0 },
95
+ },
96
+ chars: {
97
+ input: charsInput,
98
+ output: charsOutput,
99
+ cache: { get: 0, set: 0 },
100
+ },
101
+ };
102
+ // calculate cash costs via rhachet utility
103
+ const { cash } = (0, brains_1.calcBrainOutputCost)({
104
+ for: { tokens: size.tokens },
105
+ with: { cost: { cash: config.spec.cost.cash } },
106
+ });
107
+ // build metrics
108
+ const metrics = new brains_1.BrainOutputMetrics({
109
+ size,
110
+ cost: {
111
+ time: { milliseconds: elapsedMs },
112
+ cash,
113
+ },
114
+ });
115
+ // build continuables (episode + series) for this invocation
116
+ const { episode, series } = await (0, brains_1.genBrainContinuables)({
117
+ for: { grain: 'atom' },
118
+ on: { episode: askInput.on?.episode ?? null, series: null },
119
+ with: {
120
+ exchange: {
121
+ input: askInput.prompt,
122
+ output: content,
123
+ exid: response.id ?? null,
124
+ },
125
+ episode: { exid: response.id ?? null },
126
+ },
127
+ });
128
+ return new brains_1.BrainOutput({ output, metrics, episode, series });
129
+ },
130
+ });
131
+ };
132
+ exports.genBrainAtom = genBrainAtom;
133
+ //# sourceMappingURL=genBrainAtom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genBrainAtom.js","sourceRoot":"","sources":["../../../src/domain.operations/atom/genBrainAtom.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2CASwB;AAIxB,6BAAwB;AAExB,yDAG4B;AAK5B;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,CAAC,KAE5B,EAAa,EAAE;IACd,MAAM,MAAM,GAAG,sCAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,IAAI,kBAAS,CAAC;QACnB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,IAAI,EAAE,MAAM,CAAC,IAAI;QAEjB;;;;;WAKG;QACH,GAAG,EAAE,KAAK,EACR,QAMC,EACD,OAAe,EACwB,EAAE;YACzC,wCAAwC;YACxC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE7B,oCAAoC;YACpC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM;gBACvC,CAAC,CAAC,MAAM,IAAA,2BAAkB,EAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC5D,CAAC,CAAC,SAAS,CAAC;YAEd,4EAA4E;YAC5E,MAAM,MAAM,GACT,OA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AAA,4BAAmB,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,2BAAkB,CAAC;gBACrC,IAAI;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE;oBACjC,IAAI;iBACL;aACF,CAAC,CAAC;YAEH,4DAA4D;YAC5D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,6BAAoB,EAAC;gBACrD,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;gBACtB,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;gBAC3D,IAAI,EAAE;oBACJ,QAAQ,EAAE;wBACR,KAAK,EAAE,QAAQ,CAAC,MAAM;wBACtB,MAAM,EAAE,OAAO;wBACf,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,IAAI;qBAC1B;oBACD,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,IAAI,EAAE;iBACvC;aACF,CAAC,CAAC;YAEH,OAAO,IAAI,oBAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/D,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA/IW,QAAA,YAAY,gBA+IvB"}
@@ -0,0 +1 @@
1
+ export * from './contract/sdk';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./contract/sdk"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
package/license.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 ehmpathy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "rhachet-brains-togetherai",
3
+ "author": "ehmpathy",
4
+ "description": "rhachet brain.atom adapter for together ai open-source models",
5
+ "version": "0.0.1",
6
+ "repository": "ehmpathy/rhachet-brains-togetherai",
7
+ "homepage": "https://github.com/ehmpathy/rhachet-brains-togetherai",
8
+ "keywords": [
9
+ "together",
10
+ "togetherai",
11
+ "qwen",
12
+ "deepseek",
13
+ "llama",
14
+ "open-source",
15
+ "rhachet",
16
+ "brain",
17
+ "llm",
18
+ "ai"
19
+ ],
20
+ "bugs": "https://github.com/ehmpathy/rhachet-brains-togetherai/issues",
21
+ "license": "MIT",
22
+ "main": "dist/index.js",
23
+ "engines": {
24
+ "node": ">=8.0.0"
25
+ },
26
+ "files": [
27
+ "/dist"
28
+ ],
29
+ "dependencies": {
30
+ "domain-objects": "0.31.9",
31
+ "helpful-errors": "1.5.3",
32
+ "iso-price": "1.1.1",
33
+ "openai": "5.8.2",
34
+ "rhachet-artifact": "1.0.1",
35
+ "rhachet-artifact-git": "1.1.5",
36
+ "rhachet-roles-bhrain": "0.7.5",
37
+ "type-fns": "1.21.0",
38
+ "zod": "4.3.4"
39
+ },
40
+ "peerDependencies": {
41
+ "rhachet": ">=1.21.4"
42
+ },
43
+ "devDependencies": {
44
+ "@biomejs/biome": "2.3.8",
45
+ "@commitlint/cli": "19.5.0",
46
+ "@commitlint/config-conventional": "19.5.0",
47
+ "@swc/core": "1.15.3",
48
+ "@swc/jest": "0.2.39",
49
+ "@tsconfig/node20": "20.1.5",
50
+ "@tsconfig/strictest": "2.0.5",
51
+ "@types/jest": "30.0.0",
52
+ "@types/node": "22.15.21",
53
+ "cz-conventional-changelog": "3.3.0",
54
+ "declapract": "0.13.14",
55
+ "declapract-typescript-ehmpathy": "0.47.16",
56
+ "declastruct": "1.7.3",
57
+ "declastruct-github": "1.3.0",
58
+ "depcheck": "1.4.3",
59
+ "esbuild-register": "3.6.0",
60
+ "husky": "8.0.3",
61
+ "jest": "30.2.0",
62
+ "rhachet": "1.29.5",
63
+ "rhachet-brains-anthropic": "0.3.2",
64
+ "rhachet-roles-bhuild": "0.7.0",
65
+ "rhachet-roles-ehmpathy": "1.18.0",
66
+ "test-fns": "1.10.0",
67
+ "tsc-alias": "1.8.10",
68
+ "tsx": "4.20.6",
69
+ "typescript": "5.4.5",
70
+ "yalc": "1.0.0-pre.53"
71
+ },
72
+ "config": {
73
+ "commitizen": {
74
+ "path": "./node_modules/cz-conventional-changelog"
75
+ }
76
+ },
77
+ "scripts": {
78
+ "build:ts": "tsc -p ./tsconfig.build.json",
79
+ "commit:with-cli": "npx cz",
80
+ "fix:format:biome": "biome check --write",
81
+ "fix:format": "npm run fix:format:biome",
82
+ "fix:lint": "biome check --write",
83
+ "fix": "npm run fix:format && npm run fix:lint",
84
+ "build:clean:bun": "rm -f ./bin/*.bc",
85
+ "build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
86
+ "build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
87
+ "build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
88
+ "build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
89
+ "build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
90
+ "test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
91
+ "test:types": "tsc -p ./tsconfig.json --noEmit",
92
+ "test:format:biome": "biome format",
93
+ "test:format": "npm run test:format:biome",
94
+ "test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
95
+ "test:lint:biome": "biome check --diagnostic-level=error",
96
+ "test:lint:biome:all": "biome check",
97
+ "test:lint": "npm run test:lint:biome && npm run test:lint:deps",
98
+ "test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
99
+ "test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
100
+ "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
101
+ "test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
102
+ "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
103
+ "prepush": "npm run test && npm run build",
104
+ "prepublish": "npm run build",
105
+ "preversion": "npm run prepush",
106
+ "postversion": "git push origin HEAD --tags --no-verify",
107
+ "prepare:husky": "husky install && chmod ug+x .husky/*",
108
+ "prepare:rhachet": "rhachet init --roles behaver mechanic reviewer --hooks"
109
+ }
110
+ }
package/readme.md ADDED
@@ -0,0 +1,85 @@
1
+ # rhachet-brains-togetherai
2
+
3
+ rhachet brain.atom adapter for together ai open-source models
4
+
5
+ ## install
6
+
7
+ ```sh
8
+ npm install rhachet-brains-togetherai
9
+ ```
10
+
11
+ ## usage
12
+
13
+ ```ts
14
+ import { genBrainAtom } from 'rhachet-brains-togetherai';
15
+ import { z } from 'zod';
16
+
17
+ // create a brain atom for direct model inference
18
+ const brainAtom = genBrainAtom({ slug: 'together/qwen3/coder-next' });
19
+
20
+ // simple string output
21
+ const { output: explanation } = await brainAtom.ask({
22
+ role: { briefs: [] },
23
+ prompt: 'explain this code',
24
+ schema: { output: z.string() },
25
+ });
26
+
27
+ // structured object output
28
+ const { output: { summary, issues } } = await brainAtom.ask({
29
+ role: { briefs: [] },
30
+ prompt: 'analyze this code',
31
+ schema: { output: z.object({ summary: z.string(), issues: z.array(z.string()) }) },
32
+ });
33
+ ```
34
+
35
+ ## available brains
36
+
37
+ ### atoms (via genBrainAtom)
38
+
39
+ stateless inference without tool use.
40
+
41
+ | slug | model id | context | swe-bench | input | output |
42
+ | --- | --- | --- | --- | --- | --- |
43
+ | `together/qwen3/coder-next` | Qwen/Qwen3-Coder-Next-FP8 | 262K | 74.2% | $0.50/1M | $1.20/1M |
44
+ | `together/qwen3/coder-480b` | Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 | 262K | 69.6% | $2.00/1M | $2.00/1M |
45
+ | `together/qwen3/235b` | Qwen/Qwen3-235B-A22B-Instruct-2507-tput | 131K | — | $0.20/1M | $0.60/1M |
46
+ | `together/deepseek/v3.1` | deepseek-ai/DeepSeek-V3.1 | 128K | — | $1.25/1M | $1.25/1M |
47
+ | `together/deepseek/r1` | deepseek-ai/DeepSeek-R1 | 128K | — | $3.00/1M | $7.00/1M |
48
+ | `together/kimi/k2` | moonshotai/Kimi-K2-Instruct | 128K | — | $1.00/1M | $3.00/1M |
49
+ | `together/kimi/k2.5` | moonshotai/Kimi-K2.5 | 128K | 76.8% | $0.50/1M | $2.80/1M |
50
+ | `together/llama4/maverick` | meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 | 1M | — | $0.27/1M | $0.85/1M |
51
+ | `together/llama3.3/70b` | meta-llama/Llama-3.3-70B-Instruct-Turbo | 128K | — | $0.88/1M | $0.88/1M |
52
+ | `together/glm/4.7` | zai-org/GLM-4.7 | 128K | 73.8% | $0.45/1M | $2.00/1M |
53
+
54
+ ## why together ai
55
+
56
+ together ai rates include managed fine-tune access ($6-10/1M tokens) and high-throughput serverless infrastructure. some model authors offer cheaper direct apis for inference-only:
57
+
58
+ | model | together ai (in/out) | author direct (in/out) | author api |
59
+ | --- | --- | --- | --- |
60
+ | deepseek v3 | $1.25/$1.25 | **$0.28/$0.42** (3-4x cheaper) | [api.deepseek.com](https://api-docs.deepseek.com/quick_start/pricing) |
61
+ | deepseek r1 | $3.00/$7.00 | **$0.28/$0.42** (10-17x cheaper) | [api.deepseek.com](https://api-docs.deepseek.com/quick_start/pricing) |
62
+ | kimi k2 | $1.00/$3.00 | **$0.60/$2.50** (~35% cheaper) | [platform.moonshot.ai](https://platform.moonshot.ai/docs/pricing/chat) |
63
+ | kimi k2.5 | $0.50/$2.80 | $0.60/$3.00 (at parity) | [platform.moonshot.ai](https://platform.moonshot.ai/docs/pricing/chat) |
64
+ | qwen3 coder-next | **$0.50/$1.20** | $1.00/$5.00 (together ai cheaper) | [alibabacloud.com](https://www.alibabacloud.com/help/en/model-studio/model-pricing) |
65
+ | glm-4.7 | **$0.45/$2.00** | $0.60/$2.20 (together ai cheaper) | [z.ai](https://docs.z.ai/guides/overview/pricing) |
66
+ | llama 4 maverick | $0.27/$0.85 | ~$0.27/$0.85 (at parity) | [llama.com](https://www.llama.com/products/llama-api/) |
67
+
68
+ **tldr:** deepseek's direct api is dramatically cheaper. kimi k2 is modestly cheaper via moonshot. the rest are at parity or more expensive than together ai. together ai's premium buys fine-tune access and unified multi-model infrastructure.
69
+
70
+ ## environment
71
+
72
+ requires `TOGETHER_API_KEY` environment variable.
73
+
74
+ get your api key at https://api.together.xyz/settings/api-keys
75
+
76
+ ## sources
77
+
78
+ - [together ai api docs](https://docs.together.ai/reference/chat-completions-1)
79
+ - [together ai models](https://docs.together.ai/docs/serverless-models)
80
+ - [together ai rates](https://www.together.ai/pricing)
81
+ - [deepseek rates](https://api-docs.deepseek.com/quick_start/pricing)
82
+ - [moonshot rates](https://platform.moonshot.ai/docs/pricing/chat)
83
+ - [alibaba model studio rates](https://www.alibabacloud.com/help/en/model-studio/model-pricing)
84
+ - [zhipu z.ai rates](https://docs.z.ai/guides/overview/pricing)
85
+ - [meta llama api](https://www.llama.com/products/llama-api/)