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

minimax.test.ts

163 lines5.0 KB

1import { afterEach, describe, expect, it } from 'vitest'
2​
3import {
4 MINIMAX_MAX_COMPLETION_TOKENS,
5 MINIMAX_PRICING_PAGE,
6 MINIMAX_SDK_PAGE,
7} from '../fixtures/minimax-docs.ts'
8import {
9 MINIMAX_CHAT_SPEC_URL,
10 MINIMAX_MESSAGES_SPEC_URL,
11 MINIMAX_PRICING_URL,
12 MINIMAX_SDK_URL,
13} from '../minimax-docs.ts'
14import { MINIMAX_MODELS_URL, provider } from './minimax.ts'
15​
16/** Excerpt of platform.minimax.io models-intro.md (2026-10-04). */
17const FIXTURE = `
18### Language
19​
20| **Models** | **Description** |
21| :- | :- |
22| [MiniMax-M2.7](/docs/api-reference/text-anthropic-api) | Beginning the journey |
23| <a href="/docs/api-reference/text-anthropic-api">MiniMax-M3</a> | Frontier |
24​
25### Video
26​
27| **Models** | **Description** |
28| :- | :- |
29| [MiniMax H3](/docs/api-reference/video-generation-v2-create) | Next-gen open general-purpose multimodal video model |
30| [MiniMax H3 Max](/docs/api-reference/video-generation-v2-create) | High-speed video model post-trained by [fal.ai](https://fal.ai/) on MiniMax H3 |
31​
32### Audio
33​
34| **Models** | **Description** |
35| :- | :- |
36| [speech-2.8-hd](/docs/api-reference/speech-t2a-http) | Ultra-realistic quality featuring sound tags |
37| [speech-2.8-turbo](/docs/api-reference/speech-t2a-http) | Seamless speed meets natural flow |
39​
40const CHAT_SPEC = {
41 openapi: '3.1.0',
42 paths: { '/v1/chat/completions': { post: {} } },
43 components: {
44 schemas: {
45 ChatCompletionReq: {
46 properties: {
47 max_completion_tokens: {
48 type: 'integer',
49 description: MINIMAX_MAX_COMPLETION_TOKENS,
50 },
51 },
52 },
53 },
54 },
56​
57const PAGES: Record<string, string> = {
58 [MINIMAX_MODELS_URL]: FIXTURE,
59 [MINIMAX_SDK_URL]: MINIMAX_SDK_PAGE,
60 [MINIMAX_PRICING_URL]: MINIMAX_PRICING_PAGE,
61 [MINIMAX_CHAT_SPEC_URL]: JSON.stringify(CHAT_SPEC),
62 [MINIMAX_MESSAGES_SPEC_URL]: JSON.stringify({
63 openapi: '3.1.0',
64 paths: { '/anthropic/v1/messages': { post: {} } },
65 }),
67​
68const originalFetch = globalThis.fetch
69​
70function mockFetch(pages: Record<string, string>): void {
71 globalThis.fetch = ((url: string) => {
72 const page = pages[String(url)]
73 return page === undefined
74 ? Promise.reject(new Error(`unexpected fetch: ${String(url)}`))
75 : Promise.resolve(new Response(page))
76 }) as typeof fetch
78​
79afterEach(() => {
80 globalThis.fetch = originalFetch
81})
82​
83describe('minimax', () => {
84 it('lists linked model ids and fills chat rows from the docs pages', async () => {
85 mockFetch(PAGES)
86​
87 const listed = await provider.listModels({})
88​
89 expect(listed.models.map((model) => [model.rawId, model.activity])).toEqual(
90 [
91 ['MiniMax-M2.7', 'chat'],
92 ['MiniMax-M3', 'chat'],
93 ['speech-2.8-hd', 'audio'],
94 ['speech-2.8-turbo', 'audio'],
95 ],
96 )
97 const m3 = listed.models.find((model) => model.rawId === 'MiniMax-M3')
98 expect(m3).toMatchObject({
99 contextWindow: 1_000_000,
100 maxOutput: 524_288,
101 modalities: { input: ['text', 'image', 'video'], output: ['text'] },
102 reasoning: { mode: 'adaptive', mandatory: false },
103 pricing: {
104 tables: { rate: { base: { input_tokens: 0.3 / 1e6 } } },
105 source: { url: MINIMAX_PRICING_URL },
106 },
107 factSources: {
108 contextWindow: {
109 derivation: 'docs-derived',
110 sourceUrl: MINIMAX_SDK_URL,
111 },
112 maxOutput: { sourceUrl: MINIMAX_CHAT_SPEC_URL },
113 modalities: { sourceUrl: MINIMAX_SDK_URL },
114 reasoning: { sourceUrl: MINIMAX_SDK_URL },
115 pricing: { sourceUrl: MINIMAX_PRICING_URL },
116 },
117 })
118 // Speech rows stay as listed: the chat pages say nothing about them.
119 expect(
120 listed.models.find((model) => model.rawId === 'speech-2.8-hd'),
121 ).toEqual({ rawId: 'speech-2.8-hd', activity: 'audio', pricing: null })
122 expect(listed.models.some((model) => model.rawId === 'fal.ai')).toBe(false)
123 expect(listed.models.some((model) => model.rawId === 'MiniMax H3')).toBe(
124 false,
125 )
126 })
127​
128 it('throws when a docs page parses nothing', async () => {
129 mockFetch({ ...PAGES, [MINIMAX_PRICING_URL]: '# Pay as You Go\n' })
130 await expect(provider.listModels({})).rejects.toThrow(
131 'minimax pricing page: parsed 0 model rows',
132 )
133 })
134​
135 it('syncs both chat documents and binds chat rows to chat completions', async () => {
136 mockFetch(PAGES)
137​
138 const spec = await provider.fetchSpec({})
139​
140 expect(spec.sources.map((source) => source.url)).toEqual([
141 MINIMAX_CHAT_SPEC_URL,
142 MINIMAX_MESSAGES_SPEC_URL,
143 ])
144 expect(spec.specs).toHaveLength(2)
145 expect(provider.classify('/v1/chat/completions', {})).toBe('chat')
146 expect(provider.classify('/anthropic/v1/messages', {})).toBe('chat')
147 expect(
148 provider.classify('/anthropic/v1/messages/count_tokens', {}),
149 ).toBeNull()
150 expect(
151 provider.generationEndpointId?.({
152 rawId: 'MiniMax-M3',
153 activity: 'chat',
154 }),
155 ).toBe('v1/chat/completions')
156 expect(
157 provider.generationEndpointId?.({
158 rawId: 'speech-2.8-hd',
159 activity: 'audio',
160 }),
161 ).toBeNull()
162 })
163})