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

fal-chat-facts.test.ts

674 lines22.7 KB

1import { afterEach, describe, expect, it, vi } from 'vitest'
2​
3import {
4 falChatFacts,
5 falDescriptionContextWindow,
6 falEndpointSpecUrl,
7} from './fal-chat-facts.ts'
8import { falProvider } from './fal.ts'
9import chatModels from './fixtures/fal-chat-models.json'
10import type { OpenApiDocument } from './types.ts'
11​
12const LISTING = 'https://api.fal.ai/v1/models'
13​
14interface Fixture {
15 endpoint_id: string
16 metadata: { category: string; description: string }
17 openapi: OpenApiDocument
19​
20const fixtures = chatModels as unknown as Array<Fixture>
21​
22function fixture(rawId: string): Fixture {
23 const found = fixtures.find((m) => m.endpoint_id === rawId)
24 if (!found) throw new Error(`no fixture for ${rawId}`)
25 return structuredClone(found)
27​
28function facts(model: Fixture) {
29 return falChatFacts(
30 {
31 endpoint_id: model.endpoint_id,
32 description: model.metadata.description,
33 openapi: model.openapi,
34 },
35 LISTING,
36 )
38​
39/** The request schema's properties, for mutating a fixture. */
40function inputProperties(
41 model: Fixture,
42): Record<string, Record<string, unknown>> {
43 const schemas = model.openapi.components?.schemas ?? {}
44 const name = Object.keys(schemas).find((key) => key.endsWith('Input'))
45 const schema = schemas[name ?? ''] as {
46 properties: Record<string, Record<string, unknown>>
47 }
48 return schema.properties
50​
51describe('falChatFacts', () => {
52 it('reads a model endpoint from its request schema and description', () => {
53 const rawId = 'fal-ai/bytedance/seed/v2/mini'
54 const got = facts(fixture(rawId))
55 expect(got.contextWindow).toBe(256_000)
56 expect(got.maxOutput).toBe(65_536)
57 expect(got.modalities).toEqual({
58 input: ['text', 'image', 'video'],
59 output: ['text'],
60 })
61 expect(got.reasoning).toEqual({
62 mode: 'effort',
63 mandatory: false,
64 efforts: ['minimal', 'low', 'medium', 'high'],
65 })
66 expect(got.capabilities).toEqual(
67 expect.arrayContaining([
68 'reasoning',
69 'reasoning_effort',
70 'max_tokens',
71 'temperature',
72 'top_p',
73 ]),
74 )
75 expect(got.factSources?.contextWindow).toEqual({
76 derivation: 'listing',
77 sourceUrl: LISTING,
78 path: 'metadata.description',
79 })
80 expect(got.factSources?.maxOutput).toEqual({
81 derivation: 'upstream-spec',
82 sourceUrl: falEndpointSpecUrl(LISTING, rawId),
83 endpointId: rawId,
84 path: '/properties/max_completion_tokens/maximum',
85 })
86 expect(got.factSources?.reasoning?.path).toBe(
87 '/properties/reasoning_effort',
88 )
89 expect(got.factSources?.capabilities?.temperature?.sourceUrl).toBe(
90 falEndpointSpecUrl(LISTING, rawId),
91 )
92 expect(got.requestMap).toEqual({
93 thinking: {
94 on: { thinking: 'enabled', reasoning_effort: 'high' },
95 off: { thinking: 'disabled' },
96 levels: {
97 off: null,
98 minimal: 'minimal',
99 low: 'low',
100 medium: 'medium',
101 high: 'high',
102 xhigh: null,
103 max: null,
104 },
105 },
106 maxTokensField: 'max_completion_tokens',
107 developerRole: null,
108 replayReasoningContent: null,
109 store: null,
110 strictTools: null,
111 sessionAffinity: null,
112 cacheControl: null,
113 toolStream: null,
114 reasoningEffort: true,
115 })
116 expect(got.factSources?.requestMap).toEqual({
117 derivation: 'upstream-spec',
118 sourceUrl: falEndpointSpecUrl(LISTING, rawId),
119 endpointId: rawId,
120 path: '/properties/max_completion_tokens',
121 })
122 })
123​
124 it('reads `max_tokens` and a single media field', () => {
125 const got = facts(fixture('nvidia/nemotron-3-nano-omni/vision'))
126 expect(got.maxOutput).toBe(20_000)
127 expect(got.modalities).toEqual({
128 input: ['text', 'image'],
129 output: ['text'],
130 })
131 // `reasoning_mode` is the endpoint's own think/no_think switch. The
132 // schema walk knows no such field, so the flag list is unchanged.
133 expect(got.reasoning).toEqual({ mode: 'toggle', mandatory: false })
134 expect(got.factSources?.reasoning).toMatchObject({
135 derivation: 'upstream-spec',
136 endpointId: 'nvidia/nemotron-3-nano-omni/vision',
137 path: '/properties/reasoning_mode',
138 })
139 expect(got.capabilities).toEqual(
140 expect.arrayContaining(['max_tokens', 'temperature', 'top_p']),
141 )
142 expect(got.capabilities).not.toContain('reasoning')
143 expect(got.contextWindow).toBeUndefined()
144 expect(got.requestMap).toMatchObject({
145 thinking: {
146 on: { reasoning_mode: 'think' },
147 off: { reasoning_mode: 'no_think' },
148 levels: null,
149 },
150 maxTokensField: 'max_tokens',
151 reasoningEffort: null,
152 })
153 expect(got.factSources?.requestMap?.path).toBe('/properties/max_tokens')
154 })
155​
156 it('reads a spec whose path uses the app alias, not the endpoint id', () => {
157 const model = fixture('nvidia/nemotron-3-nano-omni/vision')
158 const aliased = Object.fromEntries(
159 Object.entries(model.openapi.paths ?? {}).map(([path, operations]) => [
160 path.replace('/nvidia/', '/fal-ai/'),
161 operations,
162 ]),
163 )
164 model.openapi.paths = aliased
165 expect(facts(model).maxOutput).toBe(20_000)
166 // Two POST paths: which one is the endpoint is not stated.
167 model.openapi.paths = { ...aliased, '/other': { post: {} } }
168 expect(facts(model)).toEqual({})
169 })
170​
171 it('states no window, cap, or reasoning for a router', () => {
172 const got = facts(fixture('openrouter/router/video'))
173 expect(got.contextWindow).toBeUndefined()
174 // `max_tokens` has no maximum: the cap is the routed model's.
175 expect(got.maxOutput).toBeUndefined()
176 expect(got.reasoning).toBeUndefined()
177 expect(got.capabilities).not.toContain('reasoning')
178 expect(got.capabilities).toEqual(
179 expect.arrayContaining(['max_tokens', 'temperature']),
180 )
181 expect(got.modalities).toEqual({
182 input: ['text', 'video'],
183 output: ['text'],
184 })
185 // `reasoning: boolean` asks for the trace. It is not the thinking body.
186 expect(got.requestMap).toMatchObject({
187 thinking: null,
188 maxTokensField: 'max_tokens',
189 reasoningEffort: null,
190 })
191 })
192​
193 it('names no text input without a `prompt` field', () => {
194 const got = facts(fixture('openrouter/router/decisions'))
195 expect(got.modalities).toBeUndefined()
196 expect(got.capabilities).toEqual([])
197 expect(got.requestMap).toBeUndefined()
198 })
199​
200 it('leaves an endpoint with an empty request schema untouched', () => {
201 expect(
202 facts(fixture('openrouter/router/openai/v1/chat/completions')),
203 ).toEqual({})
204 const model = fixture('fal-ai/bytedance/seed/v2/mini')
205 expect(falChatFacts({ endpoint_id: model.endpoint_id }, LISTING)).toEqual(
206 {},
207 )
208 })
209​
210 it('stores nothing when the schema is reworded', () => {
211 const model = fixture('fal-ai/bytedance/seed/v2/mini')
212 const properties = inputProperties(model)
213 // The cap moves into prose, the toggle changes vocabulary.
214 delete properties.max_completion_tokens?.maximum
215 properties.thinking!.enum = ['on', 'off']
216 model.metadata.description = 'Up to 256,000 tokens of context.'
217 const got = facts(model)
218 expect(got.maxOutput).toBeUndefined()
219 expect(got.reasoning).toBeUndefined()
220 expect(got.capabilities).not.toContain('reasoning')
221 expect(got.contextWindow).toBeUndefined()
222 })
223​
224 it('stores no toggle for a `reasoning_mode` it does not know', () => {
225 for (const values of [
226 ['think'],
227 ['think', 'no_think', 'auto'],
228 ['on', 'off'],
229 [],
230 ]) {
231 const model = fixture('nvidia/nemotron-3-nano-omni/vision')
232 inputProperties(model).reasoning_mode!.enum = values
233 expect(facts(model).reasoning).toBeUndefined()
234 expect(facts(model).factSources?.reasoning).toBeUndefined()
235 }
236 // A free-text field of that name is not a switch.
237 const text = fixture('nvidia/nemotron-3-nano-omni/vision')
238 delete inputProperties(text).reasoning_mode!.enum
239 expect(facts(text).reasoning).toBeUndefined()
240 })
241​
242 it('does not read a non-integer or unbounded cap', () => {
243 const model = fixture('nvidia/nemotron-3-nano-omni/vision')
244 inputProperties(model).max_tokens!.type = 'string'
245 expect(facts(model).maxOutput).toBeUndefined()
246 const other = fixture('nvidia/nemotron-3-nano-omni/vision')
247 inputProperties(other).max_tokens!.maximum = '20000'
248 expect(facts(other).maxOutput).toBeUndefined()
249 })
250​
251 it('marks reasoning mandatory when it cannot be disabled', () => {
252 const model = fixture('fal-ai/bytedance/seed/v2/mini')
253 inputProperties(model).thinking!.enum = ['enabled', 'auto']
254 expect(facts(model).reasoning?.mandatory).toBe(true)
255 })
256})
257​
258describe('falDescriptionContextWindow', () => {
259 it('reads one stated size', () => {
260 expect(falDescriptionContextWindow('video input with 256K context')).toBe(
261 256_000,
262 )
263 expect(falDescriptionContextWindow('a 1M context model')).toBe(1_000_000)
264 })
265​
266 it('refuses anything else', () => {
267 for (const text of [
268 undefined,
269 '',
270 'long-context reasoning model',
271 'provide context to the model',
272 'from 128K context to 256K context',
273 '256K tokens',
274 '256 context',
275 'renders 4K video',
276 ]) {
277 expect(falDescriptionContextWindow(text), String(text)).toBeNull()
278 }
279 })
280})
281​
282/** A Pricing section that names no dollar amount. Not a failed fetch. */
283const NO_TOKEN_PRICE = `# Model
284​
285## Pricing
286​
287You will be charged based on the number of input and output tokens.
288​
289## API
291​
292const SEED_LLMS = `# Seed
293​
294## Pricing
295​
296Your request will cost **$0.0001** per 1000 units. For inputs under 128k tokens, the units per input token is 1. For inputs of over 128k tokens, 2 units will be charged per token. Similarly, each output token costs 4 units, provided the total output length (reasoning + output) is under 128k tokens, and 8 units per token otherwise.
297​
298For more details, see [fal.ai pricing](https://fal.ai/pricing).
299​
300## API
302​
303describe('fal listModels', () => {
304 afterEach(() => {
305 vi.unstubAllGlobals()
306 })
307​
308 const image = {
309 endpoint_id: 'fal-ai/flux/dev',
310 metadata: { category: 'text-to-image' },
311 }
312 const listed = fixtures.map(({ endpoint_id, metadata }) => ({
313 endpoint_id,
314 metadata,
315 }))
316​
317 function page(models: Array<unknown>): Response {
318 return new Response(
319 JSON.stringify({ models, has_more: false, next_cursor: null }),
320 )
321 }
322​
323 function endpointNotFound(): Response {
324 return new Response(
325 JSON.stringify({
326 error: { type: 'not_found', message: 'Endpoint(s) not found' },
327 }),
328 { status: 404, headers: { 'Content-Type': 'application/json' } },
329 )
330 }
331​
332 function respond(
333 input: string,
334 llms: (pathname: string) => string,
335 ): Response {
336 const url = new URL(input)
337 if (url.hostname === 'fal.ai') return new Response(llms(url.pathname))
338 return url.searchParams.has('endpoint_id')
339 ? page(fixtures)
340 : page([image, ...listed])
341 }
342​
343 it('fills chat rows from one spec request by endpoint id', async () => {
344 const urls: Array<URL> = []
345 vi.stubGlobal('fetch', (input: string) => {
346 const url = new URL(input)
347 urls.push(url)
348 return Promise.resolve(respond(input, () => NO_TOKEN_PRICE))
349 })
350 const { models } = await falProvider.listModels({ FAL_KEY: 'k' })
351 // Listing, the chat spec page, one llms.txt per chat endpoint, then
352 // the unlisted fal-ai/whisper lookup. The mock page has no whisper row.
353 expect(urls).toHaveLength(3 + listed.length)
354 expect(urls[0]?.searchParams.has('expand')).toBe(false)
355 expect(urls[1]?.searchParams.get('expand')).toBe('openapi-3.0')
356 expect(urls[1]?.searchParams.getAll('endpoint_id').sort()).toEqual(
357 fixtures.map((m) => m.endpoint_id).sort(),
358 )
359 const whisperLookup = urls.find(
360 (url) => url.searchParams.get('endpoint_id') === 'fal-ai/whisper',
361 )
362 expect(whisperLookup?.searchParams.get('expand')).toBe('openapi-3.0')
363 expect(models.some((model) => model.rawId === 'fal-ai/whisper')).toBe(false)
364 const byId = new Map(models.map((m) => [m.rawId, m]))
365 expect(byId.get('fal-ai/flux/dev')).toMatchObject({
366 activity: 'image',
367 providerMetadata: { category: 'text-to-image' },
368 })
369 expect(byId.get('fal-ai/flux/dev')?.factSources).toBeUndefined()
370 expect(byId.get('fal-ai/bytedance/seed/v2/mini')).toMatchObject({
371 activity: 'chat',
372 contextWindow: 256_000,
373 maxOutput: 65_536,
374 })
375 expect(byId.get('fal-ai/bytedance/seed/v2/mini')?.pricing).toBeUndefined()
376 expect(byId.get('openrouter/router/video')?.requestMap).toMatchObject({
377 maxTokensField: 'max_tokens',
378 thinking: null,
379 })
380 // No request schema: no flags. FAL's category is metadata on every row.
381 const router = byId.get('openrouter/router/openai/v1/chat/completions')
382 expect(router?.capabilities).toBeUndefined()
383 expect(router?.providerMetadata).toEqual({ category: 'llm' })
384 })
385​
386 it('stores a chat token card from that endpoint llms.txt', async () => {
387 vi.stubGlobal('fetch', (input: string) =>
388 Promise.resolve(
389 respond(input, (pathname) =>
390 pathname.includes('bytedance/seed/v2/mini')
391 ? SEED_LLMS
392 : NO_TOKEN_PRICE,
393 ),
394 ),
395 )
396 const { models } = await falProvider.listModels({ FAL_KEY: 'k' })
397 const seed = models.find((m) => m.rawId === 'fal-ai/bytedance/seed/v2/mini')
398 const rate = (
399 seed!.pricing as {
400 tables?: { rate?: { base?: Record<string, number> } }
401 }
402 ).tables?.rate?.base
403 expect(rate).toEqual({
404 input_tokens: 0.0001 / 1000,
405 output_tokens: (0.0001 / 1000) * 4,
406 })
407 expect(seed?.factSources?.pricing).toMatchObject({
408 derivation: 'docs-extracted',
409 sourceUrl: 'https://fal.ai/models/fal-ai/bytedance/seed/v2/mini/llms.txt',
410 path: 'Pricing',
411 })
412 expect(
413 models.find((m) => m.rawId === 'openrouter/router/video')?.pricing,
414 ).toBeUndefined()
415 })
416​
417 it('lists every row and withholds chat facts when a chat spec is missing', async () => {
418 vi.stubGlobal('fetch', (input: string) => {
419 const url = new URL(input)
420 if (url.hostname === 'fal.ai')
421 return Promise.resolve(new Response(NO_TOKEN_PRICE))
422 return Promise.resolve(
423 url.searchParams.has('endpoint_id')
424 ? page(fixtures.slice(1))
425 : page([image, ...listed]),
426 )
427 })
428 const result = await falProvider.listModels({ FAL_KEY: 'k' })
429 expect(result.docsFailures?.first).toMatchObject([
430 {
431 source:
432 'https://api.fal.ai/v1/models?expand=openapi-3.0 (chat endpoints)',
433 error: expect.stringContaining(
434 'fal chat specs: models API left out',
435 ) as string,
436 },
437 ])
438 expect(result.models).toHaveLength(listed.length + 1)
439 for (const model of result.models) {
440 if (model.activity === 'chat') {
441 expect(model.absent).toEqual({
442 contextWindow: 'unavailable',
443 maxOutput: 'unavailable',
444 modalities: 'unavailable',
445 capabilities: 'unavailable',
446 reasoning: 'unavailable',
447 requestMap: 'unavailable',
448 })
449 } else {
450 expect(model.absent).toBeUndefined()
451 }
452 }
453 })
454​
455 it('indexes fal-ai/whisper from a direct lookup when the active search omits it', async () => {
456 const whisper = {
457 endpoint_id: 'fal-ai/whisper',
458 metadata: null,
459 retires_at: null,
460 openapi: {
461 openapi: '3.0.4',
462 info: {
463 title: 'Whisper',
464 'x-fal-metadata': {
465 category: 'speech-to-text',
466 endpointId: 'fal-ai/whisper',
467 },
468 },
469 paths: {
470 '/': {
471 post: {
472 operationId: 'whisper',
473 responses: { '200': { description: 'ok' } },
474 },
475 },
476 },
477 },
478 }
479 vi.stubGlobal('fetch', (input: string) => {
480 const url = new URL(input)
481 if (url.hostname === 'fal.ai')
482 return Promise.resolve(new Response(NO_TOKEN_PRICE))
483 if (url.searchParams.get('endpoint_id') === 'fal-ai/whisper') {
484 return Promise.resolve(page([whisper]))
485 }
486 return Promise.resolve(
487 url.searchParams.has('endpoint_id')
488 ? page(fixtures)
489 : page([image, ...listed]),
490 )
491 })
492 const { models } = await falProvider.listModels({ FAL_KEY: 'k' })
493 expect(
494 models.find((model) => model.rawId === 'fal-ai/whisper'),
495 ).toMatchObject({
496 activity: 'audio',
497 deprecated: false,
498 displayName: null,
499 providerMetadata: { category: 'speech-to-text' },
500 })
501 expect(
502 models.filter((model) => model.rawId === 'fal-ai/whisper'),
503 ).toHaveLength(1)
504 })
505​
506 it('skips fal-ai/whisper when the direct lookup 404s', async () => {
507 const error = vi.spyOn(console, 'error').mockImplementation(() => undefined)
508 vi.stubGlobal('fetch', (input: string) => {
509 const url = new URL(input)
510 if (url.hostname === 'fal.ai')
511 return Promise.resolve(new Response(NO_TOKEN_PRICE))
512 if (url.searchParams.get('endpoint_id') === 'fal-ai/whisper') {
513 return Promise.resolve(endpointNotFound())
514 }
515 return Promise.resolve(
516 url.searchParams.has('endpoint_id')
517 ? page(fixtures)
518 : page([image, ...listed]),
519 )
520 })
521 const { models } = await falProvider.listModels({ FAL_KEY: 'k' })
522 expect(models.some((model) => model.rawId === 'fal-ai/whisper')).toBe(false)
523 expect(models).toHaveLength(listed.length + 1)
524 expect(error).toHaveBeenCalledWith(
525 expect.stringContaining(
526 'fal-ai/whisper: no longer served at https://api.fal.ai/v1/models?',
527 ) as string,
528 )
529 const line = String(error.mock.calls[0]?.[0])
530 expect(line).toContain('endpoint_id=fal-ai%2Fwhisper')
531 expect(line).toContain('404 Endpoint(s) not found')
532 error.mockRestore()
533 })
534​
535 it('fails the poll when an unlisted lookup 404s for another reason', async () => {
536 vi.stubGlobal('fetch', (input: string) => {
537 const url = new URL(input)
538 if (url.hostname === 'fal.ai')
539 return Promise.resolve(new Response(NO_TOKEN_PRICE))
540 if (url.searchParams.get('endpoint_id') === 'fal-ai/whisper') {
541 return Promise.resolve(new Response('missing', { status: 404 }))
542 }
543 return Promise.resolve(
544 url.searchParams.has('endpoint_id')
545 ? page(fixtures)
546 : page([image, ...listed]),
547 )
548 })
549 await expect(falProvider.listModels({ FAL_KEY: 'k' })).rejects.toThrow(
550 'fal models fetch failed: 404',
551 )
552 })
553​
554 it('omits a listed chat endpoint whose endpoint_id filter 404s', async () => {
555 const goneId = 'fal-ai/video-prompt-generator'
556 const error = vi.spyOn(console, 'error').mockImplementation(() => undefined)
557 vi.stubGlobal('fetch', (input: string) => {
558 const url = new URL(input)
559 if (url.hostname === 'fal.ai')
560 return Promise.resolve(new Response(NO_TOKEN_PRICE))
561 const ids = url.searchParams.getAll('endpoint_id')
562 if (ids.includes(goneId)) return Promise.resolve(endpointNotFound())
563 if (ids.length === 0) {
564 return Promise.resolve(
565 page([
566 image,
567 ...listed,
568 { endpoint_id: goneId, metadata: { category: 'llm' } },
569 ]),
570 )
571 }
572 if (ids.length === 1 && ids[0] === 'fal-ai/whisper') {
573 return Promise.resolve(page([]))
574 }
575 const wanted = new Set(ids)
576 return Promise.resolve(
577 page(fixtures.filter((model) => wanted.has(model.endpoint_id))),
578 )
579 })
580 const result = await falProvider.listModels({ FAL_KEY: 'k' })
581 expect(result.models.some((model) => model.rawId === goneId)).toBe(false)
582 expect(result.models).toHaveLength(listed.length + 1)
583 expect(result.docsFailures?.failed).toBe(0)
584 expect(
585 result.models.find(
586 (model) => model.rawId === 'fal-ai/bytedance/seed/v2/mini',
587 ),
588 ).toMatchObject({ activity: 'chat', contextWindow: 256_000 })
589 const line = error.mock.calls.map((call) => String(call[0])).join('\n')
590 expect(line).toContain(
591 `${goneId}: no longer served at https://api.fal.ai/v1/models?`,
592 )
593 expect(line).toContain('endpoint_id=fal-ai%2Fvideo-prompt-generator')
594 expect(line).toContain('expand=openapi-3.0')
595 expect(line).not.toContain('fal-ai/whisper')
596 error.mockRestore()
597 })
598​
599 it('keeps the rows when a filtered 404 is not Endpoint(s) not found', async () => {
600 const goneId = 'fal-ai/video-prompt-generator'
601 vi.stubGlobal('fetch', (input: string) => {
602 const url = new URL(input)
603 if (url.hostname === 'fal.ai')
604 return Promise.resolve(new Response(NO_TOKEN_PRICE))
605 const ids = url.searchParams.getAll('endpoint_id')
606 if (ids.includes(goneId)) {
607 return Promise.resolve(new Response('nope', { status: 404 }))
608 }
609 if (ids.length === 1 && ids[0] === 'fal-ai/whisper') {
610 return Promise.resolve(page([]))
611 }
612 return Promise.resolve(
613 ids.length === 0
614 ? page([
615 image,
616 ...listed,
617 { endpoint_id: goneId, metadata: { category: 'llm' } },
618 ])
619 : page(fixtures),
620 )
621 })
622 const result = await falProvider.listModels({ FAL_KEY: 'k' })
623 expect(result.models.some((model) => model.rawId === goneId)).toBe(true)
624 expect(result.docsFailures?.first[0]?.error).toContain(
625 'fal models fetch failed: 404',
626 )
627 expect(result.models).toHaveLength(listed.length + 2)
628 })
629​
630 it('marks an unlisted endpoint deprecated once retires_at is past', async () => {
631 vi.stubGlobal('fetch', (input: string) => {
632 const url = new URL(input)
633 if (url.hostname === 'fal.ai')
634 return Promise.resolve(new Response(NO_TOKEN_PRICE))
635 if (url.searchParams.get('endpoint_id') === 'fal-ai/whisper') {
636 return Promise.resolve(
637 page([
638 {
639 endpoint_id: 'fal-ai/whisper',
640 metadata: null,
641 retires_at: '2020-01-01T00:00:00.000Z',
642 openapi: {
643 info: { 'x-fal-metadata': { category: 'speech-to-text' } },
644 paths: {
645 '/': {
646 post: {
647 responses: { '200': { description: 'ok' } },
648 },
649 },
650 },
651 },
652 },
653 ]),
654 )
655 }
656 return Promise.resolve(
657 url.searchParams.has('endpoint_id')
658 ? page(fixtures)
659 : page([image, ...listed]),
660 )
661 })
662 const { models } = await falProvider.listModels({ FAL_KEY: 'k' })
663 expect(
664 models.find((model) => model.rawId === 'fal-ai/whisper'),
665 ).toMatchObject({ activity: 'audio', deprecated: true })
666 })
667​
668 it('fails the poll when the listing itself fails', async () => {
669 vi.stubGlobal('fetch', () =>
670 Promise.resolve(new Response('denied', { status: 401 })),
671 )
672 await expect(falProvider.listModels({ FAL_KEY: 'k' })).rejects.toThrow()
673 })
674})