Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { parseGroqPrice, parseGroqPricing } from './groq-pricing.ts'
4
5const PAGE = `# Supported Models
6
7| MODEL ID | SPEED | PRICE PER 1M TOKENS | RATE LIMITS |
8| --- | --- | --- | --- |
9| [GPT OSS 120B](/docs/model/openai/gpt-oss-120b)openai/gpt-oss-120b | 500 | $0.15 input$0.60 output | 250K TPM |
10| [Llama 3.1 8B](/docs/model/llama-3.1-8b-instant)Enterprisellama-3.1-8b-instant | 560 | ContactSales | ContactSales |
11| [Whisper](/docs/model/whisper-large-v3)whisper-large-v3 | - | $0.111 per hour | 200K ASH |
12| [Orpheus](/docs/model/canopylabs/orpheus-v1-english)canopylabs/orpheus-v1-english | - | $22.00 per 1M characters | 50K TPM |
13| [Qwen](/docs/model/qwen/qwen3.8-27b)qwen/qwen3.8-27b | 450 | $0.80 input$4.00 output | 250K TPM |
14| [New](/docs/model/new)new-model | - | $1 per request | - |
15`
16
17describe('groq models page', () => {
18 it('reads token, hour, and character prices and skips unpublished ones', () => {
19 const rates = parseGroqPricing(PAGE)
20 expect(rates.get('openai/gpt-oss-120b')).toEqual({
21 kind: 'tokens',
22 rates: { input_tokens: 0.15e-6, output_tokens: 0.6e-6 },
23 })
24 const oss = rates.get('openai/gpt-oss-120b')
25 expect(oss?.kind === 'tokens' ? oss.rates : {}).not.toHaveProperty(
26 'cache_read_tokens',
27 )
28 expect(rates.get('qwen/qwen3.8-27b')).toEqual({
29 kind: 'tokens',
30 rates: { input_tokens: 0.8 / 1e6, output_tokens: 4 / 1e6 },
31 })
32 expect(rates.get('whisper-large-v3')).toEqual({
33 kind: 'unit',
34 unit: {
35 quantity: { param: 'audio_seconds', bound: 'usage' },
36 rates: 0.111 / 3600,
37 },
38 })
39 expect(rates.get('canopylabs/orpheus-v1-english')).toEqual({
40 kind: 'unit',
41 unit: {
42 quantity: { param: 'characters', bound: 'usage' },
43 rates: 22 / 1e6,
44 },
45 })
46 expect(rates.has('llama-3.1-8b-instant')).toBe(false)
47 expect(rates.has('new-model')).toBe(false)
48 expect(parseGroqPrice('$1 per request')).toBe('refuse')
49 })
50})