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

together-pricing.test.ts

79 lines3.2 KB

1import { describe, expect, it } from 'vitest'
2​
3import { price } from '@modelschemas/rate-card'
4​
5import {
6 parseTogetherMediaPrices,
7 togetherMediaCard,
8} from './together-pricing.ts'
9​
10const CATALOG = `
11## Image models
12​
13| Organization | Model name | Model string for API | Unit | Price | Output per $1 |
14| :- | :- | :- | :- | :- | :- |
15| Black Forest Labs | Flux1.1 [pro] | black-forest-labs/FLUX.1.1-pro | \`megapixel\` | \\$0.04 | 25 megapixels |
16| Black Forest Labs | FLUX.2 [pro] | black-forest-labs/FLUX.2-pro | \`image\` | \\$0.03+ ([varies](https://example.com)) | 33 images |
17| Black Forest Labs | FLUX.2 [max] | black-forest-labs/FLUX.2-max | \`megapixel\` | \\$0.07 at 50 steps | 14 megapixels |
18​
19## Video models
20​
21| Organization | Model name | Model string for API | Price per video | Resolution / duration |
22| :- | :- | :- | :- | :- |
23| ByteDance | Seedance 1.0 Pro | ByteDance/Seedance-1.0-pro | \\$0.57 | 1080p / 5s |
24| ByteDance | Seedance 2.0 | ByteDance/Seedance-2.0 | \\$0.16 | - |
25| Black Forest Labs | FLUX 3 | black-forest-labs/FLUX-3 | \\$0.17 | - |
26​
27## Audio models
28​
29| Organization | Modality | Model name | Model string for API | Pricing |
30| :- | :- | :- | :- | :- |
31| Cartesia | Text-to-Speech | Cartesia Sonic 3 | cartesia/sonic-3 | \\$65.00 per 1M chars |
32| OpenAI | Speech-to-Text | Whisper Large v3 | openai/whisper-large-v3 | \\$0.0015 per audio min |
34​
35const source = {
36 url: 'https://docs.together.ai/docs/serverless/models.md',
37 hash: 'abc',
38 extractedAt: '2026-10-03T00:00:00.000Z',
40​
41function cardFor(id: string) {
42 const spec = parseTogetherMediaPrices(CATALOG).get(id.toLowerCase())
43 if (!spec) return null
44 return togetherMediaCard(spec, source)
46​
47describe('together media catalog', () => {
48 it('compiles a megapixel image rate and skips a varying per-image estimate', () => {
49 const card = cardFor('black-forest-labs/FLUX.1.1-pro')
50 if (!card) throw new Error('did not compile')
51 expect(price(card, {}, { megapixels: 2 })).toBeCloseTo(0.08, 9)
52 const max = cardFor('black-forest-labs/FLUX.2-max')
53 if (!max) throw new Error('did not compile')
54 expect(price(max, {}, { megapixels: 1 })).toBeCloseTo(0.07, 9)
55 expect(cardFor('black-forest-labs/FLUX.2-pro')).toBeNull()
56 })
57​
58 it('keeps the published price-per-video figure and does not divide by duration', () => {
59 const clip = cardFor('ByteDance/Seedance-1.0-pro')
60 if (!clip) throw new Error('did not compile')
61 expect(price(clip, {}, {})).toBeCloseTo(0.57, 9)
62 const flat = cardFor('bytedance/seedance-2.0')
63 if (!flat) throw new Error('did not compile')
64 expect(price(flat, {}, {})).toBeCloseTo(0.16, 9)
65 const flux = cardFor('black-forest-labs/FLUX-3')
66 if (!flux) throw new Error('did not compile')
67 expect(price(flux, {}, {})).toBeCloseTo(0.17, 9)
68 })
69​
70 it('compiles character and audio-minute rates', () => {
71 const speech = cardFor('cartesia/sonic-3')
72 if (!speech) throw new Error('did not compile')
73 expect(price(speech, {}, { characters: 1e6 })).toBeCloseTo(65, 9)
74 const whisper = cardFor('openai/whisper-large-v3')
75 if (!whisper) throw new Error('did not compile')
76 expect(price(whisper, {}, { audio_seconds: 60 })).toBeCloseTo(0.0015, 9)
77 expect(cardFor('cartesia/sonic-3.5')).toBeNull()
78 })
79})