Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { compileTokenCard } from '@modelschemas/rate-card'
4
5import { parseVoyagePricing } from './voyage-pricing.ts'
6
7const PAGE = `# Pricing
8
9| Model | Price per thousand tokens | Price per million tokens | Number of free tokens |
10| --- | --- | --- | --- |
11| \`voyage-4-large\` | $0.00012 | $0.12 | 200 million |
12| \`voyage-finance-2\`<br />\`voyage-law-2\`<br />\`voyage-code-2\` | $0.00012 | $0.12 | 50 million |
13
14| Model | Price per million tokens | Price per billion pixels | Number of free tokens and pixels |
15| --- | --- | --- | --- |
16| \`voyage-multimodal-3.5\`<br />\`voyage-multimodal-3\` | $0.12 | $0.60 | 200M text tokens and 150B pixels |
17
18| Model | Price per thousand tokens | Price per million tokens |
19| --- | --- | --- |
20| \`voyage-3-large\` | $0.00018 | $0.18 |
21| \`voyage-3\` | $0.00006 | $0.06 |
22| \`voyage-large-2\` | $0.00012 | $0.12 |
23`
24
25const SOURCE = {
26 url: 'https://docs.voyageai.com/docs/pricing.md',
27 hash: 'a'.repeat(64),
28 extractedAt: '2026-10-03T00:00:00.000Z',
29}
30
31describe('voyage pricing page', () => {
32 it('prices a listed model and leaves an unpriced id null', () => {
33 const rates = parseVoyagePricing(PAGE)
34 const priced = rates.get('voyage-3')
35 expect(priced).toEqual({ inputTokens: 0.06 / 1e6 })
36 expect(
37 priced
38 ? compileTokenCard({ input_tokens: priced.inputTokens }, [], SOURCE)
39 : null,
40 ).toMatchObject({
41 tables: { rate: { base: { input_tokens: 0.06 / 1e6 } } },
42 })
43 expect(rates.get('voyage-3-large')?.inputTokens).toBe(0.18 / 1e6)
44 expect(rates.get('voyage-law-2')?.inputTokens).toBe(0.12 / 1e6)
45 const multi = rates.get('voyage-multimodal-3')
46 expect(multi).toEqual({ inputTokens: 0.12 / 1e6, pixels: 0.6 / 1e9 })
47 expect(
48 multi
49 ? compileTokenCard(
50 { input_tokens: multi.inputTokens, pixels: multi.pixels ?? 0 },
51 [],
52 SOURCE,
53 )
54 : null,
55 ).toMatchObject({
56 inputs: {
57 input_tokens: { bound: 'usage' },
58 pixels: { bound: 'usage' },
59 },
60 })
61 expect(rates.has('voyage-not-on-the-page')).toBe(false)
62 })
63})