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

catalog-activity.test.ts

708 lines23.7 KB

1import { describe, expect, it } from 'vitest'
2​
3import { price } from '@modelschemas/rate-card'
4import type { RateCard } from '@modelschemas/rate-card'
5​
6import { provider as cerebras } from './adapters/cerebras.ts'
7import { provider as deepseek } from './adapters/deepseek.ts'
8import { dashscopeListedModel } from './adapters/dashscope.ts'
9import { provider as fireworks } from './adapters/fireworks.ts'
10import { provider as hyperbolic } from './adapters/hyperbolic.ts'
11import { provider as jina } from './adapters/jina.ts'
12import { provider as moonshot } from './adapters/moonshot.ts'
13import { provider as novita } from './adapters/novita.ts'
14import { provider as perplexity } from './adapters/perplexity.ts'
15import { provider as sambanova } from './adapters/sambanova.ts'
16import { parseDeepseekPricing } from './deepseek-pricing.ts'
17import { parseFireworksPricing } from './fireworks-pricing.ts'
18import { parseMoonshotPricing } from './moonshot-pricing.ts'
19import { DEEPSEEK_THINKING_URL, KIMI_THINKING_URL } from './provider-replay.ts'
20import {
21 DEEPSEEK_REPLAY_FIXTURE,
22 KIMI_REPLAY_FIXTURE,
23} from './fixtures/provider-replay.ts'
24import {
25 cerebrasCatalogRows,
26 parseCerebrasModelPage,
27} from './cerebras-pricing.ts'
28​
29const DEEPSEEK_HTML = `
30<table>
31<tr><td>MODEL</td><td>deepseek-flash</td><td>deepseek-v4-pro</td></tr>
32<tr><td>PRICING</td></tr>
33<tr><td>OFF-PEAK</td><td>$0.003</td><td>$0.022</td></tr>
34<tr><td>PEAK</td><td>$0.006</td><td>$0.044</td></tr>
35<tr><td>OFF-PEAK</td><td>$0.15</td><td>$0.66</td></tr>
36<tr><td>PEAK</td><td>$0.3</td><td>$1.32</td></tr>
37<tr><td>OFF-PEAK</td><td>$0.6</td><td>$1.98</td></tr>
38<tr><td>PEAK</td><td>$1.2</td><td>$3.96</td></tr>
39<tr><td>Concurrency Limit</td><td>2500</td><td>500</td></tr>
40</table>`
41​
42const FIREWORKS_MD = `
43| Model | Standard | Priority |
44| - | - | - |
45| [DeepSeek V4.1 Flash](https://app.fireworks.ai/models/fireworks/deepseek-v4p1-flash) | $0.30 / $0.006 / $1.20 | $0.375 / $0.0075 / $1.50 |
46| [DeepSeek V4.1 Flash (US)](https://app.fireworks.ai/models/fireworks/deepseek-v4p1-flash) | $0.45 / $0.009 / $1.80 | $0.56 / $0.01 / $2.25 |
47| [Kimi K3 Fast](https://app.fireworks.ai/models/fireworks/kimi-k3) | $4.50 / $0.45 / $22.50 | — |
48| Less than 4B parameters | $0.10 |
50​
51const MOONSHOT_MD = `
52["kimi-k2.6", "1M tokens", <>{"$"}0.16</>, <>{"$"}0.95</>, <>{"$"}4.00</>, "262,144 tokens"],
53["kimi-k3", "1M tokens", <>{"$"}3.00</>, <>{"$"}6.00</>, <>{"$"}0.30</>, <>{"$"}3.00</>, <>{"$"}15.00</>, "1,048,576 tokens"],
55​
56const CEREBRAS_CATALOG = `
57| [OpenAI GPT OSS](/models/openai-oss) | \`gpt-oss-120b\` | 120 billion |
59​
60const CEREBRAS_PAGE = `
61<ModelInfo
62 modelId="gpt-oss-120b"
63 pricing={{
64 inputPrice: "$0.35 / M tokens",
65 outputPrice: "$0.75 / M tokens"
66 }}
67 inputOutput={{
68 inputFormats: ["text"],
69 outputFormats: ["text"]
70 }}
71 features={[
72 "Reasoning",
73 "Tool Calling"
74 ]}
75 contextLength={{
76 paidTiers: "131k tokens"
77 }}
78 maxOutput={{
79 freeTier: "32k tokens",
80 paidTiers: "40k tokens"
81 }}
82/>
84​
85function inputUsd(card: unknown): number {
86 return price(card as RateCard, {}, { input_tokens: 1e6, output_tokens: 0 })
88​
89function json(body: unknown): Response {
90 return new Response(JSON.stringify(body), {
91 status: 200,
92 headers: { 'content-type': 'application/json' },
93 })
95​
96async function withFetch(
97 handler: (url: string) => Response,
98 run: () => Promise<void>,
99): Promise<void> {
100 const original = globalThis.fetch
101 globalThis.fetch = ((url: string) =>
102 Promise.resolve(handler(String(url)))) as typeof fetch
103 try {
104 await run()
105 } finally {
106 globalThis.fetch = original
107 }
109​
110describe('deepseek pricing page', () => {
111 it('keeps the off-peak rate and drops a model the table does not name', () => {
112 const parsed = parseDeepseekPricing(DEEPSEEK_HTML)
113 expect(parsed.get('deepseek-flash')).toEqual({
114 cacheRead: 0.003,
115 input: 0.15,
116 output: 0.6,
117 })
118 expect(parsed.get('deepseek-v4-pro')?.input).toBe(0.66)
119 expect(parsed.has('deepseek-chat')).toBe(false)
120 })
121})
122​
123describe('fireworks pricing page', () => {
124 it('maps standard cells, skips US and size bands, and splits fast routers', () => {
125 const parsed = parseFireworksPricing(FIREWORKS_MD)
126 expect(parsed.get('accounts/fireworks/models/deepseek-v4p1-flash')).toEqual(
127 { input: 0.3, cacheRead: 0.006, output: 1.2 },
128 )
129 expect(parsed.get('accounts/fireworks/routers/kimi-k3-fast')?.input).toBe(
130 4.5,
131 )
132 expect(parsed.size).toBe(2)
133 })
134})
135​
136describe('moonshot pricing page', () => {
137 it('reads K2 cache columns and K3 cache-write columns', () => {
138 const parsed = parseMoonshotPricing(MOONSHOT_MD)
139 expect(parsed.get('kimi-k2.6')).toEqual({
140 cacheRead: 0.16,
141 input: 0.95,
142 output: 4,
143 })
144 expect(parsed.get('kimi-k3')?.cacheWrite).toBe(3)
145 expect(parsed.get('kimi-k3')?.cacheWrite1h).toBe(6)
146 })
147})
148​
149describe('cerebras model pages', () => {
150 it('reads the catalog link and the ModelInfo price', () => {
151 expect(cerebrasCatalogRows(CEREBRAS_CATALOG)).toEqual([
152 { slug: 'openai-oss', id: 'gpt-oss-120b' },
153 ])
154 const facts = parseCerebrasModelPage(CEREBRAS_PAGE)
155 expect(facts?.inputPerMillion).toBe(0.35)
156 expect(facts?.outputPerMillion).toBe(0.75)
157 expect(facts?.modalities).toEqual({ input: ['text'], output: ['text'] })
158 expect(facts?.capabilities).toEqual(['reasoning', 'tools'])
159 expect(facts?.maxOutput).toBe(40_000)
160 expect(facts?.contextWindow).toBe(131_000)
161 })
162​
163 it('prefers the paid parenthetical context window over 128k', () => {
164 const facts = parseCerebrasModelPage(`
165Context window: 64K tokens (65,536) for Free Trial and 128K tokens (131,072) for paid tiers and trial customers.
166<ModelInfo
167 contextLength={{
168 paidTiers: "128k tokens"
169 }}
170/>
171`)
172 expect(facts?.contextWindow).toBe(131_072)
173 })
174​
175 it('prefers the paid parenthetical output cap over 40k', () => {
176 const facts = parseCerebrasModelPage(`
177Maximum output: 32K tokens (32,768) for Free Trial and 40K tokens (40,960) for paid tiers.
178<ModelInfo
179 maxOutput={{
180 freeTier: "32k tokens",
181 paidTiers: "40k tokens"
182 }}
183/>
184`)
185 expect(facts?.maxOutput).toBe(40_960)
186 })
187})
188​
189describe('issue #109 listModels', () => {
190 it('sets deepseek activity and an off-peak card, and leaves an unpriced id null', async () => {
191 await withFetch(
192 (url) => {
193 if (url.includes('api.deepseek.com/models')) {
194 return json({
195 data: [
196 {
197 id: 'deepseek-flash',
198 output_modalities: ['text'],
199 input_modalities: ['text', 'image'],
200 effort: { supported_levels: ['high'] },
201 },
202 { id: 'deepseek-other' },
203 ],
204 })
205 }
206 if (url.includes('quick_start/pricing')) {
207 return new Response(DEEPSEEK_HTML, { status: 200 })
208 }
209 if (url === DEEPSEEK_THINKING_URL)
210 return new Response(DEEPSEEK_REPLAY_FIXTURE)
211 return new Response('missing', { status: 404 })
212 },
213 async () => {
214 const { models } = await deepseek.listModels({
215 DEEPSEEK_API_KEY: 'test',
216 })
217 const flash = models.find((model) => model.rawId === 'deepseek-flash')
218 const other = models.find((model) => model.rawId === 'deepseek-other')
219 expect(flash?.activity).toBe('chat')
220 expect(flash?.modalities).toEqual({
221 input: ['text', 'image'],
222 output: ['text'],
223 })
224 expect(flash?.pricing).toBeTruthy()
225 expect(inputUsd(flash?.pricing)).toBeCloseTo(0.15, 9)
226 expect(other?.activity).toBeNull()
227 expect(other?.pricing ?? null).toBeNull()
228 },
229 )
230 })
231​
232 it('prices a cerebras chat row from its model page and leaves an unlisted id null', async () => {
233 await withFetch(
234 (url) => {
235 if (url.includes('api.cerebras.ai')) {
236 return json({
237 data: [{ id: 'gpt-oss-120b' }, { id: 'not-on-the-page' }],
238 })
239 }
240 if (url.endsWith('/models/overview.md')) {
241 return new Response(CEREBRAS_CATALOG, { status: 200 })
242 }
243 if (url.endsWith('/models/openai-oss.md')) {
244 return new Response(CEREBRAS_PAGE, { status: 200 })
245 }
246 if (url.endsWith('/capabilities/reasoning.md')) {
247 return new Response(
248 `
249| Model | Default | \`reasoning_effort\` | Disable reasoning | Availability |
250| - | - | - | - | - |
251| [\`gpt-oss-120b\`](/models/openai-oss) | \`medium\` | \`low\`, \`medium\`, \`high\` | Not supported | Shared Inference |
252| \`kimi-k2.7-code\` | Always enabled | Accepted but ignored | Not supported | Customer trials only |
253`,
254 { status: 200 },
255 )
256 }
257 if (url.endsWith('/openapi.yaml')) {
258 return new Response(
259 `
260 max_completion_tokens:
261 type: integer
262 description: The maximum number of tokens that can be generated.
263 max_tokens:
264 type: integer
265 description: >
266 An alias for \`max_completion_tokens\`. Do not send both parameters
267 in the same request.
268 Developer messages are supported only by \`gpt-oss-120b\`.
269`,
270 { status: 200 },
271 )
272 }
273 return new Response('missing', { status: 404 })
274 },
275 async () => {
276 const { models } = await cerebras.listModels({
277 CEREBRAS_API_KEY: 'test',
278 })
279 const priced = models.find((model) => model.rawId === 'gpt-oss-120b')
280 const bare = models.find((model) => model.rawId === 'not-on-the-page')
281 expect(priced?.activity).toBe('chat')
282 expect(priced?.modalities).toEqual({
283 input: ['text'],
284 output: ['text'],
285 })
286 expect(inputUsd(priced?.pricing)).toBeCloseTo(0.35, 9)
287 expect(priced?.maxOutput).toBe(40_000)
288 expect(priced?.reasoning).toEqual({
289 mode: 'effort',
290 mandatory: true,
291 efforts: ['low', 'medium', 'high'],
292 })
293 expect(priced?.requestMap).toMatchObject({
294 maxTokensField: 'max_completion_tokens',
295 developerRole: true,
296 reasoningEffort: true,
297 thinking: {
298 on: { reasoning_effort: 'high' },
299 off: null,
300 },
301 })
302 expect(priced?.factSources?.maxOutput?.sourceUrl).toBe(
303 'https://inference-docs.cerebras.ai/models/openai-oss.md',
304 )
305 expect(priced?.factSources?.reasoning?.sourceUrl).toBe(
306 'https://inference-docs.cerebras.ai/capabilities/reasoning.md',
307 )
308 expect(bare?.activity).toBe('chat')
309 expect(bare?.pricing ?? null).toBeNull()
310 expect(bare?.maxOutput ?? null).toBeNull()
311 expect(bare?.reasoning ?? null).toBeNull()
312 expect(bare?.requestMap?.developerRole).toBe(false)
313 expect(bare?.requestMap?.maxTokensField).toBe('max_completion_tokens')
314 },
315 )
316 })
317​
318 it('prices moonshot from the docs table and keeps a zero quote null', async () => {
319 await withFetch(
320 (url) => {
321 if (url.includes('api.moonshot.ai')) {
322 return json({
323 data: [
324 {
325 id: 'kimi-k2.6',
326 supports_image_in: true,
327 supports_video_in: false,
328 supports_reasoning: true,
329 context_length: 262144,
330 },
331 { id: 'kimi-free' },
332 ],
333 })
334 }
335 if (url.includes('pricing/chat.md')) {
336 return new Response(MOONSHOT_MD, { status: 200 })
337 }
338 if (url === KIMI_THINKING_URL) return new Response(KIMI_REPLAY_FIXTURE)
339 return new Response('missing', { status: 404 })
340 },
341 async () => {
342 const { models } = await moonshot.listModels({
343 MOONSHOT_API_KEY: 'test',
344 })
345 const kimi = models.find((model) => model.rawId === 'kimi-k2.6')
346 const free = models.find((model) => model.rawId === 'kimi-free')
347 expect(kimi?.activity).toBe('chat')
348 expect(kimi?.modalities).toEqual({
349 input: ['text', 'image'],
350 output: ['text'],
351 })
352 expect(kimi?.capabilities).toEqual(['reasoning'])
353 expect(inputUsd(kimi?.pricing)).toBeCloseTo(0.95, 9)
354 expect(free?.activity).toBe('chat')
355 expect(free?.pricing ?? null).toBeNull()
356 },
357 )
358 })
359​
360 it('prices a fireworks chat row and leaves a reranker and a missing price null', async () => {
361 await withFetch(
362 (url) => {
363 // This pricing-only synthetic case states no reasoning evidence.
364 // Distinguish model metadata from the inference listing response.
365 for (const id of ['deepseek-v4p1-flash', 'unpriced']) {
366 const name = 'accounts/fireworks/models/' + id
367 if (url === 'https://api.fireworks.ai/v1/' + name)
368 return json({ name, description: '' })
369 }
370 if (url.includes('api.fireworks.ai')) {
371 return json({
372 data: [
373 {
374 id: 'accounts/fireworks/models/deepseek-v4p1-flash',
375 kind: 'HF_BASE_MODEL',
376 supports_chat: true,
377 supports_image_input: true,
378 supports_tools: true,
379 },
380 {
381 id: 'accounts/fireworks/models/qwen3-reranker-8b',
382 kind: 'HF_BASE_MODEL',
383 supports_chat: true,
384 },
385 {
386 id: 'accounts/fireworks/models/unpriced',
387 kind: 'HF_BASE_MODEL',
388 supports_chat: true,
389 supports_image_input: false,
390 },
391 ],
392 })
393 }
394 if (url.includes('serverless/pricing.md')) {
395 return new Response(FIREWORKS_MD, { status: 200 })
396 }
397 return new Response('missing', { status: 404 })
398 },
399 async () => {
400 const { models } = await fireworks.listModels({
401 FIREWORKS_API_KEY: 'test',
402 })
403 const chat = models.find((model) => model.rawId.includes('deepseek'))
404 const rerank = models.find((model) => model.rawId.includes('reranker'))
405 const bare = models.find((model) => model.rawId.includes('unpriced'))
406 expect(chat?.activity).toBe('chat')
407 expect(chat?.modalities).toEqual({
408 input: ['text', 'image'],
409 output: ['text'],
410 })
411 expect(chat?.capabilities).toEqual(['tools'])
412 expect(inputUsd(chat?.pricing)).toBeCloseTo(0.3, 9)
413 expect(rerank?.activity).toBeNull()
414 expect(rerank?.pricing ?? null).toBeNull()
415 expect(bare?.activity).toBe('chat')
416 expect(bare?.pricing ?? null).toBeNull()
417 },
418 )
419 })
420​
421 it('compiles a novita decimal and leaves a tiered row null', async () => {
422 await withFetch(
423 () =>
424 json({
425 data: [
426 {
427 id: 'zai-org/glm',
428 model_type: 'chat',
429 input_modalities: ['text'],
430 output_modalities: ['text'],
431 features: ['function-calling'],
432 pricing: {
433 prompt: { price_per_m_decimal: '0.15' },
434 completion: { price_per_m_decimal: '0.5' },
435 },
436 },
437 {
438 id: 'tiered',
439 model_type: 'chat',
440 is_tiered_billing: true,
441 pricing: {
442 prompt: { price_per_m_decimal: '1' },
443 completion: { price_per_m_decimal: '2' },
444 },
445 },
446 ],
447 }),
448 async () => {
449 const { models } = await novita.listModels({ NOVITA_API_KEY: 'test' })
450 const chat = models.find((model) => model.rawId === 'zai-org/glm')
451 const tiered = models.find((model) => model.rawId === 'tiered')
452 expect(chat?.activity).toBe('chat')
453 expect(chat?.capabilities).toContain('tools')
454 expect(inputUsd(chat?.pricing)).toBeCloseTo(0.15, 9)
455 expect(tiered?.activity).toBe('chat')
456 expect(tiered?.pricing ?? null).toBeNull()
457 },
458 )
459 })
460​
461 it('compiles perplexity per-million quotes and rejects an untagged unit', async () => {
462 await withFetch(
463 (url) =>
464 url.endsWith('/models.md')
465 ? new Response('<Tab title="x">\n| `perplexity/sonar` | — |\n</Tab>')
466 : url.endsWith('/presets.md')
467 ? new Response(
468 '<Accordion title="x — current preset values">\n* **Model:** `a/b`\n* **Tools:** `web_search`\n</Accordion>',
469 )
470 : json({
471 data: [
472 {
473 id: 'perplexity/sonar',
474 pricing: { input: 1, output: 1, unit: 'usd_per_1m_tokens' },
475 },
476 {
477 id: 'mystery',
478 pricing: { input: 1, output: 1, unit: 'credits' },
479 },
480 ],
481 }),
482 async () => {
483 const { models } = await perplexity.listModels({
484 PERPLEXITY_API_KEY: 'test',
485 })
486 const sonar = models.find((model) => model.rawId === 'perplexity/sonar')
487 const mystery = models.find((model) => model.rawId === 'mystery')
488 expect(sonar?.activity).toBe('chat')
489 expect(inputUsd(sonar?.pricing)).toBeCloseTo(1, 9)
490 expect(
491 perplexity.generationEndpointId?.({
492 rawId: 'perplexity/sonar',
493 activity: 'chat',
494 }),
495 ).toBe('v1/agent')
496 expect(mystery?.pricing ?? null).toBeNull()
497 },
498 )
499 })
500​
501 it('sets jina activity from output modalities and skips an all-zero price', async () => {
502 const chatSpec = {
503 openapi: '3.1.0',
504 components: {
505 schemas: {
506 ChatCompletionRequest: {
507 type: 'object',
508 properties: {
509 messages: {
510 type: 'array',
511 items: { $ref: '#/components/schemas/ChatMessage' },
512 },
513 model: { type: 'string', const: 'jina-ocr-v1' },
514 max_completion_tokens: { type: 'integer', minimum: 1 },
515 },
516 required: ['messages', 'model'],
517 },
518 ChatMessage: {
519 type: 'object',
520 properties: {
521 role: {
522 type: 'string',
523 enum: ['system', 'developer', 'user', 'assistant'],
524 },
525 },
526 },
527 },
528 },
529 }
530 await withFetch(
531 (url) =>
532 url.endsWith('/openapi.json')
533 ? json(chatSpec)
534 : json({
535 data: [
536 {
537 id: 'jina-embeddings-v3',
538 output_modalities: ['embeddings'],
539 input_modalities: ['text'],
540 pricing: { prompt: '0.00000005', completion: '0' },
541 },
542 {
543 id: 'jina-reranker-v3',
544 output_modalities: ['text'],
545 input_modalities: ['text'],
546 pricing: { prompt: '0', completion: '0' },
547 },
548 ],
549 }),
550 async () => {
551 const { models } = await jina.listModels({ JINA_API_KEY: 'test' })
552 const embed = models.find((model) => model.rawId.includes('embeddings'))
553 const rerank = models.find((model) => model.rawId.includes('reranker'))
554 expect(embed?.activity).toBe('embeddings')
555 expect(inputUsd(embed?.pricing)).toBeCloseTo(0.05, 9)
556 expect(rerank?.activity).toBeNull()
557 expect(rerank?.pricing ?? null).toBeNull()
558 },
559 )
560 })
561​
562 it('prices sambanova per token and leaves a zero quote null', async () => {
563 await withFetch(
564 () =>
565 json({
566 data: [
567 {
568 id: 'DeepSeek-V3.2',
569 context_length: 32768,
570 pricing: { prompt: '0.00000300', completion: '0.00000450' },
571 },
572 {
573 id: 'free',
574 pricing: { prompt: '0', completion: '0' },
575 },
576 ],
577 }),
578 async () => {
579 const { models } = await sambanova.listModels({
580 SAMBANOVA_API_KEY: 'test',
581 })
582 const chat = models.find((model) => model.rawId === 'DeepSeek-V3.2')
583 const free = models.find((model) => model.rawId === 'free')
584 expect(chat?.activity).toBe('chat')
585 expect(chat?.contextWindow).toBe(32768)
586 expect(inputUsd(chat?.pricing)).toBeCloseTo(3, 9)
587 expect(free?.pricing ?? null).toBeNull()
588 },
589 )
590 })
591​
592 it('prices hyperbolic per million tokens from the listing', async () => {
593 await withFetch(
594 () =>
595 json({
596 data: [
597 {
598 id: 'deepseek-ai/DeepSeek-R1',
599 supports_chat: true,
600 supports_image_input: false,
601 supports_tools: false,
602 input_price: 2,
603 output_price: 2,
604 },
605 {
606 id: 'no-price',
607 supports_chat: true,
608 supports_image_input: false,
609 },
610 ],
611 }),
612 async () => {
613 const { models } = await hyperbolic.listModels({
614 HYPERBOLIC_API_KEY: 'test',
615 })
616 const chat = models.find((model) => model.rawId.includes('DeepSeek'))
617 const bare = models.find((model) => model.rawId === 'no-price')
618 expect(chat?.activity).toBe('chat')
619 expect(chat?.modalities).toEqual({
620 input: ['text'],
621 output: ['text'],
622 })
623 expect(chat?.capabilities).toEqual([])
624 expect(chat?.exactCapabilities).toBe(true)
625 expect(inputUsd(chat?.pricing)).toBeCloseTo(2, 9)
626 expect(bare?.activity).toBe('chat')
627 expect(bare?.capabilities).toBeUndefined()
628 expect(bare?.pricing ?? null).toBeNull()
629 },
630 )
631 })
632​
633 it('maps a dashscope chat row to a card and leaves a zero quote null', async () => {
634 const priced = await dashscopeListedModel({
635 model: 'qwen3-max',
636 name: 'Qwen3-Max',
637 capabilities: ['TG'],
638 features: ['function-calling'],
639 inference_metadata: {
640 request_modality: ['Text'],
641 response_modality: ['Text'],
642 },
643 prices: [
644 {
645 range_name: 'Default',
646 prices: [
647 {
648 type: 'input_token',
649 price: '2',
650 price_unit: 'per million tokens',
651 },
652 {
653 type: 'output_token',
654 price: '6',
655 price_unit: 'per million tokens',
656 },
657 ],
658 },
659 ],
660 })
661 const free = await dashscopeListedModel({
662 model: 'decision-model-preview',
663 capabilities: ['TG'],
664 inference_metadata: {
665 request_modality: ['Text'],
666 response_modality: ['Text'],
667 },
668 prices: [
669 {
670 range_name: 'Default',
671 prices: [
672 { type: 'input_token', price: '0', price_unit: 'Per 1M tokens' },
673 ],
674 },
675 ],
676 })
677 expect(priced?.activity).toBe('chat')
678 expect(priced?.modalities).toEqual({ input: ['text'], output: ['text'] })
679 expect(priced?.capabilities).toEqual(['tools'])
680 expect(inputUsd(priced?.pricing)).toBeCloseTo(2, 9)
681 expect(free?.activity).toBe('chat')
682 expect(free?.pricing ?? null).toBeNull()
683 })
684​
685 it('binds schema ids that the generated OpenAI-compat spec actually stores', () => {
686 expect(
687 hyperbolic.generationEndpointId?.({ rawId: 'x', activity: 'chat' }),
688 ).toBe('chat/completions')
689 expect(
690 sambanova.generationEndpointId?.({ rawId: 'x', activity: 'chat' }),
691 ).toBe('chat/completions')
692 expect(
693 novita.generationEndpointId?.({ rawId: 'x', activity: 'chat' }),
694 ).toBe('chat/completions')
695 expect(
696 novita.generationEndpointId?.({ rawId: 'x', activity: 'image' }),
697 ).toBe('images/generations')
698 expect(
699 novita.generationEndpointId?.({ rawId: 'x', activity: 'video' }),
700 ).toBeNull()
701 expect(
702 novita.generationEndpointId?.({ rawId: 'x', activity: 'audio' }),
703 ).toBeNull()
704 expect(
705 novita.generationEndpointId?.({ rawId: 'x', activity: 'embeddings' }),
706 ).toBeNull()
707 })
708})