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

openapi.ts

1,045 lines40.6 KB

1/**
2 * The service's own OpenAPI 3.1 document (PLAN.md task 4.1), hand-maintained.
3 * Single source of truth for three consumer surfaces: the generated TS client
4 * (task 7.4), the CLI (7.5), and the agent-auth capability list (5.1) — every
5 * operation MUST carry a unique operationId.
6 */
7​
8const activityEnum = [
9 'chat',
10 'image',
11 'video',
12 'audio',
13 'embeddings',
14 'moderation',
16​
17const changeTypeEnum = [
18 'model.added',
19 'model.removed',
20 'model.updated',
21 'schema.added',
22 'schema.updated',
23 'endpoint.added',
24 'endpoint.removed',
26​
27const errorResponse = {
28 description: 'Error',
29 content: {
30 'application/json': {
31 schema: { $ref: '#/components/schemas/Error' },
32 },
33 },
35​
36const providerParam = {
37 name: 'provider',
38 in: 'path',
39 required: true,
40 description: 'Provider slug (see GET /v1/providers).',
41 schema: { type: 'string' },
43​
44const activityParam = {
45 name: 'activity',
46 in: 'path',
47 required: true,
48 description: 'Activity group.',
49 schema: { type: 'string', enum: activityEnum },
51​
52export const openApiDocument = {
53 openapi: '3.1.0',
54 info: {
55 title: 'modelschemas',
56 version: '0.1.0',
57 description:
58 'Live AI model schema service: per-endpoint request/response JSON ' +
59 'Schemas and model metadata for monitored providers, with ' +
60 'stale-while-revalidate caching and a change feed. Anonymous reads ' +
61 'are allowed at a low rate limit; register (agent-auth or API key) ' +
62 'for higher limits and webhook subscriptions.',
63 },
64 servers: [{ url: '/' }],
65 paths: {
66 '/v1': {
67 get: {
68 operationId: 'getServiceIndex',
69 summary: 'Service description and endpoint index',
70 responses: {
71 '200': {
72 description: 'Service index with _links to every surface.',
73 content: { 'application/json': { schema: { type: 'object' } } },
74 },
75 },
76 },
77 },
78 '/v1/status': {
79 get: {
80 operationId: 'getStatus',
81 summary: 'Per-provider sync status and row counts',
82 parameters: [
83 {
84 name: 'wait',
85 in: 'query',
86 description:
87 'Long-poll: hold up to N seconds (cap 60; "30s" form accepted) until new data exists, then return current data.',
88 schema: { type: 'string' },
89 },
90 ],
91 responses: {
92 '200': {
93 description: 'Service status.',
94 content: {
95 'application/json': {
96 schema: { $ref: '#/components/schemas/ServiceStatus' },
97 },
98 },
99 },
100 },
101 },
102 },
103 '/v1/providers': {
104 get: {
105 operationId: 'listProviders',
106 summary: 'List monitored providers with sync status',
107 responses: {
108 '200': {
109 description: 'Providers.',
110 content: { 'application/json': { schema: { type: 'object' } } },
111 },
112 },
113 },
114 },
115 '/v1/providers/{provider}/models': {
116 get: {
117 operationId: 'listProviderModels',
118 summary: 'List models for one provider',
119 parameters: [providerParam],
120 responses: {
121 '200': {
122 description: 'Models for the provider.',
123 content: { 'application/json': { schema: { type: 'object' } } },
124 },
125 '404': errorResponse,
126 },
127 },
128 },
129 '/v1/models': {
130 get: {
131 operationId: 'listModels',
132 summary: 'Cross-provider model catalog',
133 description:
134 'The headline "what can I use right now" endpoint. Filterable.',
135 parameters: [
136 {
137 name: 'activity',
138 in: 'query',
139 schema: { type: 'string', enum: activityEnum },
140 },
141 { name: 'provider', in: 'query', schema: { type: 'string' } },
142 {
143 name: 'capability',
144 in: 'query',
145 description:
146 'A capability flag the model is stated to support: matches rows whose capabilities map has this key set to true (capability=tools). Exact flag name, not a substring.',
147 schema: { type: 'string' },
148 },
149 {
150 name: 'q',
151 in: 'query',
152 description: 'Free-text match against id and display name.',
153 schema: { type: 'string' },
154 },
155 {
156 name: 'provenance',
157 in: 'query',
158 description:
159 'Set to 1 to include per-field factSources on each list row. Model detail always includes factSources and OpenRouter discrepancies.',
160 schema: { type: 'string', enum: ['1'] },
161 },
162 {
163 name: 'pricing',
164 in: 'query',
165 description:
166 'Set to 1 to include the full rate card on each list row. Default is a compact summary: per-million base rates for token cards, otherwise the unit the card bills by.',
167 schema: { type: 'string', enum: ['1'] },
168 },
169 ],
170 responses: {
171 '200': {
172 description:
173 'Matching models. pricing is a compact token projection, a full RateCard when ?pricing=1, or null. OpenRouter-shaped vendor blobs are not served.',
174 content: {
175 'application/json': {
176 schema: { $ref: '#/components/schemas/ModelList' },
177 },
178 },
179 },
180 },
181 },
182 },
183 '/v1/models/{provider}/{modelId}': {
184 get: {
185 operationId: 'getModel',
186 summary: 'Full metadata for one model',
187 parameters: [
188 providerParam,
189 {
190 name: 'modelId',
191 in: 'path',
192 required: true,
193 description: 'Model slug or raw provider id.',
194 schema: { type: 'string' },
195 },
196 ],
197 responses: {
198 '200': {
199 description:
200 'Model metadata with activity, schemaEndpointId (canonical generation route on grain=provider catalogs), a RateCard or null for pricing, factSources (per-field provenance), OpenRouter discrepancies, and _links.schema when bound.',
201 content: {
202 'application/json': {
203 schema: { $ref: '#/components/schemas/Model' },
204 },
205 },
206 },
207 '404': errorResponse,
208 },
209 },
210 },
211 '/v1/schemas': {
212 get: {
213 operationId: 'listAllSchemas',
214 summary: 'System-wide schema index',
215 description:
216 'Every provider with extracted schemas, each with its activities and endpoint ids — the discovery entry point for all schemas on the system.',
217 responses: {
218 '200': {
219 description: 'Provider → activity → endpoint-id index.',
220 content: { 'application/json': { schema: { type: 'object' } } },
221 },
222 },
223 },
224 },
225 '/v1/schemas/{provider}': {
226 get: {
227 operationId: 'listProviderSchemas',
228 summary: 'Activities and endpoint ids for a provider',
229 parameters: [providerParam],
230 responses: {
231 '200': {
232 description: 'Activity → endpoint-id index.',
233 content: { 'application/json': { schema: { type: 'object' } } },
234 },
235 '404': errorResponse,
236 },
237 },
238 },
239 '/v1/schemas/{provider}/{activity}': {
240 get: {
241 operationId: 'getActivitySchemas',
242 summary: 'Endpoint-id-keyed schema map for one activity',
243 parameters: [providerParam, activityParam],
244 responses: {
245 '200': {
246 description:
247 'Map of endpoint id → { input, output } self-contained JSON Schemas (current versions).',
248 content: { 'application/json': { schema: { type: 'object' } } },
249 },
250 '404': errorResponse,
251 },
252 },
253 },
254 '/v1/schemas/{provider}/{activity}/{endpointId}': {
255 get: {
256 operationId: 'getSchema',
257 summary: 'One self-contained JSON Schema',
258 parameters: [
259 providerParam,
260 activityParam,
261 {
262 name: 'endpointId',
263 in: 'path',
264 required: true,
265 description:
266 "Path-derived endpoint id (URL-encode slashes), or a listed model rawId/slug which aliases onto that activity's generation route and pins the request `model` field.",
267 schema: { type: 'string' },
268 },
269 {
270 name: 'kind',
271 in: 'query',
272 description: 'Defaults to input.',
273 schema: { type: 'string', enum: ['input', 'output'] },
274 },
275 {
276 name: 'version',
277 in: 'query',
278 description: 'Content hash of a historical version.',
279 schema: { type: 'string' },
280 },
281 {
282 name: 'format',
283 in: 'query',
284 description:
285 'json (default) or types — a self-contained TypeScript module (schema const + generated types, tree-shakeable, zero imports). format=types on an input schema with a model property overlays the live catalog union plus ListedModelId; the schema const and content hash stay the bundled schema.',
286 schema: { type: 'string', enum: ['json', 'types'] },
287 },
288 {
289 name: 'optional',
290 in: 'query',
291 description:
292 'format=types only: optional-property style. exact (default) emits `foo?: T`; undefined emits `foo?: T | undefined`.',
293 schema: { type: 'string', enum: ['exact', 'undefined'] },
294 },
295 ],
296 responses: {
297 '200': {
298 description:
299 'Self-contained JSON Schema ($defs-bundled) — or, with format=types, a TypeScript module — served with ETag. ' +
300 'JSON responses carry `provenance` (upstream sourceUrl, sourceHash, fetchedAt, extractorVersion) so derivations are independently verifiable. ' +
301 '`provenance.derivation` grades how the content was arrived at — `upstream-spec` and `generated` are re-derived every sync and self-heal, while `probe-verified` (confirmed against live API calls on `provenance.verifiedAt`) and `docs-derived` (never confirmed) are point-in-time claims that can go stale.',
302 content: {
303 'application/json': { schema: { type: 'object' } },
304 'text/typescript': { schema: { type: 'string' } },
305 },
306 },
307 '404': errorResponse,
308 },
309 },
310 },
311 '/v1/openapi/{provider}': {
312 get: {
313 operationId: 'getProviderOpenApi',
314 summary: 'Generation-only OpenAPI document for one provider',
315 description:
316 'Assembled from classified endpoints plus the provider connect profile (servers, auth, required headers). ' +
317 'Not a raw upstream-spec mirror. Model-grained providers (today: FAL) require ?model=. ' +
318 'Selections over 40 classified endpoints, or a filter that matches none, return 400 spec_requires_selector. ' +
319 'An unsynced provider returns 404 no_endpoints. ?model= pins the live model enum on provider-grained specs; it does not drop endpoints.',
320 parameters: [
321 providerParam,
322 {
323 name: 'model',
324 in: 'query',
325 description:
326 'Pin to one model (raw id or slug). Required for model-grained providers.',
327 schema: { type: 'string' },
328 },
329 {
330 name: 'activity',
331 in: 'query',
332 description: 'Restrict to one activity group.',
333 schema: { type: 'string', enum: activityEnum },
334 },
335 ],
336 responses: {
337 '200': {
338 description: 'OpenAPI 3.1 document.',
339 content: {
340 'application/openapi+json': { schema: { type: 'object' } },
341 'application/json': { schema: { type: 'object' } },
342 },
343 },
344 '400': errorResponse,
345 '404': errorResponse,
346 '500': errorResponse,
347 },
348 },
349 },
350 '/v1/validate': {
351 post: {
352 operationId: 'validatePayload',
353 summary: 'Validate a payload against a provider endpoint schema',
354 requestBody: {
355 required: true,
356 content: {
357 'application/json': {
358 schema: { $ref: '#/components/schemas/ValidateRequest' },
359 },
360 },
361 },
362 responses: {
363 '200': {
364 description: 'Validation result.',
365 content: {
366 'application/json': {
367 schema: { $ref: '#/components/schemas/ValidateResult' },
368 },
369 },
370 },
371 '400': errorResponse,
372 '404': errorResponse,
373 },
374 },
375 },
376 '/v1/estimate': {
377 post: {
378 operationId: 'estimateCost',
379 summary: 'Evaluate a stored rate card against request and usage',
380 requestBody: {
381 required: true,
382 content: {
383 'application/json': {
384 schema: { $ref: '#/components/schemas/EstimateRequest' },
385 },
386 },
387 },
388 responses: {
389 '200': {
390 description:
391 'The amount for this call and its currency, the card source, and which inputs (if any) were estimated.',
392 content: {
393 'application/json': {
394 schema: { $ref: '#/components/schemas/EstimateResult' },
395 },
396 },
397 },
398 '400': errorResponse,
399 '404': errorResponse,
400 '422': errorResponse,
401 },
402 },
403 },
404 '/v1/changes': {
405 get: {
406 operationId: 'listChanges',
407 summary: 'Changelog feed (cursor-paginated)',
408 description: 'The polling-friendly alternative to webhooks.',
409 parameters: [
410 {
411 name: 'since',
412 in: 'query',
413 description: 'Unix epoch seconds lower bound.',
414 schema: { type: 'integer' },
415 },
416 { name: 'provider', in: 'query', schema: { type: 'string' } },
417 {
418 name: 'type',
419 in: 'query',
420 schema: { type: 'string', enum: changeTypeEnum },
421 },
422 { name: 'cursor', in: 'query', schema: { type: 'string' } },
423 {
424 name: 'wait',
425 in: 'query',
426 description:
427 'Long-poll: hold up to N seconds (cap 60; "30s" form accepted) until new data exists, then return current data.',
428 schema: { type: 'string' },
429 },
430 {
431 name: 'limit',
432 in: 'query',
433 schema: { type: 'integer', minimum: 1, maximum: 200 },
434 },
435 ],
436 responses: {
437 '200': {
438 description: 'Changes page with next cursor.',
439 content: { 'application/json': { schema: { type: 'object' } } },
440 },
441 },
442 },
443 },
444 '/v1/admin/sync/{provider}': {
445 post: {
446 operationId: 'syncProvider',
447 summary: 'Manually trigger a provider spec sync (admin only)',
448 parameters: [providerParam],
449 security: [{ adminKey: [] }],
450 responses: {
451 '200': {
452 description: 'Sync outcome.',
453 content: { 'application/json': { schema: { type: 'object' } } },
454 },
455 '401': errorResponse,
456 '404': errorResponse,
457 '502': errorResponse,
458 },
459 },
460 },
461 '/v1/admin/extract/fal': {
462 post: {
463 operationId: 'extractFalPricing',
464 summary:
465 'Manually trigger the FAL llms.txt rate-card extract (admin only). Spec sync stays on POST /v1/admin/sync/fal.',
466 security: [{ adminKey: [] }],
467 responses: {
468 '200': {
469 description: 'Extract outcome.',
470 content: { 'application/json': { schema: { type: 'object' } } },
471 },
472 '401': errorResponse,
473 '502': errorResponse,
474 },
475 },
476 },
477 },
478 components: {
479 securitySchemes: {
480 adminKey: {
481 type: 'apiKey',
482 in: 'header',
483 name: 'X-Admin-Key',
484 },
485 bearerAuth: {
486 type: 'http',
487 scheme: 'bearer',
488 description: 'Agent JWT (agent-auth) or API key.',
489 },
490 },
491 schemas: {
492 Error: {
493 type: 'object',
494 required: ['error'],
495 properties: {
496 error: {
497 type: 'object',
498 required: ['code', 'message'],
499 properties: {
500 code: { type: 'string' },
501 message: { type: 'string' },
502 },
503 },
504 },
505 },
506 ServiceStatus: {
507 type: 'object',
508 required: ['service', 'time', 'providers'],
509 properties: {
510 service: { type: 'string', const: 'modelschemas' },
511 time: { type: 'integer' },
512 completenessComputedAt: {
513 type: ['integer', 'null'],
514 description:
515 'Epoch seconds the completeness scores were computed, at the last models poll (every 15 minutes). null when none is stored yet, as after a deploy that changes the scorer; every score is then null.',
516 },
517 providers: {
518 type: 'array',
519 items: {
520 type: 'object',
521 properties: {
522 id: { type: 'string' },
523 displayName: { type: 'string' },
524 status: {
525 type: 'string',
526 enum: ['active', 'degraded', 'disabled', 'pending'],
527 },
528 lastPolledAt: { type: ['integer', 'null'] },
529 lastSyncedAt: { type: ['integer', 'null'] },
530 docsFailing: {
531 type: 'object',
532 description:
533 'Present only while the provider docs pages fail to load. Polls go on and models keep their stored docs-derived facts, which may be stale. Does not change status.',
534 required: [
535 'since',
536 'polls',
537 'lastAt',
538 'failed',
539 'skipped',
540 'sources',
541 'error',
542 ],
543 properties: {
544 since: {
545 type: 'integer',
546 description: 'Epoch seconds of the first failing poll.',
547 },
548 polls: {
549 type: 'integer',
550 description: 'Consecutive failing polls.',
551 },
552 lastAt: {
553 type: 'integer',
554 description: 'Epoch seconds of the latest failing poll.',
555 },
556 failed: {
557 type: 'integer',
558 description: 'Documents that failed in the latest poll.',
559 },
560 skipped: {
561 type: 'integer',
562 description:
563 'Documents not attempted after the failure budget.',
564 },
565 sources: {
566 type: 'array',
567 items: { type: 'string' },
568 description: 'The first few failing documents.',
569 },
570 error: {
571 type: 'string',
572 description:
573 'First error of the latest poll, at most 500 characters.',
574 },
575 },
576 },
577 priceClearsRefused: {
578 type: 'object',
579 description:
580 'Present only while polls refuse to clear most of the stored prices of the provider at once. The stored prices stay and may be stale. Does not change status.',
581 required: ['since', 'polls', 'lastAt', 'refused', 'priced'],
582 properties: {
583 since: {
584 type: 'integer',
585 description: 'Epoch seconds of the first refusing poll.',
586 },
587 polls: {
588 type: 'integer',
589 description: 'Consecutive refusing polls.',
590 },
591 lastAt: {
592 type: 'integer',
593 description: 'Epoch seconds of the latest refusing poll.',
594 },
595 refused: {
596 type: 'integer',
597 description:
598 'Stored prices the latest poll asked to clear; none was cleared.',
599 },
600 priced: {
601 type: 'integer',
602 description:
603 'Listed models holding a stored price at that poll.',
604 },
605 },
606 },
607 completeness: {
608 type: 'object',
609 description:
610 'The gap-report score over the live chat models of the provider: the share filled of the eleven chat facts (contextWindow, maxOutput, modalities, priced, cacheRead, capabilities, reasoning, efforts, requestMap, endpoint, replayReasoningContent). Summed per model, each fact counted only where it applies; provider-wide and exact-model source-silent exceptions are excluded. Computed at the models poll (completenessComputedAt), not per request.',
611 required: ['score', 'chat', 'filled', 'needed', 'silent'],
612 properties: {
613 score: {
614 type: ['number', 'null'],
615 description:
616 'filled / needed, 0 to 1. 1 when every fact that applies is in silent. null when the provider has no live chat models (nothing to score, not a score of zero), when no score is stored yet, and when the chat models changed since the stored score.',
617 },
618 chat: {
619 type: 'integer',
620 description: 'Live chat models scored.',
621 },
622 filled: {
623 type: 'integer',
624 description:
625 'Facts carried, summed over those models; silent facts left out.',
626 },
627 needed: {
628 type: 'integer',
629 description:
630 'Facts that apply, summed over those models; silent facts left out.',
631 },
632 silent: {
633 type: 'array',
634 items: { type: 'string' },
635 description:
636 'Facts the provider does not publish, left out of the score.',
637 },
638 },
639 },
640 counts: {
641 type: 'object',
642 description:
643 'Model tallies count live models only: what GET /v1/models lists by default. Deprecated models are in deprecated and nowhere else.',
644 properties: {
645 models: { type: 'integer' },
646 deprecated: {
647 type: 'integer',
648 description:
649 'Models no longer listed upstream (GET /v1/models?deprecated=true).',
650 },
651 priced: {
652 type: 'integer',
653 description:
654 'Models with a stored rate card. priced / models is the price score.',
655 },
656 reasoning: {
657 type: 'integer',
658 description:
659 'Models with stored reasoning metadata. reasoning / chat is the reasoning score.',
660 },
661 chat: {
662 type: 'integer',
663 description: 'Models whose activity is chat.',
664 },
665 endpoints: { type: 'integer' },
666 schemas: { type: 'integer' },
667 },
668 },
669 },
670 },
671 },
672 },
673 },
674 ValidateRequest: {
675 type: 'object',
676 required: ['provider', 'endpointId', 'payload'],
677 properties: {
678 provider: { type: 'string' },
679 endpointId: { type: 'string' },
680 kind: { type: 'string', enum: ['input', 'output'] },
681 payload: {},
682 },
683 },
684 ValidateResult: {
685 type: 'object',
686 required: ['valid', 'errors'],
687 properties: {
688 valid: { type: 'boolean' },
689 errors: {
690 type: 'array',
691 items: {
692 type: 'object',
693 properties: {
694 path: { type: 'string' },
695 message: { type: 'string' },
696 keyword: { type: 'string' },
697 },
698 },
699 },
700 },
701 },
702 CompactPricing: {
703 type: 'object',
704 description:
705 'List-row summary of a stored rate card. per=token cards carry per-million rates at the base tier (tiered marks a long-prompt re-quote above some threshold; fetch the card for it). Other values name the unit the card bills by; the full card is on the detail route or ?pricing=1.',
706 required: ['currency', 'per'],
707 properties: {
708 currency: {
709 type: 'string',
710 pattern: '^[A-Z]{3}$',
711 description:
712 'ISO-4217 code the rates are in. Rows in different currencies do not compare; nothing is converted.',
713 },
714 per: {
715 type: 'string',
716 enum: ['token', 'second', 'character', 'image', 'request', 'unit'],
717 },
718 inputPerMillion: { type: 'number' },
719 outputPerMillion: { type: 'number' },
720 tiered: { type: 'boolean', enum: [true] },
721 },
722 },
723 RateCardSource: {
724 type: 'object',
725 required: ['url', 'hash', 'extractedAt'],
726 properties: {
727 url: { type: 'string', format: 'uri' },
728 hash: { type: 'string', pattern: '^[0-9a-f]{64}$' },
729 extractedAt: { type: 'string', format: 'date-time' },
730 expiresAt: { type: 'string', format: 'date-time' },
731 },
732 },
733 RateCardExample: {
734 type: 'object',
735 required: ['params', 'usd', 'quote'],
736 properties: {
737 params: { type: 'object' },
738 usd: {
739 type: 'number',
740 description: "In the card's currency; the name predates currency.",
741 },
742 quote: { type: 'string' },
743 },
744 },
745 RateCardInput: {
746 type: 'object',
747 required: ['param', 'kind'],
748 properties: {
749 param: { type: 'string' },
750 bound: { type: 'string', enum: ['request', 'usage'] },
751 kind: {
752 type: 'string',
753 enum: ['number', 'enum', 'boolean', 'count', 'dimensions'],
754 },
755 estimate: {
756 type: 'object',
757 description:
758 'Number inputs only: the source-published way to estimate this value when the caller omits it. Its own inputs bind only then, and POST /v1/estimate lists the param under estimated. Estimate inputs never carry an estimate of their own.',
759 required: ['inputs', 'value', 'source'],
760 properties: {
761 inputs: {
762 type: 'object',
763 additionalProperties: {
764 $ref: '#/components/schemas/RateCardInput',
765 },
766 },
767 value: {
768 description: 'JSONLogic expression over the closed op set.',
769 },
770 source: {
771 type: 'object',
772 required: ['url', 'hash'],
773 properties: {
774 url: { type: 'string', format: 'uri' },
775 hash: { type: 'string', pattern: '^[0-9a-f]{64}$' },
776 },
777 },
778 },
779 },
780 },
781 },
782 RateCard: {
783 type: 'object',
784 required: ['inputs', 'tables', 'price', 'examples', 'source'],
785 properties: {
786 inputs: {
787 type: 'object',
788 additionalProperties: {
789 $ref: '#/components/schemas/RateCardInput',
790 },
791 },
792 tables: { type: 'object' },
793 price: {
794 description:
795 'JSONLogic expression over the closed op set, yielding USD. A card in another currency wraps it as { "currency": ["CNY", <expression>] } (ISO 4217); that wrapper is the only place a card states its currency, and an evaluator that does not know it refuses the card.',
796 },
797 examples: {
798 type: 'array',
799 items: { $ref: '#/components/schemas/RateCardExample' },
800 },
801 source: { $ref: '#/components/schemas/RateCardSource' },
802 },
803 },
804 ChatRequestMap: {
805 type: 'object',
806 description:
807 'Verified chat request wire map. A null field is unverified, not a guess. thinking.levels null means the level subset is unverified; a null level value means omit that field.',
808 properties: {
809 thinking: {
810 oneOf: [
811 {
812 type: 'object',
813 required: ['on', 'off', 'levels'],
814 properties: {
815 on: {
816 type: 'object',
817 description: 'Request body for thinking on at effort high.',
818 additionalProperties: true,
819 },
820 off: {
821 description:
822 'Request body that turns thinking off, or null when silence is off.',
823 },
824 levels: {
825 description:
826 'Shared effort levels to the value this model accepts. null omits the field. The object itself is null when the subset is unverified.',
827 oneOf: [
828 {
829 type: 'object',
830 required: [
831 'off',
832 'minimal',
833 'low',
834 'medium',
835 'high',
836 'xhigh',
837 'max',
838 ],
839 properties: {
840 off: { type: ['string', 'null'] },
841 minimal: { type: ['string', 'null'] },
842 low: { type: ['string', 'null'] },
843 medium: { type: ['string', 'null'] },
844 high: { type: ['string', 'null'] },
845 xhigh: { type: ['string', 'null'] },
846 max: { type: ['string', 'null'] },
847 },
848 },
849 { type: 'null' },
850 ],
851 },
852 },
853 },
854 { type: 'null' },
855 ],
856 },
857 maxTokensField: {
858 type: ['string', 'null'],
859 enum: ['max_completion_tokens', 'max_tokens', null],
860 },
861 developerRole: { type: ['boolean', 'null'] },
862 replayReasoningContent: { type: ['boolean', 'null'] },
863 store: { type: ['boolean', 'null'] },
864 strictTools: { type: ['boolean', 'null'] },
865 sessionAffinity: { type: ['boolean', 'null'] },
866 cacheControl: {
867 type: ['string', 'null'],
868 enum: ['anthropic', null],
869 },
870 toolStream: { type: ['boolean', 'null'] },
871 reasoningEffort: { type: ['boolean', 'null'] },
872 },
873 },
874 Model: {
875 type: 'object',
876 properties: {
877 id: { type: 'string' },
878 provider: { type: 'string' },
879 rawId: { type: 'string' },
880 sameAs: {
881 description:
882 "The catalog row this provider's own listing or docs identify as the same upstream model. It does not change this row's facts. null when no upstream is stated, or the stated one matches no row or more than one. When set, factSources.sameAs records the source, with normalized: true when the id matched only after reading dots as hyphens.",
883 oneOf: [
884 {
885 type: 'object',
886 required: ['provider', 'rawId'],
887 properties: {
888 provider: { type: 'string' },
889 rawId: { type: 'string' },
890 },
891 },
892 { type: 'null' },
893 ],
894 },
895 activity: { type: ['string', 'null'], enum: [...activityEnum, null] },
896 displayName: { type: ['string', 'null'] },
897 schemaEndpointId: { type: ['string', 'null'] },
898 contextWindow: { type: ['integer', 'null'] },
899 maxOutput: { type: ['integer', 'null'] },
900 modalities: {},
901 pricing: {
902 description:
903 'Full RateCard on detail and on list rows with ?pricing=1; a CompactPricing summary on list rows otherwise. null only when no card is stored.',
904 oneOf: [
905 { $ref: '#/components/schemas/RateCard' },
906 { $ref: '#/components/schemas/CompactPricing' },
907 { type: 'null' },
908 ],
909 },
910 capabilities: {
911 description:
912 "Capability flags as a map. true: the provider states the model supports the flag. false: the provider states it does not. Key absent: unknown; never read a missing key as false. null: nothing is known. Test capabilities?.tools === true to offer a feature and === false to rule it out. factSources.capabilities holds one source per key, for a true and a false alike; a false whose source has path 'unlisted' comes from the provider publishing the model's whole flag list without that flag.",
913 type: ['object', 'null'],
914 additionalProperties: { type: 'boolean' },
915 },
916 providerMetadata: {
917 description:
918 "The provider's own listing object for the model, as published: not normalised, and different for every provider (fal category, BytePlus Ark features and task type, ElevenLabs languages, Replicate visibility). null when the provider lists none. Nothing in it is a capability flag; read capabilities for those.",
919 type: ['object', 'null'],
920 additionalProperties: true,
921 },
922 reasoning: {
923 description:
924 "How thinking is configured, or null when the model does not reason or its source names no request field for it. mode names the one control the request exposes: adaptive (the model decides; Anthropic thinking.type adaptive, or a switch with an auto value), budget (a token budget: thinking.budget_tokens, Gemini thinkingBudget), effort (a level: reasoning_effort, Gemini thinkingLevel) or toggle (an on/off switch and nothing else: thinking.type enabled|disabled, enable_thinking; it says nothing about the default when the field is omitted). mandatory has one meaning on every mode. true: the provider states thinking cannot be turned off for this model (on a toggle: the off value is rejected, so send on or omit the field). false: the provider states it can be, in prose or by an off value in this model's own schema or level list. null: unstated. null must not be read as false: test mandatory === false before offering an off option. A toggle is never stored with mandatory null. efforts: the accepted effort values as published, an off value such as none included; never present on toggle. Rows from some providers still carry a true inferred from a level list with no off value; the README release notes list them.",
925 oneOf: [
926 {
927 type: 'object',
928 required: ['mode', 'mandatory'],
929 properties: {
930 mode: {
931 type: 'string',
932 enum: ['adaptive', 'budget', 'effort', 'toggle'],
933 },
934 mandatory: { type: ['boolean', 'null'] },
935 efforts: { type: 'array', items: { type: 'string' } },
936 },
937 },
938 { type: 'null' },
939 ],
940 },
941 serverTools: {
942 description:
943 "Provider-hosted tool type ids the model accepts in the request's tools array (web_search_20250305, google_search, x_search, …), or null when unknown. factSources.serverTools holds one source per id.",
944 type: ['array', 'null'],
945 items: { type: 'string' },
946 },
947 requestMap: {
948 description:
949 "How to build this chat model's request: thinking on/off and shared effort levels (null omits the field), max-token field name, developer vs system role, reasoning_content replay, and related flags. Null until verified. reasoning stays the readable fact (mode, mandatory, efforts).",
950 oneOf: [
951 { $ref: '#/components/schemas/ChatRequestMap' },
952 { type: 'null' },
953 ],
954 },
955 aliases: {
956 description:
957 'Caller ids that resolve to this row (for example claude-opus-4-5 → the dated snapshot). null when the provider documents none. GET /v1/models/{provider}/{id} accepts an alias and returns this row, whose rawId is the dated id.',
958 type: ['array', 'null'],
959 items: { type: 'string' },
960 },
961 factSources: {
962 description:
963 'Per-field provenance. Detail always includes this; lists include it with provenance=1. A ledgered null chat fact carries derivation source-silent, with sourceUrl and checkedAt only when recorded. capabilities and serverTools normally contain per-item source maps; whole-field silence is a source-silent object. Missing cacheRead and efforts subfacts have separate provenance keys; endpoint silence is schemaEndpointId. Populated facts keep their existing provenance. Nulls without ledger evidence gain no entry.',
964 },
965 releasedAt: {
966 description:
967 "The provider's own stated release or creation date, epoch seconds. null when the provider reports none. Unlike firstSeenAt it is never our observation.",
968 type: ['integer', 'null'],
969 },
970 knowledgeCutoff: {
971 description:
972 'Knowledge (training data) cutoff as the provider states it: YYYY-MM, or YYYY-MM-DD when the provider gives a day. Never padded to a day. null when unknown. factSources.knowledgeCutoff is its source.',
973 type: ['string', 'null'],
974 pattern: '^\\d{4}-\\d{2}(-\\d{2})?$',
975 },
976 openWeights: {
977 description:
978 'true when the provider itself states the weights can be openly downloaded, false when it states they cannot, null when it states neither. Never inferred from a model name. factSources.openWeights is its source.',
979 type: ['boolean', 'null'],
980 },
981 weightsUrl: {
982 description:
983 'Where the provider says the weights are. Set only when openWeights is true.',
984 type: ['string', 'null'],
985 },
986 firstSeenAt: {
987 description:
988 'The release date the provider reports when it reports one (the same date as releasedAt), otherwise when this service first observed the model. Read releasedAt to tell the two apart.',
989 type: 'integer',
990 },
991 lastSeenAt: { type: 'integer' },
992 deprecatedAt: { type: ['integer', 'null'] },
993 },
994 },
995 ModelList: {
996 type: 'object',
997 properties: {
998 count: { type: 'integer' },
999 models: {
1000 type: 'array',
1001 items: { $ref: '#/components/schemas/Model' },
1002 },
1003 },
1004 },
1005 EstimateRequest: {
1006 type: 'object',
1007 required: ['provider', 'model'],
1008 properties: {
1009 provider: { type: 'string' },
1010 model: { type: 'string' },
1011 request: { type: 'object' },
1012 usage: { type: 'object' },
1013 },
1014 },
1015 EstimateResult: {
1016 type: 'object',
1017 required: ['amount', 'currency', 'cardSource', 'estimated'],
1018 properties: {
1019 amount: {
1020 type: 'number',
1021 description: 'The price, in currency. Never converted.',
1022 },
1023 currency: {
1024 type: 'string',
1025 pattern: '^[A-Z]{3}$',
1026 description: "ISO-4217 code of the card's currency.",
1027 },
1028 usd: {
1029 type: 'number',
1030 deprecated: true,
1031 description:
1032 'Deprecated: read amount and currency. Repeats amount when currency is USD; absent for any other currency.',
1033 },
1034 cardSource: { $ref: '#/components/schemas/RateCardSource' },
1035 estimated: {
1036 type: 'array',
1037 items: { type: 'string' },
1038 description:
1039 'Params the caller omitted that the card estimated by its published method. Empty: amount is the price as billed for the supplied request and usage.',
1040 },
1041 },
1042 },
1043 },
1044 },
1045} as const