Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { compileUnitCard, price } from '@modelschemas/rate-card'
4
5import { cardRequestParamsOk } from '#/server/rate-card.ts'
6
7import {
8 WORLDLABS_PROMPT_INPUT,
9 parseWorldlabsPricing,
10} from './worldlabs-pricing.ts'
11
12/** Excerpt of https://docs.worldlabs.ai/api/pricing.md (2026-11-10). */
13const PAGE = `
14You may purchase credits at a fixed rate of $1.00 USD per 1,250 credits through the platform.
15
16#### Draft model totals (\`marble-1.0-draft\`)
17
18| Input type | Pano generation | World generation | Total |
19| - | -: | -: | -: |
20| Image (pano) | 0 | 150 | 150 |
21| Text | 80 | 150 | 230 |
22| Image (non-pano) | 80 | 150 | 230 |
23| Multi-image | 100 | 150 | 250 |
24| Video | 100 | 150 | 250 |
25
26#### Standard model totals (\`marble-1.0\`, \`marble-1.1\`)
27
28| Input type | Pano generation | World generation | Total |
29| - | -: | -: | -: |
30| Image (pano) | 0 | 1,500 | 1,500 |
31| Text | 80 | 1,500 | 1,580 |
32| Image (non-pano) | 80 | 1,500 | 1,580 |
33| Multi-image | 100 | 1,500 | 1,600 |
34| Video | 100 | 1,500 | 1,600 |
35
36#### Marble 1.1 Plus totals (\`marble-1.1-plus\`)
37
38| Input type | Pano generation | Base world generation | Variable world generation | Total |
39| - | -: | -: | - | - |
40| Image (pano) | 0 | 1,500 | 0-1,500 | 1,500-3,000 |
41| Text | 80 | 1,500 | 0-1,500 | 1,580-3,080 |
42| Image (non-pano) | 80 | 1,500 | 0-1,500 | 1,580-3,080 |
43| Multi-image | 100 | 1,500 | 0-1,500 | 1,600-3,100 |
44| Video | 100 | 1,500 | 0-1,500 | 1,600-3,100 |
45`
46
47const SOURCE = {
48 url: 'https://docs.worldlabs.ai/api/pricing.md',
49 hash: 'a'.repeat(64),
50 extractedAt: '2026-11-10T00:00:00.000Z',
51}
52
53describe('parseWorldlabsPricing', () => {
54 const cards = parseWorldlabsPricing(PAGE)
55
56 it('prices draft and standard models in USD per input type', () => {
57 expect([...cards.keys()].sort()).toEqual([
58 'marble-1.0',
59 'marble-1.0-draft',
60 'marble-1.1',
61 ])
62 const draft = compileUnitCard(cards.get('marble-1.0-draft')!, SOURCE)
63 const standard = compileUnitCard(cards.get('marble-1.1')!, SOURCE)
64 expect(draft).not.toBeNull()
65 expect(standard).not.toBeNull()
66 expect(price(draft!, { [WORLDLABS_PROMPT_INPUT]: 'Image (pano)' })).toBe(
67 150 / 1250,
68 )
69 expect(price(draft!, { [WORLDLABS_PROMPT_INPUT]: 'Text' })).toBe(230 / 1250)
70 expect(price(standard!, { [WORLDLABS_PROMPT_INPUT]: 'Text' })).toBe(
71 1580 / 1250,
72 )
73 expect(price(standard!, { [WORLDLABS_PROMPT_INPUT]: 'Video' })).toBe(
74 1600 / 1250,
75 )
76 expect(cards.get('marble-1.0')).toEqual(cards.get('marble-1.1'))
77 // WorldsGenerateRequest top-level properties. The lever is not one of them.
78 expect(
79 cardRequestParamsOk(
80 standard!,
81 new Set([
82 'display_name',
83 'model',
84 'permission',
85 'seed',
86 'tags',
87 'world_prompt',
88 ]),
89 ),
90 ).toBe(true)
91 })
92
93 it('leaves marble-1.1-plus unpriced while its totals are ranges', () => {
94 expect(cards.has('marble-1.1-plus')).toBe(false)
95 })
96
97 it('throws when the credit rate or a fixed table is missing', () => {
98 expect(() => parseWorldlabsPricing('no prices here')).toThrow(/credit rate/)
99 expect(() =>
100 parseWorldlabsPricing(
101 PAGE.replace('#### Draft model totals', '#### Gone'),
102 ),
103 ).toThrow(/totals table is missing/)
104 })
105})