Open History to see the last commit
1import { afterEach, describe, expect, it } from 'vitest'
2
3import gptOss from '../fixtures/workers-ai-gpt-oss-120b.json'
4import {
5 catalogFacts,
6 chatBodyFields,
7 parseCatalogModel,
8 provider,
9 thinkingSwitch,
10 WORKERS_AI_CATALOG_URL,
11 WORKERS_AI_MODELS_URL,
12} from './cloudflare-workers-ai.ts'
13import type { CatalogDoc } from './cloudflare-workers-ai.ts'
14
15/** Excerpt of developers.cloudflare.com/workers-ai/models/ (2026-10-07). */
16const GLM_CARD = `<div data-model-id="@cf/zai-org/glm-5.3" data-model-label="glm-5.3" data-model-href="/workers-ai/models/glm-5.3/" data-model-task="Text Generation" data-model-context="1048576" data-model-pricing="Input (per 1M tokens): $1.40
17Output (per 1M tokens): $4.40
18Cached input (per 1M tokens): $0.26"></div>`
19const APERTUS_CARD = `<div data-model-id="@cf/swiss-ai/apertus-v1.5-8b" data-model-label="apertus-v1.5-8b" data-model-href="/workers-ai/models/apertus-v1.5-8b/" data-model-task="Text Generation" data-model-context="262144" data-model-output data-model-pricing></div>`
20const OTHER_CARDS = `<div data-model-id="@cf/deepgram/aura-1" data-model-label="aura-1" data-model-href="/workers-ai/models/aura-1/" data-model-task="Text-to-Speech" data-model-pricing="per 1k characters: $0.015"></div>
21<div data-model-id="@cf/black-forest-labs/flux-1-schnell" data-model-label="flux-1-schnell" data-model-task="Text-to-Image"></div>`
22const FIXTURE = [GLM_CARD, APERTUS_CARD, OTHER_CARDS].join('\n')
23
24const GLM_URL = `${WORKERS_AI_CATALOG_URL}glm-5.3.json`
25const APERTUS_URL = `${WORKERS_AI_CATALOG_URL}apertus-v1.5-8b.json`
26
27/** The two chat-completions request shapes Cloudflare's files use. */
28const body = (...fields: Array<string>) => ({
29 properties: Object.fromEntries(fields.map((name) => [name, {}])),
30})
31const LEGACY_INPUT = {
32 type: 'object',
33 oneOf: [
34 { title: 'Prompt', ...body('prompt', 'max_tokens') },
35 { title: 'Messages', ...body('messages', 'tools', 'max_tokens') },
36 ],
37}
38const effortInput = (efforts: Array<string>) => ({
39 anyOf: [
40 {
41 oneOf: [
42 { title: 'Prompt', ...body('prompt', 'max_tokens') },
43 {
44 title: 'Messages',
45 properties: {
46 messages: {},
47 max_tokens: {},
48 max_completion_tokens: {},
49 reasoning_effort: {
50 anyOf: [{ type: 'string', enum: efforts }, { type: 'null' }],
51 },
52 },
53 },
54 ],
55 },
56 { ...body('requests') },
57 ],
58})
59
60/** `properties` are verbatim from Cloudflare's files; schemas are cut down. */
61function catalogFile(
62 name: string,
63 properties: Array<{ property_id: string; value: unknown }>,
64 schema?: { input: unknown; output?: unknown },
65): string {
66 return JSON.stringify({
67 name,
68 task: { name: 'Text Generation' },
69 properties,
70 ...(schema ? { schema } : {}),
71 })
72}
73
74const GLM_PROPERTIES = [
75 { property_id: 'require_workers_paid', value: 'true' },
76 { property_id: 'context_window', value: '1048576' },
77 { property_id: 'function_calling', value: 'true' },
78 { property_id: 'reasoning', value: 'true' },
79 {
80 property_id: 'reasoning_effort',
81 value: {
82 supported_efforts: ['max', 'high', 'low'],
83 default_effort: 'max',
84 normalizes_to: { none: 'max', minimal: 'max', medium: 'max' },
85 mandatory: true,
86 default_enabled: true,
87 },
88 },
89]
90const GLM = catalogFile('@cf/zai-org/glm-5.3', GLM_PROPERTIES, {
91 input: effortInput(['max', 'high', 'low']),
92 output: { type: 'object', properties: { choices: { type: 'array' } } },
93})
94const APERTUS = catalogFile('@cf/swiss-ai/apertus-v1.5-8b', [
95 { property_id: 'context_window', value: '262144' },
96 { property_id: 'function_calling', value: 'true' },
97 { property_id: 'vision', value: 'true' },
98])
99
100function facts(text: string, rawId: string, edit?: (doc: CatalogDoc) => void) {
101 const url = `${WORKERS_AI_CATALOG_URL}x.json`
102 const parsed = parseCatalogModel(text, rawId, url)
103 const doc: CatalogDoc = {
104 properties: parsed.properties,
105 chatFields: chatBodyFields(parsed.input),
106 thinkingSwitch: thinkingSwitch(parsed.input),
107 hasRequestSchema: parsed.input !== null,
108 hash: 'h',
109 }
110 edit?.(doc)
111 return catalogFacts(doc, rawId, url)
112}
113
114const originalFetch = globalThis.fetch
115
116afterEach(() => {
117 globalThis.fetch = originalFetch
118})
119
120function stubFetch(pages: Record<string, string>): Array<string> {
121 const urls: Array<string> = []
122 globalThis.fetch = ((url: string) => {
123 urls.push(String(url))
124 const page = pages[String(url)]
125 return Promise.resolve(
126 page === undefined
127 ? new Response('<html>Not found</html>', { status: 404 })
128 : new Response(page),
129 )
130 }) as typeof fetch
131 return urls
132}
133
134describe('cloudflare-workers-ai listing', () => {
135 it('lists catalog cards and prices only per-1M input and output', async () => {
136 const urls = stubFetch({
137 [WORKERS_AI_MODELS_URL]: FIXTURE,
138 [GLM_URL]: GLM,
139 [APERTUS_URL]: APERTUS,
140 })
141
142 const listed = await provider.listModels({})
143 const glm = listed.models.find(
144 (model) => model.rawId === '@cf/zai-org/glm-5.3',
145 )
146 const aura = listed.models.find(
147 (model) => model.rawId === '@cf/deepgram/aura-1',
148 )
149
150 expect(listed.models.map((model) => model.rawId)).toEqual([
151 '@cf/zai-org/glm-5.3',
152 '@cf/swiss-ai/apertus-v1.5-8b',
153 '@cf/deepgram/aura-1',
154 '@cf/black-forest-labs/flux-1-schnell',
155 ])
156 expect(glm).toMatchObject({
157 activity: 'chat',
158 contextWindow: 1048576,
159 displayName: 'glm-5.3',
160 capabilities: ['tools', 'reasoning'],
161 schemaEndpointId: 'accounts/{account_id}/ai/run/@cf/zai-org/glm-5.3',
162 })
163 expect(glm).not.toHaveProperty('catalogUrl')
164 expect(glm?.pricing).toMatchObject({
165 tables: {
166 rate: {
167 base: {
168 input_tokens: 1.4 / 1_000_000,
169 output_tokens: 4.4 / 1_000_000,
170 cache_read_tokens: 0.26 / 1_000_000,
171 },
172 },
173 },
174 })
175 // Only text-generation cards read a catalog file.
176 expect(aura).toEqual({
177 rawId: '@cf/deepgram/aura-1',
178 displayName: 'aura-1',
179 activity: 'audio',
180 contextWindow: null,
181 pricing: null,
182 })
183 expect(listed.models[3]).toMatchObject({ activity: 'image', pricing: null })
184 expect(urls.sort()).toEqual(
185 [WORKERS_AI_MODELS_URL, GLM_URL, APERTUS_URL].sort(),
186 )
187 })
188
189 it('withholds only that model’s catalog facts when one file cannot be read', async () => {
190 // A 404, a 200 that is an HTML page, and a 200 that is another model's file.
191 const unreadable: Array<[string | undefined, RegExp]> = [
192 [undefined, /apertus.*404/],
193 ['<!doctype html><title>Sign in</title>', /is not JSON/],
194 [GLM, /is not the catalog file for @cf\/swiss-ai\/apertus-v1.5-8b/],
195 ]
196 for (const [apertus, error] of unreadable) {
197 stubFetch({
198 [WORKERS_AI_MODELS_URL]: FIXTURE,
199 [GLM_URL]: GLM,
200 ...(apertus === undefined ? {} : { [APERTUS_URL]: apertus }),
201 })
202 const listed = await provider.listModels({})
203 expect(listed.docsFailures?.first).toMatchObject([
204 { source: APERTUS_URL, error: expect.stringMatching(error) as string },
205 ])
206 const [glm, failed] = listed.models
207 // The listing page's own facts and the other model's file still land.
208 expect(glm).toMatchObject({ capabilities: ['tools', 'reasoning'] })
209 expect(glm?.absent).toBeUndefined()
210 expect(glm?.pricing).not.toBeNull()
211 expect(failed).toMatchObject({
212 rawId: '@cf/swiss-ai/apertus-v1.5-8b',
213 activity: 'chat',
214 absent: {
215 modalities: 'unavailable',
216 capabilities: 'unavailable',
217 reasoning: 'unavailable',
218 requestMap: 'unavailable',
219 schemaEndpointId: 'unavailable',
220 },
221 })
222 expect(failed).not.toHaveProperty('capabilities')
223 }
224 })
225
226 it('fails when a text-generation card links no model page', async () => {
227 stubFetch({
228 [WORKERS_AI_MODELS_URL]:
229 '<div data-model-id="@cf/a/b" data-model-href="https://example.com/b/" data-model-task="Text Generation"></div>',
230 })
231 await expect(provider.listModels({})).rejects.toThrow(
232 /@cf\/a\/b links no model page/,
233 )
234 })
235})
236
237describe('cloudflare-workers-ai catalog facts', () => {
238 it('reads efforts, flags, and the request map from an effort model', () => {
239 const glm = facts(GLM, '@cf/zai-org/glm-5.3')
240 expect(glm).toMatchObject({
241 modalities: { input: ['text'], output: ['text'] },
242 capabilities: ['tools', 'reasoning'],
243 exactCapabilities: true,
244 reasoning: {
245 mode: 'effort',
246 mandatory: true,
247 efforts: ['max', 'high', 'low'],
248 },
249 requestMap: {
250 thinking: {
251 on: { reasoning_effort: 'high' },
252 off: null,
253 levels: {
254 off: null,
255 minimal: null,
256 low: 'low',
257 medium: null,
258 high: 'high',
259 xhigh: null,
260 max: 'max',
261 },
262 },
263 maxTokensField: 'max_completion_tokens',
264 developerRole: null,
265 reasoningEffort: true,
266 },
267 })
268 expect(glm.factSources).toMatchObject({
269 modalities: { sourceUrl: `${WORKERS_AI_CATALOG_URL}x.json` },
270 capabilities: {
271 tools: { derivation: 'listing', path: 'properties.function_calling' },
272 reasoning: { path: 'properties.reasoning' },
273 },
274 reasoning: { sourceHash: 'h', path: 'properties.reasoning_effort' },
275 })
276 })
277
278 it('maps a "none" effort to an explicit off', () => {
279 const kimi = facts(
280 catalogFile(
281 '@cf/moonshotai/kimi-k2.6',
282 [
283 { property_id: 'reasoning', value: 'true' },
284 {
285 property_id: 'reasoning_effort',
286 value: {
287 supported_efforts: ['high', 'none'],
288 default_effort: 'high',
289 mandatory: false,
290 default_enabled: true,
291 },
292 },
293 { property_id: 'vision', value: 'true' },
294 ],
295 { input: effortInput(['high', 'none']) },
296 ),
297 '@cf/moonshotai/kimi-k2.6',
298 )
299 expect(kimi.modalities).toEqual({
300 input: ['text', 'image'],
301 output: ['text'],
302 })
303 expect(kimi.reasoning).toEqual({
304 mode: 'effort',
305 mandatory: false,
306 efforts: ['high', 'none'],
307 })
308 expect(kimi.requestMap?.thinking).toMatchObject({
309 off: { reasoning_effort: 'none' },
310 levels: { off: 'none', high: 'high', max: null },
311 })
312 })
313
314 /** A chat body with `chat_template_kwargs.enable_thinking`, as published. */
315 const switchInput = (enableThinking: unknown) => ({
316 anyOf: [
317 {
318 oneOf: [
319 { title: 'Prompt', ...body('prompt', 'max_tokens') },
320 {
321 title: 'Messages',
322 properties: {
323 messages: {},
324 max_tokens: {},
325 max_completion_tokens: {},
326 chat_template_kwargs: {
327 type: 'object',
328 properties: {
329 enable_thinking: enableThinking,
330 clear_thinking: { type: 'boolean', default: false },
331 },
332 },
333 },
334 },
335 ],
336 },
337 { ...body('requests') },
338 ],
339 })
340 /** `enable_thinking` of gemma-4-26b-a4b-it and of kimi-k2.7-code (2026-10-07). */
341 const ON_OFF = {
342 type: 'boolean',
343 default: true,
344 description: 'Whether to enable reasoning for this model.',
345 }
346 const ON_ONLY = {
347 type: 'boolean',
348 default: true,
349 description:
350 'Reasoning is always enabled for this model and cannot be disabled.',
351 enum: [true],
352 }
353 const switched = (
354 rawId: string,
355 effort: unknown,
356 enableThinking: unknown,
357 edit?: (doc: CatalogDoc) => void,
358 ) =>
359 facts(
360 catalogFile(
361 rawId,
362 [
363 { property_id: 'reasoning', value: 'true' },
364 ...(effort === undefined
365 ? []
366 : [{ property_id: 'reasoning_effort', value: effort }]),
367 ],
368 { input: switchInput(enableThinking) },
369 ),
370 rawId,
371 edit,
372 )
373
374 it('reads an on/off toggle from the model’s own enable_thinking field', () => {
375 // On by default, can be turned off.
376 const gemma = switched(
377 '@cf/google/gemma-4-26b-a4b-it',
378 { mandatory: false, default_enabled: true },
379 ON_OFF,
380 )
381 expect(gemma.reasoning).toEqual({ mode: 'toggle', mandatory: false })
382 expect(gemma.capabilities).toEqual(['reasoning'])
383 expect(gemma.factSources?.reasoning).toMatchObject({
384 sourceHash: 'h',
385 path: 'chat_template_kwargs.enable_thinking',
386 })
387 // The request map is unchanged by the toggle.
388 expect(gemma.requestMap).toMatchObject({
389 thinking: null,
390 maxTokensField: 'max_completion_tokens',
391 reasoningEffort: null,
392 })
393
394 // The catalog states `mandatory: true`, and the field only takes `true`.
395 expect(
396 switched(
397 '@cf/moonshotai/kimi-k2.7-code',
398 { mandatory: true, default_enabled: true },
399 ON_ONLY,
400 ).reasoning,
401 ).toEqual({ mode: 'toggle', mandatory: true })
402 // The statement wins over a field that still offers `false`.
403 expect(
404 switched('@cf/moonshotai/kimi-k2.7-code', { mandatory: true }, ON_OFF)
405 .reasoning,
406 ).toEqual({ mode: 'toggle', mandatory: true })
407 // @cf/nvidia/nemotron-3-120b-a12b: no property, a plain boolean field.
408 expect(
409 switched('@cf/nvidia/nemotron-3-120b-a12b', undefined, ON_OFF).reasoning,
410 ).toEqual({ mode: 'toggle', mandatory: false })
411 })
412
413 it('stores no toggle without a request field or a stated off position', () => {
414 const none = (model: ReturnType<typeof facts>) => {
415 expect(model.reasoning).toBeUndefined()
416 expect(model.capabilities).toEqual(['reasoning'])
417 expect(model.factSources?.reasoning?.path).toBe('silent')
418 }
419 // @cf/qwen/qwq-32b: the catalog flag alone.
420 none(
421 facts(
422 catalogFile(
423 '@cf/qwen/qwq-32b',
424 [{ property_id: 'reasoning', value: 'true' }],
425 { input: body('messages', 'max_tokens') },
426 ),
427 '@cf/qwen/qwq-32b',
428 ),
429 )
430 // `mandatory` is stated but the request takes no switch.
431 none(
432 facts(
433 catalogFile(
434 '@cf/x/y',
435 [
436 { property_id: 'reasoning', value: 'true' },
437 { property_id: 'reasoning_effort', value: { mandatory: true } },
438 ],
439 { input: body('messages', 'max_tokens') },
440 ),
441 '@cf/x/y',
442 ),
443 )
444 // A field that only takes `true`, with no statement beside it.
445 none(switched('@cf/x/y', undefined, ON_ONLY))
446 // The catalog says it can be turned off; the field refuses `false`.
447 none(switched('@cf/x/y', { mandatory: false }, ON_ONLY))
448 // Shapes this does not know.
449 none(switched('@cf/x/y', undefined, { type: 'string', enum: ['on'] }))
450 none(switched('@cf/x/y', undefined, { ...ON_OFF, enum: [false] }))
451 none(switched('@cf/x/y', undefined, {}))
452 // An entry cached before the field was read claims no switch.
453 none(
454 switched('@cf/x/y', { mandatory: false }, ON_OFF, (doc) => {
455 delete doc.thinkingSwitch
456 }),
457 )
458 // A `mandatory` that is not a boolean is a changed file.
459 expect(() => switched('@cf/x/y', { mandatory: 'no' }, ON_OFF)).toThrow(
460 /reasoning_effort changed shape/,
461 )
462 })
463
464 it('reads enable_thinking only from bodies that take messages', () => {
465 expect(thinkingSwitch(switchInput(ON_OFF))).toBe('on-off')
466 expect(thinkingSwitch(switchInput(ON_ONLY))).toBe('on-only')
467 expect(thinkingSwitch(effortInput(['low']))).toBeNull()
468 expect(thinkingSwitch(null)).toBeNull()
469 const kwargs = (field: unknown) => ({
470 chat_template_kwargs: { properties: { enable_thinking: field } },
471 })
472 // A prompt body's switch is not the chat body's.
473 expect(
474 thinkingSwitch({
475 oneOf: [{ properties: { prompt: {}, ...kwargs(ON_OFF) } }],
476 }),
477 ).toBeNull()
478 // Two chat bodies that disagree state nothing.
479 expect(
480 thinkingSwitch({
481 oneOf: [
482 { properties: { messages: {}, ...kwargs(ON_OFF) } },
483 { properties: { messages: {}, ...kwargs(ON_ONLY) } },
484 ],
485 }),
486 ).toBeNull()
487 })
488
489 it('reads chat fields only from bodies that take messages', () => {
490 // The whole file as published: its Responses body has `reasoning`, its
491 // chat body has neither that nor `reasoning_effort`.
492 const text = JSON.stringify(gptOss)
493 const parsed = parseCatalogModel(text, '@cf/openai/gpt-oss-120b', 'u')
494 const fields = chatBodyFields(parsed.input)
495 expect(fields).toContain('messages')
496 expect(fields).toContain('max_tokens')
497 expect(fields).not.toContain('reasoning')
498 expect(fields).not.toContain('input')
499 expect(fields).not.toContain('prompt')
500
501 const oss = facts(text, '@cf/openai/gpt-oss-120b')
502 expect(oss.reasoning).toEqual({
503 mode: 'effort',
504 mandatory: true,
505 efforts: ['low', 'medium', 'high'],
506 })
507 expect(oss.requestMap).toMatchObject({
508 thinking: null,
509 maxTokensField: 'max_tokens',
510 reasoningEffort: null,
511 })
512 expect(oss.schemaEndpointId).toBe(
513 'accounts/{account_id}/ai/run/@cf/openai/gpt-oss-120b',
514 )
515 })
516
517 it('gives no "effort high" body to a model without that level', () => {
518 // @cf/qwen/qwen3.8-27b
519 const qwen = facts(
520 catalogFile(
521 '@cf/qwen/qwen3.8-27b',
522 [
523 {
524 property_id: 'reasoning_effort',
525 value: {
526 supported_efforts: ['low', 'medium', 'xhigh'],
527 mandatory: false,
528 },
529 },
530 ],
531 { input: effortInput(['low', 'medium', 'xhigh']) },
532 ),
533 '@cf/qwen/qwen3.8-27b',
534 )
535 expect(qwen.requestMap).toMatchObject({
536 thinking: null,
537 reasoningEffort: true,
538 })
539 })
540
541 it('claims nothing the file does not state', () => {
542 // No properties beyond the window: an empty, exact flag list.
543 const llama = facts(
544 catalogFile(
545 '@cf/meta/llama-3.2-1b-instruct',
546 [{ property_id: 'context_window', value: '60000' }],
547 { input: LEGACY_INPUT },
548 ),
549 '@cf/meta/llama-3.2-1b-instruct',
550 )
551 expect(llama.capabilities).toEqual([])
552 expect(llama.exactCapabilities).toBe(true)
553 expect(llama.reasoning).toBeUndefined()
554 expect(Object.keys(llama.factSources ?? {})).toEqual([
555 'modalities',
556 'capabilities',
557 ])
558 expect(llama.factSources?.capabilities).toEqual({})
559
560 // No schema: no route to bind and no request map.
561 const apertus = facts(APERTUS, '@cf/swiss-ai/apertus-v1.5-8b')
562 expect(apertus.schemaEndpointId).toBeUndefined()
563 expect(apertus.requestMap).toBeUndefined()
564 expect(apertus.capabilities).toEqual(['tools'])
565
566 // A schema that is not a chat body (@cf/cloudflare/clef): a route, but
567 // no chat request map.
568 const clef = facts(
569 catalogFile('@cf/cloudflare/clef', [], {
570 input: { type: 'object', ...body('model', 'state', 'questions') },
571 }),
572 '@cf/cloudflare/clef',
573 )
574 expect(clef.requestMap).toBeUndefined()
575 expect(clef.schemaEndpointId).toBe(
576 'accounts/{account_id}/ai/run/@cf/cloudflare/clef',
577 )
578 })
579
580 it('throws on a property that changed shape', () => {
581 const mutate = (id: string, value: unknown) => () =>
582 facts(GLM, '@cf/zai-org/glm-5.3', (doc) => {
583 doc.properties[id] = value
584 })
585 expect(mutate('function_calling', 'yes')).toThrow(/function_calling/)
586 expect(mutate('vision', true)).toThrow(/vision/)
587 expect(mutate('reasoning', 'high')).toThrow(/reasoning changed shape/)
588 expect(mutate('reasoning_effort', 'high')).toThrow(/reasoning_effort/)
589 expect(mutate('reasoning_effort', { supported_efforts: 'high' })).toThrow(
590 /reasoning_effort/,
591 )
592 expect(
593 mutate('reasoning_effort', { supported_efforts: [], mandatory: true }),
594 ).toThrow(/reasoning_effort/)
595 // Efforts without a stated `mandatory` are not defaulted to optional.
596 expect(
597 mutate('reasoning_effort', { supported_efforts: ['low', 'high'] }),
598 ).toThrow(/reasoning_effort/)
599 })
600
601 it('throws on a file that is not a catalog file', () => {
602 const parse = (text: string) => () =>
603 parseCatalogModel(text, '@cf/zai-org/glm-5.3', 'u')
604 expect(parse('[]')).toThrow(/is not the catalog file/)
605 expect(parse('{"name":"@cf/zai-org/glm-5.3"}')).toThrow(
606 /has no properties list/,
607 )
608 expect(
609 parse('{"name":"@cf/zai-org/glm-5.3","properties":[{"id":"x"}]}'),
610 ).toThrow(/malformed property/)
611 })
612})
613
614describe('cloudflare-workers-ai spec', () => {
615 it('builds one document per model that publishes a request schema', async () => {
616 stubFetch({
617 [WORKERS_AI_MODELS_URL]: FIXTURE,
618 [GLM_URL]: GLM,
619 [APERTUS_URL]: APERTUS,
620 })
621 const spec = await provider.fetchSpec({})
622 const path = '/accounts/{account_id}/ai/run/@cf/zai-org/glm-5.3'
623
624 expect(spec.skipped).toBeUndefined()
625 expect(spec.specs).toHaveLength(1)
626 expect(spec.sources.map((source) => source.url)).toEqual([GLM_URL])
627 expect(spec.sources[0]?.hash).toMatch(/^[0-9a-f]{64}$/)
628 const post = spec.specs[0]?.paths?.[path]?.post as {
629 requestBody: { content: Record<string, { schema: unknown }> }
630 responses: Record<
631 string,
632 { content: Record<string, { schema: unknown }> }
633 >
634 }
635 expect(post.requestBody.content['application/json']?.schema).toEqual(
636 effortInput(['max', 'high', 'low']),
637 )
638 expect(
639 post.responses['200']?.content['application/json']?.schema,
640 ).toMatchObject({ type: 'object' })
641 expect(provider.classify(path, {})).toBe('chat')
642 expect(provider.classify('/accounts/{account_id}/ai/models', {})).toBeNull()
643 })
644
645 it('throws when no model publishes a schema or a file is unreadable', async () => {
646 stubFetch({ [WORKERS_AI_MODELS_URL]: APERTUS_CARD, [APERTUS_URL]: APERTUS })
647 await expect(provider.fetchSpec({})).rejects.toThrow(
648 /no text-generation model published a request schema/,
649 )
650
651 stubFetch({ [WORKERS_AI_MODELS_URL]: FIXTURE, [GLM_URL]: GLM })
652 await expect(provider.fetchSpec({})).rejects.toThrow(/404/)
653 })
654})