Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

together-facts.test.ts

252 lines9.1 KB

1import { describe, expect, it } from 'vitest'
2​
3import { cachedDocs } from './model-facts.ts'
4import {
5 TOGETHER_GLM_53_URL,
6 TOGETHER_GPT_OSS_URL,
7 TOGETHER_KIMI_K3_URL,
8 TOGETHER_REASONING_URL,
9 loadTogetherQuickstart,
10 loadTogetherReasoningPage,
11 loadTogetherServerlessChat,
12 parseTogetherChatCatalog,
13 parseTogetherQuickstartReasoning,
14 parseTogetherReasoning,
15 parseTogetherVisionModalities,
16} from './together-facts.ts'
17​
18/** Excerpt of https://docs.together.ai/docs/serverless/models.md (2026-10-07). */
19const MODELS_MD = `
20## Chat models
21​
22| Organization | Model name | API model string | Context length | Input pricing (per 1M tokens) | Cached input pricing (per 1M tokens) | Output pricing (per 1M tokens) | Quantization | Function calling | Structured outputs |
23| :- | :- | :- | :- | :- | :- | :- | :- | :- | :- |
24| Thinking Machines | Inkling | thinkingmachines/Inkling | 524288 | \\$1.00 | \\$0.17 | \\$4.05 | NVFP4 | Yes | Yes |
25| Qwen | Qwen3.8-2.4T-A95B | Qwen/Qwen3.8-2.4T-A95B | - | \\$2.00 | \\$0.50 | \\$6.00 | FP4 | - | - |
26| Qwen | Qwen3.6 Plus | Qwen/Qwen3.6-Plus | 1000000 | \\$0.50 | - | \\$3.00 | - | - | - |
27| Prism ML | Ternary Bonsai 27B | Prism-ML/Ternary-Bonsai-27B | 262144 | Free | - | Free | - | - | - |
28| Together AI | Tev1 4B Experimental | together/Tev1-4B-experimental | 32768 | \\$0.042 | - | Free | - | - | - |
29​
30## Vision models
31​
32| Organization | Model name | API model string | Context length | Input pricing (per 1M tokens) | Output pricing (per 1M tokens) |
33| :- | :- | :- | :- | :- | :- |
34| Qwen | Qwen3.5 9B | Qwen/Qwen3.5-9B | 262144 | \\$0.17 | \\$0.25 |
35| Minimax | Minimax M3 | MiniMaxAI/MiniMax-M3 | 524288 | \\$0.30 | \\$1.20 |
36| Moonshot | Kimi K3 | moonshotai/Kimi-K3 | 1048576 | \\$3.00 | \\$15.00 |
38​
39/**
40 * Excerpt of https://docs.together.ai/docs/inference/chat/reasoning.md
41 * (2026-10-07). The DeepSeek R1 row is added: the live table has no
42 * reasoning-only line, and a row of that type must not become an object.
43 */
44const REASONING_MD = `
45Reasoning models fall into a few behavioral types:
46​
47* **Reasoning only:** Always produces reasoning tokens. Cannot be toggled off.
48* **Hybrid:** Supports both reasoning and non-reasoning modes via \`reasoning={"enabled": True/False}\`.
49* **Adjustable effort:** Supports the \`reasoning_effort\` parameter to control reasoning depth (\`"low"\`, \`"medium"\`, or \`"high"\`).
50​
51## Supported models
52​
53| Model | API string | Type | Context length |
54| :- | :- | :- | :- |
55| MiniMax M3 | \`MiniMaxAI/MiniMax-M3\` | Hybrid (on by default) | 512K |
56| DeepSeek V4 Pro 0813 | \`deepseek-ai/DeepSeek-V4-Pro-0813\` | Hybrid (on by default) | 1M |
57| GLM-5.2 | \`zai-org/GLM-5.2\` | Hybrid (on by default) | 512K |
58| Kimi K3 | \`moonshotai/Kimi-K3\` | Hybrid (on by default) | 1M |
59| Qwen3.6 Plus | \`Qwen/Qwen3.6-Plus\` | Hybrid (on by default) | 1M |
60| Qwen3.5 9B | \`Qwen/Qwen3.5-9B\` | Hybrid (on by default) | 262K |
61| GPT-OSS 120B | \`openai/gpt-oss-120b\` | Adjustable effort | 128K |
62| DeepSeek R1 | \`deepseek-ai/DeepSeek-R1\` | Reasoning only | 128K |
63​
64## Reasoning effort
65​
66GPT-OSS models support a \`reasoning_effort\` parameter that controls how much computation the model spends on reasoning.
67​
68DeepSeek V4 Pro 0813 accepts only \`"high"\` and \`"max"\` for \`reasoning_effort\`. Other values are mapped automatically:
69​
70* \`"low"\` and \`"medium"\` map to \`"high"\`.
71* \`"high"\` and \`"xhigh"\` map to \`"max"\`.
73​
74/** Excerpt of https://docs.together.ai/docs/kimi-k3-quickstart.md (2026-10-07). */
75const KIMI_MD = `
76The model ID is \`moonshotai/Kimi-K3\`.
77​
78## Set the thinking effort
79​
80K3 thinks by default at \`reasoning_effort="max"\`. Lower the level to cut cost and latency:
81​
82* \`"low"\`: shallow reasoning.
83* \`"high"\`: deep reasoning.
84* \`"max"\`: maximum reasoning, the default.
85​
86To skip thinking entirely on trivial turns, pass \`reasoning={"enabled": False}\`.
87​
88## Sampling parameters
89​
90| Parameter | Behavior on Together |
91| - | - |
92| \`reasoning_effort\` | \`"low"\`, \`"medium"\`, \`"high"\`, or \`"max"\` (default). Invalid strings are accepted silently, so validate client-side. |
93| \`reasoning\` | \`{"enabled": False}\` disables thinking entirely. |
95​
96/** Excerpt of https://docs.together.ai/docs/glm-5.3-quickstart.md (2026-10-07). */
97const GLM_MD = `
98| Model | Model ID | Input / 1M tokens | Cached input / 1M tokens | Output / 1M tokens |
99| - | - | - | - | - |
100| GLM-5.3 | \`zai-org/GLM-5.3\` | \\$1.40 | \\$0.26 | \\$4.40 |
101| GLM-5.3 Flash | \`zai-org/GLM-5.3-Flash\` | \\$0.15 | \\$0.03 | \\$0.50 |
102​
103The examples below use \`zai-org/GLM-5.3\`. Swap in \`zai-org/GLM-5.3-Flash\` when cost and latency matter more than maximum depth.
104​
105## Set the reasoning effort
106​
107\`reasoning_effort\` accepts \`"low"\`, \`"medium"\`, \`"high"\`, and \`"max"\`.
108​
109Thinking cannot be disabled entirely on GLM-5.3.
110​
111\`\`\`python
112completion = client.chat.completions.create(
113 model="zai-org/GLM-5.3",
114 reasoning_effort="max",
116\`\`\`
118​
119/** Excerpt of https://docs.together.ai/docs/gpt-oss.md (2026-10-07). */
120const GPT_MD = `
121The model ID is \`openai/gpt-oss-120b\`.
122​
123The smaller \`openai/gpt-oss-20b\` was removed from serverless inference.
124​
125## Set the reasoning effort
126​
127\`reasoning_effort\` accepts \`"low"\`, \`"medium"\`, and \`"high"\`. The default is \`"medium"\`.
128​
129Reasoning cannot be disabled entirely.
131​
132describe('together chat catalog', () => {
133 it('reads context and standard per-million rates', () => {
134 const rows = parseTogetherChatCatalog(MODELS_MD)
135 expect(rows.get('thinkingmachines/Inkling')).toEqual({
136 contextWindow: 524288,
137 inputPerMillion: 1,
138 cachedPerMillion: 0.17,
139 outputPerMillion: 4.05,
140 })
141 expect(rows.get('Qwen/Qwen3.8-2.4T-A95B')?.contextWindow).toBeNull()
142 expect(rows.get('Qwen/Qwen3.6-Plus')).toMatchObject({
143 contextWindow: 1000000,
144 cachedPerMillion: null,
145 })
146 expect(rows.get('Prism-ML/Ternary-Bonsai-27B')).toMatchObject({
147 inputPerMillion: null,
148 outputPerMillion: null,
149 })
150 expect(rows.get('together/Tev1-4B-experimental')).toMatchObject({
151 inputPerMillion: 0.042,
152 outputPerMillion: null,
153 })
154 })
155​
156 it('reads the vision table as text and image in, text out', () => {
157 const vision = parseTogetherVisionModalities(MODELS_MD)
158 expect(vision.get('Qwen/Qwen3.5-9B')).toEqual({
159 input: ['text', 'image'],
160 output: ['text'],
161 })
162 expect(vision.size).toBe(3)
163 })
164})
165​
166describe('together reasoning guide', () => {
167 it('stores a toggle or the effort list the page names', () => {
168 const rows = parseTogetherReasoning(REASONING_MD)
169 expect(rows.get('MiniMaxAI/MiniMax-M3')).toEqual({
170 mode: 'toggle',
171 mandatory: false,
172 })
173 expect(rows.get('zai-org/GLM-5.2')).toEqual({
174 mode: 'toggle',
175 mandatory: false,
176 })
177 expect(rows.get('deepseek-ai/DeepSeek-V4-Pro-0813')).toEqual({
178 mode: 'effort',
179 mandatory: false,
180 efforts: ['high', 'max'],
181 })
182 expect(rows.get('openai/gpt-oss-120b')).toEqual({
183 mode: 'effort',
184 mandatory: null,
185 efforts: ['low', 'medium', 'high'],
186 })
187 expect(rows.has('deepseek-ai/DeepSeek-R1')).toBe(false)
188 })
189})
190​
191describe('together reasoning quickstarts', () => {
192 it('reads Kimi K3 levels from the parameter table, including medium', () => {
193 expect(
194 parseTogetherQuickstartReasoning(KIMI_MD).get('moonshotai/Kimi-K3'),
195 ).toEqual({
196 mode: 'effort',
197 mandatory: false,
198 efforts: ['low', 'medium', 'high', 'max'],
199 })
200 })
201​
202 it('does not copy GLM-5.3 efforts onto GLM-5.3 Flash', () => {
203 const rows = parseTogetherQuickstartReasoning(GLM_MD)
204 expect(rows.get('zai-org/GLM-5.3')).toEqual({
205 mode: 'effort',
206 mandatory: true,
207 efforts: ['low', 'medium', 'high', 'max'],
208 })
209 expect(rows.has('zai-org/GLM-5.3-Flash')).toBe(false)
210 })
211​
212 it('reads GPT-OSS as mandatory effort and ignores the removed 20B id', () => {
213 const rows = parseTogetherQuickstartReasoning(GPT_MD)
214 expect([...rows.keys()]).toEqual(['openai/gpt-oss-120b'])
215 expect(rows.get('openai/gpt-oss-120b')).toEqual({
216 mode: 'effort',
217 mandatory: true,
218 efforts: ['low', 'medium', 'high'],
219 })
220 })
221})
222​
223describe('together docs loaders', () => {
224 it('throws when a page parses no rows', async () => {
225 const original = globalThis.fetch
226 globalThis.fetch = () =>
227 Promise.resolve(new Response('# empty\n', { status: 200 }))
228 try {
229 await expect(
230 loadTogetherReasoningPage(undefined, cachedDocs),
231 ).rejects.toThrow(/together reasoning guide: parsed 0/)
232 await expect(
233 loadTogetherServerlessChat(undefined, cachedDocs),
234 ).rejects.toThrow(/together serverless chat catalog: parsed 0/)
235 await expect(
236 loadTogetherQuickstart(undefined, cachedDocs, TOGETHER_KIMI_K3_URL),
237 ).rejects.toThrow(/parsed 0/)
238 } finally {
239 globalThis.fetch = original
240 }
241 })
242​
243 it('fetches the published page urls', () => {
244 expect(TOGETHER_REASONING_URL).toBe(
245 'https://docs.together.ai/docs/inference/chat/reasoning.md',
246 )
247 expect(TOGETHER_GLM_53_URL).toContain('glm-5.3-quickstart.md')
248 expect(TOGETHER_GPT_OSS_URL).toBe(
249 'https://docs.together.ai/docs/gpt-oss.md',
250 )
251 })
252})