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

byteplus-pricing.test.ts

716 lines23.1 KB

1import { describe, expect, it } from 'vitest'
2​
3import { price, priceDetailed } from '@modelschemas/rate-card'
4​
5import { storeListedPricing } from '../rate-card.ts'
6​
7import {
8 byteplusRatesFor,
9 compilePeriodCard,
10 compileSeedanceCard,
11 compileSeedreamProCard,
12 parseByteplusAliases,
13 parseByteplusImages,
14 parseByteplusModelPage,
15 parseByteplusPixelTiers,
16 parseByteplusPricing,
17 parseByteplusVideo,
18 parseSeedanceGeometry,
19 sharePublishedAliases,
20} from './byteplus-pricing.ts'
21import type { ByteplusDoc } from './byteplus-pricing.ts'
22import { overlayModelFacts } from './reasoning-config.ts'
23import type { ModelInfo } from './types.ts'
24​
25function cell(id: string, text: string) {
26 return {
27 ops: [{ insert: '*', attributes: { lmkr: '1' } }, { insert: `${text}\n` }],
28 zoneId: id,
29 zoneType: 'Z',
30 }
32​
33/** Chat-table header: model, tier, input, audio, cache storage, cache hit, audio cache, output. */
34const CHAT_HEADERS = [
35 'Model ID',
36 'Pricing tiers (K tokens)',
37 'Input (non-audio) (USD/M tokens)',
38 'Input (audio) (USD/M tokens)',
39 'Cache-storage (USD/M tokens/Hour)',
40 'Cache-hit input (non-audio) (USD/M tokens)',
41 'Cache-hit input (audio) (USD/M tokens)',
42 'Output (USD/M tokens)',
44​
45/** Page document of `tables`, each a header row then body rows. */
46function doc(...tables: Array<Array<Array<string>>>): ByteplusDoc {
47 const data: ByteplusDoc['data'] = { '0': { ops: [] } }
48 tables.forEach((body, t) => {
49 data['0']?.ops?.push({
50 insert: '*',
51 attributes: { aceTable: `rows${t} cols${t}` },
52 })
53 data[`rows${t}`] = {
54 ops: body.map((_, index) => ({ insert: { id: `t${t}r${index}` } })),
55 zoneType: 'R',
56 }
57 data[`cols${t}`] = {
58 ops: (body[0] ?? []).map((_, index) => ({
59 insert: { id: `t${t}c${index}` },
60 })),
61 zoneType: 'C',
62 }
63 body.forEach((cells, row) => {
64 cells.forEach((text, column) => {
65 const id = `xt${t}r${row}xt${t}c${column}`
66 data[id] = cell(id, text)
67 })
68 })
69 })
70 return { data }
72​
73describe('byteplus pricing page', () => {
74 it('reads standard token rates, tiers, and a dated catalog suffix', () => {
75 const rates = parseByteplusPricing(
76 doc([
77 CHAT_HEADERS,
78 [
79 'dola-seed-2-1-turbo',
80 'Prompt length [0, 256]',
81 '0.5',
82 '-',
83 '0.0083',
84 '0.1',
85 '-',
86 '2.5',
87 ],
88 [
89 'seed-2-0-pro-260328',
90 'Prompt length [0, 128]',
91 '0.50',
92 '-',
93 '0.0083',
94 '0.10',
95 '-',
96 '3.00',
97 ],
98 [
99 '',
100 'Prompt length (128, 256]',
101 '1.00',
102 '-',
103 '0.0083',
104 '0.20',
105 '-',
106 '6.00',
107 ],
108 [
109 'seed-2-0-lite-260428',
110 'Prompt length [0, 128]',
111 '0.25',
112 '3.75',
113 '0.0083',
114 '0.05',
115 '0.75',
116 '2.00',
117 ],
118 [
119 'deepseek-v4-1-flash-260910',
120 'Off-peak hours',
121 '0.15',
122 '-',
123 '0.0083',
124 '0.003',
125 '-',
126 '0.60',
127 ],
128 ['', 'Peak hours', '0.30', '-', '0.0083', '0.006', '-', '1.20'],
129 ['glm-5-2-260617', '-', '1.4', '-', '0.0083', '0.26', '-', '4.4'],
130 ]),
131 )
132 expect(rates.get('glm-5-2-260617')).toEqual({
133 base: {
134 input_tokens: 1.4e-6,
135 cache_read_tokens: 0.26e-6,
136 output_tokens: 4.4e-6,
137 },
138 tiers: [],
139 })
140 expect(rates.get('seed-2-0-lite-260428')).toMatchObject({
141 base: { audio_tokens: 3.75e-6 },
142 })
143 expect(rates.get('seed-2-0-pro-260328')).toMatchObject({
144 tiers: [
145 {
146 minPromptTokens: 128_000,
147 rates: {
148 input_tokens: 1 / 1e6,
149 cache_read_tokens: 0.2 / 1e6,
150 output_tokens: 6 / 1e6,
151 },
152 },
153 ],
154 })
155 // Cache storage is per hour, so it is not a lever.
156 expect(rates.get('glm-5-2-260617')).not.toHaveProperty('base.cache_storage')
157 // Peak and off-peak rows are kept apart, never folded into one price.
158 expect(rates.get('deepseek-v4-1-flash-260910')).toEqual({
159 periods: {
160 off_peak: {
161 input_tokens: 0.15e-6,
162 cache_read_tokens: 0.003e-6,
163 output_tokens: 0.6e-6,
164 },
165 peak: {
166 input_tokens: 0.3e-6,
167 cache_read_tokens: 0.006e-6,
168 output_tokens: 1.2e-6,
169 },
170 },
171 })
172 expect(byteplusRatesFor('dola-seed-2-1-turbo-260628', rates)).toMatchObject(
173 { base: { input_tokens: 0.5e-6 } },
174 )
175 expect(byteplusRatesFor('seed-translation-250915', rates)).toBeUndefined()
176 // Only a dated suffix reaches an undated row, never a sibling model.
177 expect(
178 byteplusRatesFor('dola-seed-2-1-turbo-flash-260628', rates),
179 ).toBeUndefined()
180 })
181​
182 it('refuses a period group that is not one off-peak and one peak row', () => {
183 const offPeak = [
184 'deepseek-v4-1-flash-261017',
185 'Off-peak hours',
186 '0.15',
187 '-',
188 '0.0083',
189 '0.003',
190 '-',
191 '0.60',
192 ]
193 const twoOffPeak = parseByteplusPricing(
194 doc([CHAT_HEADERS, offPeak, ['', ...offPeak.slice(1)]]),
195 )
196 expect(twoOffPeak.has('deepseek-v4-1-flash-261017')).toBe(false)
197 const mixed = parseByteplusPricing(
198 doc([
199 CHAT_HEADERS,
200 offPeak,
201 ['', 'Prompt length (128, 256]', '1', '-', '-', '-', '-', '2'],
202 ]),
203 )
204 expect(mixed.has('deepseek-v4-1-flash-261017')).toBe(false)
205 })
206​
207 it('prices a period card only for a stated pricing_period', async () => {
208 const card = compilePeriodCard(
209 {
210 periods: {
211 off_peak: {
212 input_tokens: 0.12e-6,
213 cache_read_tokens: 0.0024e-6,
214 output_tokens: 0.48e-6,
215 },
216 peak: {
217 input_tokens: 0.24e-6,
218 cache_read_tokens: 0.0048e-6,
219 output_tokens: 0.96e-6,
220 },
221 },
222 },
223 SOURCE,
224 )
225 const usage = { input_tokens: 1_000_000, output_tokens: 1_000_000 }
226 expect(price(card, {}, { ...usage, pricing_period: 'off_peak' })).toBe(0.6)
227 expect(
228 price(
229 card,
230 {},
231 { ...usage, cache_read_tokens: 1_000_000, pricing_period: 'peak' },
232 ),
233 ).toBeCloseTo(1.2048, 10)
234 expect(() => price(card, {}, usage)).toThrow(/pricing_period/)
235 expect(() =>
236 price(card, {}, { ...usage, pricing_period: 'night' }),
237 ).toThrow(/pricing_period/)
238 // Usage-bound levers only, so the chat schema accepts the card as stored.
239 const stored = await storeListedPricing(card, {
240 sourceUrl: SOURCE.url,
241 now: 1_790_000_000,
242 requestProperties: new Set(['model', 'messages']),
243 })
244 expect(stored).toEqual({ card })
245 })
246​
247 it('keeps each patch’s absent facts when overlaying', () => {
248 const model = { rawId: 'seed-translation-250915', activity: 'chat' }
249 const merged = overlayModelFacts(
250 model as ModelInfo,
251 { absent: { pricing: 'unavailable' } },
252 { absent: { reasoning: 'unavailable' } },
253 )
254 expect(merged.absent).toEqual({
255 pricing: 'unavailable',
256 reasoning: 'unavailable',
257 })
258 })
259​
260 it("reads a model page's single price row (seed-translation)", () => {
261 const headers = [
262 'Input USD/M Tokens',
263 'Input Hits Cache USD/M Tokens',
264 'Output Unit Price USD/M Tokens',
265 'Cache Storage USD/M Tokens/Hour',
266 ]
267 expect(
268 parseByteplusModelPage(doc([headers, ['0.20', '-', '0.80', '-']])),
269 ).toEqual({ input_tokens: 0.2 / 1e6, output_tokens: 0.8 / 1e6 })
270 expect(() =>
271 parseByteplusModelPage(
272 doc([headers, ['0.20', '-', '0.80', '-'], ['0.30', '-', '1', '-']]),
273 ),
274 ).toThrow(/one price table row/)
275 expect(() =>
276 parseByteplusModelPage(doc([headers, ['0.20', '-', 'TBD', '-']])),
277 ).toThrow(/unreadable/)
278 expect(() => parseByteplusModelPage(doc([CHAT_HEADERS]))).toThrow()
279 })
280})
281​
282const SOURCE = {
283 url: 'https://docs.byteplus.com/en/docs/ModelArk/1544106',
284 hash: 'a'.repeat(64),
285 extractedAt: '2026-10-02T00:00:00Z',
287​
288/** Rate cells as the live page words them (read 2026-10-02). */
289const VIDEO_TABLE = [
290 [
291 'Model ID',
292 'Online inference (USD / M tokens)',
293 'Offline inference (USD / M tokens)',
294 ],
295 [
296 'dreamina-seedance-2-5-260628 Pricing varies based on output video resolution and whether the input includes video.',
297 'For 480p and 720p outputs: Input without video: 10.70 Input with video: 6.40 For 1080p outputs: Input without video: 11.7 Input with video: 7.0',
298 'Not supported yet',
299 ],
300 [
301 'dreamina-seedance-2-0-fast-260128 Pricing varies based on whether the input includes video.',
302 'For 480p and 720p outputs: Input without video: (Original) 5.6 Time limited 25% off Input with video: (Original) 3.3 Time limited 25% off',
303 'Not supported yet',
304 ],
305 [
306 'seedance-1-5-pro-251215 Pricing varies based on whether the output includes audio',
307 'Video with audio: 2.4 Video without audio: 1.2',
308 'Video with audio: 1.2 Video without audio: 0.6',
309 ],
310 ['seedance-1-0-pro-250528', '2.5', '1.25'],
311 ['seedance-9-unknown-261231', 'Contact sales', 'Not supported yet'],
312 // Promo text with no "(Original)" may be the discounted rate: refuse.
313 ['seedance-9-promo-261231', '4.2 Time limited 25% off', 'Not supported yet'],
315​
316const IMAGE_TABLE = [
317 [
318 'Model ID',
319 'Input image price (USD / image)',
320 'Output image price (USD / image)',
321 ],
322 [
323 'dola-seedream-5-0-pro-260628 Pricing varies by image generation scenario.',
324 'First image: Free From the 2nd image: 0.003',
325 'Single image generation: ≤ 2.61 million pixels (1.5K or lower): 0.045 > 2.61 million pixels (higher than 1.5K): 0.09 Layer decomposition: ≤ 2.61 million pixels (1.5K or lower): 0.0225 > 2.61 million pixels (higher than 1.5K): 0.045',
326 ],
327 ['seedream-5-0-lite-260128', 'Free', '0.035'],
328 ['dola-seedream-5-0-flash-260915', 'Free', '0.018'],
329 ['seedream-4-5-251128', 'Free', '0.04'],
330 ['seedream-4-0-250828', 'Free', '0.03'],
332​
333describe('byteplus video and image tables', () => {
334 const page = doc(VIDEO_TABLE, IMAGE_TABLE)
335 const video = parseByteplusVideo(page)
336​
337 it('reads list prices per tier, resolution, and variant', () => {
338 expect(video.get('dreamina-seedance-2-0-fast-260128')).toEqual({
339 default: {
340 '480p': { no_video: 5.6, video: 3.3 },
341 '720p': { no_video: 5.6, video: 3.3 },
342 },
343 })
344 // No "For … outputs": one rate whatever the resolution.
345 expect(video.get('seedance-1-0-pro-250528')).toEqual({
346 default: { '*': { all: 2.5 } },
347 flex: { '*': { all: 1.25 } },
348 })
349 expect(video.has('seedance-9-unknown-261231')).toBe(false)
350 expect(video.has('seedance-9-promo-261231')).toBe(false)
351 expect(parseByteplusImages(page)).toEqual(
352 new Map([
353 ['seedream-5-0-lite-260128', 0.035],
354 ['dola-seedream-5-0-flash-260915', 0.018],
355 ['seedream-4-5-251128', 0.04],
356 ['seedream-4-0-250828', 0.03],
357 ]),
358 )
359 })
360​
361 it('copies a flat image price onto the model list alias, not onto chat', () => {
362 const images = parseByteplusImages(page)
363 const listed = doc([
364 [
365 'seedream-5-0-260128 (also supports: seedream-5-0-lite-260128)',
366 'seedream-5-0-260128 (also supports: seedream-9-other-260128)',
367 ],
368 ])
369 // Two different aliases for one id: not one price.
370 expect(parseByteplusAliases(listed).size).toBe(0)
371 const once = doc([
372 ['seedream-5-0-260128\n(also supports: seedream-5-0-lite-260128)'],
373 ])
374 const aliases = parseByteplusAliases(once)
375 sharePublishedAliases(images, aliases)
376 expect(images.get('seedream-5-0-260128')).toBe(0.035)
377 expect(images.get('seedream-5-0-lite-260128')).toBe(0.035)
378 // No speech table on this page, and no price for an unlisted snapshot.
379 expect(images.has('seed-asr')).toBe(false)
380 expect(images.has('seed-audio-1.0')).toBe(false)
381 expect(images.has('seedream-4-0-20260415')).toBe(false)
382 })
383​
384 it('prices billed completion_tokens and refuses what it cannot know', () => {
385 const usd = (
386 id: string,
387 request: Record<string, unknown>,
388 usage?: Record<string, unknown>,
389 ) => {
390 const rates = video.get(id)
391 const card = rates && compileSeedanceCard(rates, SOURCE)
392 if (!card) throw new Error(`no card for ${id}`)
393 return Number(price(card, request, usage).toFixed(4))
394 }
395 const v25 = 'dreamina-seedance-2-5-260628'
396 expect(
397 usd(
398 v25,
399 { resolution: '1080p' },
400 { completion_tokens: 1e6, input_video: true },
401 ),
402 ).toBe(7)
403 // Seedance 1.0 Pro usage table: 489600 tokens → 1.22.
404 expect(
405 usd('seedance-1-0-pro-250528', {}, { completion_tokens: 489_600 }),
406 ).toBe(1.224)
407 expect(
408 usd(
409 'seedance-1-5-pro-251215',
410 { generate_audio: true, service_tier: 'flex' },
411 { completion_tokens: 1e6 },
412 ),
413 ).toBe(1.2)
414 const billed = { completion_tokens: 1e6, input_video: false }
415 // No billed count, no stated video input, no audio choice: refuse.
416 expect(() => usd(v25, { resolution: '720p' }, {})).toThrow(
417 /completion_tokens/,
418 )
419 expect(() =>
420 usd(v25, { resolution: '720p' }, { completion_tokens: 1e6 }),
421 ).toThrow(/input_video.*required/)
422 expect(() =>
423 usd('seedance-1-5-pro-251215', {}, { completion_tokens: 1 }),
424 ).toThrow(/generate_audio.*required/)
425 // Draft bills at another resolution; flex has no offline column.
426 expect(() =>
427 usd(v25, { resolution: '1080p', draft: true }, billed),
428 ).toThrow(/draft/)
429 expect(() =>
430 usd(v25, { resolution: '720p', service_tier: 'flex' }, billed),
431 ).toThrow(/flex/)
432 })
433​
434 it('prices Seedream 5.0 pro by size tier and extra input images', () => {
435 const tiers = parseByteplusPixelTiers(page).get(
436 'dola-seedream-5-0-pro-260628',
437 )
438 const card = tiers && compileSeedreamProCard(tiers, SOURCE)
439 if (!card) throw new Error('no Seedream 5.0 pro card')
440 const usd = (request: Record<string, unknown>, inputImages = 0) =>
441 Number(
442 price(card, request, {
443 generated_images: 1,
444 input_images: inputImages,
445 }).toFixed(4),
446 )
447 // Omitted size is Ark's default 2K, the high tier.
448 expect(usd({})).toBe(0.09)
449 expect(usd({ size: '1K' })).toBe(0.045)
450 expect(usd({ size: '1.5K' })).toBe(0.045)
451 // WxH by pixel count: 1536² = 2.36 MP ≤ 2.61 MP; 2048² is above.
452 expect(usd({ size: '1536x1536' })).toBe(0.045)
453 expect(usd({ size: '2048x2048' })).toBe(0.09)
454 // First input image free, each further one 0.003 (usage.input_images).
455 expect(usd({ size: '1K' }, 1)).toBe(0.045)
456 expect(usd({ size: '1K' }, 3)).toBe(0.051)
457 // Layers mix tiers; 4K/auto are not generation sizes; usage is required.
458 expect(() => usd({ layer_decomposition: true })).toThrow(/layer/)
459 expect(() => usd({ size: '4K' })).toThrow(/unknown size/)
460 expect(() => usd({ size: 'auto' })).toThrow(/unknown size/)
461 expect(() => price(card, {}, { input_images: 0 })).toThrow(
462 /generated_images/,
463 )
464 expect(() => price(card, {}, { generated_images: 1 })).toThrow(
465 /input_images/,
466 )
467 })
468})
469​
470/** The tutorial's model and pixel tables as the live page words them. */
471const GUIDE = doc(
472 [
473 [
474 'Model name',
475 '',
476 'Dreamina Seedance 2.0',
477 'Dreamina Seedance 2.0 Fast',
478 'Seedance 1.0 Pro',
479 ],
480 [
481 'Model ID',
482 '',
483 'dreamina-seedance-2-0-260128',
484 'dreamina-seedance-2-0-fast-260128',
485 'seedance-1-0-pro-250528',
486 ],
487 ['', 'Frame rate', '24 fps', '24 fps', '24 fps'],
488 ],
489 [
490 [
491 'Resolution',
492 'Aspect ratio',
493 'Dreamina Seedance 2.0 series',
494 'Seedance 1.0 series',
495 ],
496 ['720p', '16:9', '1280×720', '1248×704'],
497 ['', '4:3', '1112×834', '1120×832'],
498 [
499 '1080p Dreamina Seedance 2.0 Fast and Dreamina Seedance 2.0 Mini do not support 1080p',
500 '16:9',
501 '1920×1080',
502 '1920×1088',
503 ],
504 ['4k Only Dreamina Seedance 2.0 supports 4K', '16:9', '3840×2160', ''],
505 ['', '4:3', '3326×2494', '-'],
506 ['', '1:1', '2880×2880', '-'],
507 ['8k Contact sales for 8K', '16:9', '7680×4320', '7680×4320'],
508 ],
510​
511describe('byteplus video generation tutorial', () => {
512 const geometry = parseSeedanceGeometry(GUIDE)
513​
514 it('reads frame rate and sizes per model, series columns included', () => {
515 expect(geometry.get('seedance-1-0-pro-250528')).toEqual({
516 fps: 24,
517 dims: {
518 '720p': {
519 '16:9': { w: 1248, h: 704 },
520 '4:3': { w: 1120, h: 832 },
521 },
522 '1080p': { '16:9': { w: 1920, h: 1088 } },
523 },
524 })
525 expect(
526 geometry.get('dreamina-seedance-2-0-260128')?.dims['4k']?.['4:3'],
527 ).toEqual({ w: 3326, h: 2494 })
528 })
529​
530 it('labels the estimate, and keeps sizes to the resolutions priced', () => {
531 const id = 'dreamina-seedance-2-0-fast-260128'
532 const model = geometry.get(id)
533 if (!model) throw new Error('no geometry')
534 const card = compileSeedanceCard(
535 {
536 default: {
537 '480p': { no_video: 5.6, video: 3.3 },
538 '720p': { no_video: 5.6, video: 3.3 },
539 },
540 },
541 SOURCE,
542 { model, url: 'https://example.test/guide', hash: 'b'.repeat(64) },
543 )
544 if (!card) throw new Error('no card')
545 // The series column lists 1080p and 4K; Fast prices neither.
546 expect(Object.keys(card.tables.pixels ?? {})).toEqual(['720p'])
547 // Page: "Dreamina Seedance 2.0 Fast (USD) 0.60 per video" (720p 16:9 5 s).
548 const request = { resolution: '720p', ratio: '16:9', duration: 5 }
549 const result = priceDetailed(card, request, { input_video: false })
550 expect(result.estimated).toEqual(['completion_tokens'])
551 expect(result.amount.toFixed(2)).toBe('0.60')
552 // Video input carries a minimum-token floor the method does not cover
553 // unless the Lark range was supplied.
554 expect(() => priceDetailed(card, request, { input_video: true })).toThrow(
555 /estimate_supported/,
556 )
557 })
558​
559 it('bills a short input video at the Lark minimum for that output', async () => {
560 const card = compileSeedanceCard(
561 {
562 default: {
563 '480p': { no_video: 10.7, video: 6.4 },
564 '720p': { no_video: 10.7, video: 6.4 },
565 '1080p': { no_video: 11.7, video: 7 },
566 },
567 },
568 SOURCE,
569 {
570 model: {
571 fps: 24,
572 dims: {
573 '480p': { '16:9': { w: 854, h: 480 } },
574 '720p': { '16:9': { w: 1280, h: 720 } },
575 '1080p': { '16:9': { w: 1920, h: 1080 } },
576 },
577 },
578 url: 'https://example.test/guide',
579 hash: 'b'.repeat(64),
580 videoMinimumsThrough: 30,
581 },
582 )
583 if (!card) throw new Error('no card')
584 const video = (duration: number, input = 0, resolution = '720p') =>
585 priceDetailed(
586 card,
587 { resolution, ratio: '16:9', duration, input_video_duration: input },
588 { input_video: true },
589 )
590 // Page: 720p 16:9, 5s out, 2–4s in → $1.244. 480p → $0.553.
591 expect(video(5, 2).amount.toFixed(3)).toBe('1.244')
592 expect(video(5, 2, '480p').amount.toFixed(3)).toBe('0.553')
593 // 30s out floors a 2s input at 20s in: 480,375 tokens × $6.40.
594 expect(video(30, 2, '480p').amount).toBeCloseTo((480_375 * 6.4) / 1e6, 6)
595 // Past the minimum, the real input length wins.
596 expect(video(30, 30, '480p').amount).toBeCloseTo((576_450 * 6.4) / 1e6, 6)
597 expect(() => video(31, 2)).toThrow(/min_input_seconds/)
598 // The generation schema has duration and ratio, not input seconds.
599 // That lever must still store; refusing it used to null the card.
600 const stored = await storeListedPricing(card, {
601 sourceUrl: 'https://docs.byteplus.com/en/docs/ModelArk/1544106',
602 now: 1_790_000_000,
603 requestProperties: new Set([
604 'service_tier',
605 'draft',
606 'resolution',
607 'duration',
608 'ratio',
609 ]),
610 })
611 expect(stored.refused).toBeUndefined()
612 expect(stored.card?.inputs.completion_tokens).toMatchObject({
613 kind: 'number',
614 })
615 })
616})
617​
618describe('byteplus tutorial notes and columns', () => {
619 it('applies resolution notes, and drops rows whose note it cannot read', () => {
620 const geometry = parseSeedanceGeometry(GUIDE)
621 // "2.0 Fast and Mini do not support 1080p"; "Only 2.0 supports 4K".
622 const fast = geometry.get('dreamina-seedance-2-0-fast-260128')?.dims
623 expect(Object.keys(fast ?? {})).toEqual(['720p'])
624 expect(
625 geometry.get('dreamina-seedance-2-0-260128')?.dims['4k']?.['1:1'],
626 ).toEqual({ w: 2880, h: 2880 })
627 // "Contact sales for 8K" names no rule: nobody gets 8K.
628 for (const model of geometry.values()) {
629 expect(model.dims).not.toHaveProperty('8k')
630 }
631 })
632​
633 it("prefers a model's own column, and drops a model whose sizes conflict", () => {
634 const geometry = parseSeedanceGeometry(
635 doc(
636 [
637 ['Model name', '', 'Seedance 1.0 Pro', 'Seedance 1.0 Pro Fast'],
638 [
639 'Model ID',
640 '',
641 'seedance-1-0-pro-250528',
642 'seedance-1-0-pro-fast-251015',
643 ],
644 ['', 'Frame rate', '24 fps', '24 fps'],
645 ],
646 [
647 [
648 'Resolution',
649 'Aspect ratio',
650 'Seedance 1.0 series',
651 'Seedance 1.0 Pro Fast',
652 'Seedance 1.0 Pro',
653 ],
654 ['720p', '16:9', '1248×704', '1280×720', '1248×704'],
655 ['', '4:3', '1120×832', '1120×832', '1112×834'],
656 ],
657 ),
658 )
659 expect(
660 geometry.get('seedance-1-0-pro-fast-251015')?.dims['720p']?.['16:9'],
661 ).toEqual({ w: 1280, h: 720 })
662 // Pro's own column agrees at 16:9 but the series disagrees at 4:3 —
663 // own beats series, so Pro keeps its own 1112×834.
664 expect(
665 geometry.get('seedance-1-0-pro-250528')?.dims['720p']?.['4:3'],
666 ).toEqual({ w: 1112, h: 834 })
667 const twice = parseSeedanceGeometry(
668 doc(
669 [
670 ['Model name', '', 'Seedance 1.0 Pro'],
671 ['Model ID', '', 'seedance-1-0-pro-250528'],
672 ['', 'Frame rate', '24 fps'],
673 ],
674 [
675 [
676 'Resolution',
677 'Aspect ratio',
678 'Seedance 1.0 Pro',
679 'Seedance 1.0 Pro',
680 ],
681 ['720p', '16:9', '1248×704', '1280×720'],
682 ],
683 ),
684 )
685 expect(twice.has('seedance-1-0-pro-250528')).toBe(false)
686 })
687​
688 it('refuses to estimate a draft', () => {
689 const model = parseSeedanceGeometry(GUIDE).get('seedance-1-0-pro-250528')
690 if (!model) throw new Error('no geometry')
691 const card = compileSeedanceCard(
692 { default: { '*': { all: 2.5 } } },
693 SOURCE,
694 { model, url: 'https://example.test/guide', hash: 'b'.repeat(64) },
695 )
696 if (!card) throw new Error('no card')
697 const request = { resolution: '720p', ratio: '16:9', duration: 5 }
698 expect(priceDetailed(card, request).estimated).toEqual([
699 'completion_tokens',
700 ])
701 expect(() => priceDetailed(card, { ...request, draft: true })).toThrow(
702 /cannot be estimated.*draft/,
703 )
704 // Billed tokens price a 1.0 draft: its rate does not split on resolution.
705 expect(
706 priceDetailed(card, { draft: true }, { completion_tokens: 1e6 }),
707 ).toEqual({
708 amount: 2.5,
709 currency: 'USD',
710 usd: 2.5,
711 estimated: [],
712 defaulted: ['service_tier'],
713 ignored: [],
714 })
715 })
716})