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

openapi.ts

1,055 lines41.0 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: [
120 providerParam,
121 {
122 name: 'provenance',
123 in: 'query',
124 description:
125 'Include recorded per-field sources by default; 0 omits them.',
126 schema: { type: 'string', enum: ['0', '1'], default: '1' },
127 },
128 ],
129 responses: {
130 '400': errorResponse,
131 '200': {
132 description: 'Models for the provider.',
133 content: { 'application/json': { schema: { type: 'object' } } },
134 },
135 '404': errorResponse,
136 },
137 },
138 },
139 '/v1/models': {
140 get: {
141 operationId: 'listModels',
142 summary: 'Cross-provider model catalog',
143 description:
144 'The headline "what can I use right now" endpoint. Filterable.',
145 parameters: [
146 {
147 name: 'activity',
148 in: 'query',
149 schema: { type: 'string', enum: activityEnum },
150 },
151 { name: 'provider', in: 'query', schema: { type: 'string' } },
152 {
153 name: 'capability',
154 in: 'query',
155 description:
156 '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.',
157 schema: { type: 'string' },
158 },
159 {
160 name: 'q',
161 in: 'query',
162 description: 'Free-text match against id and display name.',
163 schema: { type: 'string' },
164 },
165 {
166 name: 'provenance',
167 in: 'query',
168 description:
169 'Per-field factSources are included by default. Set to 0 to omit them on list rows; 1 explicitly includes them. Model detail always includes factSources and OpenRouter discrepancies.',
170 schema: { type: 'string', enum: ['0', '1'], default: '1' },
171 },
172 {
173 name: 'pricing',
174 in: 'query',
175 description:
176 '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.',
177 schema: { type: 'string', enum: ['1'] },
178 },
179 ],
180 responses: {
181 '200': {
182 description:
183 'Matching models. pricing is a compact token projection, a full RateCard when ?pricing=1, or null. OpenRouter-shaped vendor blobs are not served.',
184 content: {
185 'application/json': {
186 schema: { $ref: '#/components/schemas/ModelList' },
187 },
188 },
189 },
190 },
191 },
192 },
193 '/v1/models/{provider}/{modelId}': {
194 get: {
195 operationId: 'getModel',
196 summary: 'Full metadata for one model',
197 parameters: [
198 providerParam,
199 {
200 name: 'modelId',
201 in: 'path',
202 required: true,
203 description: 'Model slug or raw provider id.',
204 schema: { type: 'string' },
205 },
206 ],
207 responses: {
208 '200': {
209 description:
210 '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.',
211 content: {
212 'application/json': {
213 schema: { $ref: '#/components/schemas/Model' },
214 },
215 },
216 },
217 '404': errorResponse,
218 },
219 },
220 },
221 '/v1/schemas': {
222 get: {
223 operationId: 'listAllSchemas',
224 summary: 'System-wide schema index',
225 description:
226 'Every provider with extracted schemas, each with its activities and endpoint ids — the discovery entry point for all schemas on the system.',
227 responses: {
228 '200': {
229 description: 'Provider → activity → endpoint-id index.',
230 content: { 'application/json': { schema: { type: 'object' } } },
231 },
232 },
233 },
234 },
235 '/v1/schemas/{provider}': {
236 get: {
237 operationId: 'listProviderSchemas',
238 summary: 'Activities and endpoint ids for a provider',
239 parameters: [providerParam],
240 responses: {
241 '200': {
242 description: 'Activity → endpoint-id index.',
243 content: { 'application/json': { schema: { type: 'object' } } },
244 },
245 '404': errorResponse,
246 },
247 },
248 },
249 '/v1/schemas/{provider}/{activity}': {
250 get: {
251 operationId: 'getActivitySchemas',
252 summary: 'Endpoint-id-keyed schema map for one activity',
253 parameters: [providerParam, activityParam],
254 responses: {
255 '200': {
256 description:
257 'Map of endpoint id → { input, output } self-contained JSON Schemas (current versions).',
258 content: { 'application/json': { schema: { type: 'object' } } },
259 },
260 '404': errorResponse,
261 },
262 },
263 },
264 '/v1/schemas/{provider}/{activity}/{endpointId}': {
265 get: {
266 operationId: 'getSchema',
267 summary: 'One self-contained JSON Schema',
268 parameters: [
269 providerParam,
270 activityParam,
271 {
272 name: 'endpointId',
273 in: 'path',
274 required: true,
275 description:
276 "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.",
277 schema: { type: 'string' },
278 },
279 {
280 name: 'kind',
281 in: 'query',
282 description: 'Defaults to input.',
283 schema: { type: 'string', enum: ['input', 'output'] },
284 },
285 {
286 name: 'version',
287 in: 'query',
288 description: 'Content hash of a historical version.',
289 schema: { type: 'string' },
290 },
291 {
292 name: 'format',
293 in: 'query',
294 description:
295 '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.',
296 schema: { type: 'string', enum: ['json', 'types'] },
297 },
298 {
299 name: 'optional',
300 in: 'query',
301 description:
302 'format=types only: optional-property style. exact (default) emits `foo?: T`; undefined emits `foo?: T | undefined`.',
303 schema: { type: 'string', enum: ['exact', 'undefined'] },
304 },
305 ],
306 responses: {
307 '200': {
308 description:
309 'Self-contained JSON Schema ($defs-bundled) — or, with format=types, a TypeScript module — served with ETag. ' +
310 'JSON responses carry `provenance` (upstream sourceUrl, sourceHash, fetchedAt, extractorVersion) so derivations are independently verifiable. ' +
311 '`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.',
312 content: {
313 'application/json': { schema: { type: 'object' } },
314 'text/typescript': { schema: { type: 'string' } },
315 },
316 },
317 '404': errorResponse,
318 },
319 },
320 },
321 '/v1/openapi/{provider}': {
322 get: {
323 operationId: 'getProviderOpenApi',
324 summary: 'Generation-only OpenAPI document for one provider',
325 description:
326 'Assembled from classified endpoints plus the provider connect profile (servers, auth, required headers). ' +
327 'Not a raw upstream-spec mirror. Model-grained providers (today: FAL) require ?model=. ' +
328 'Selections over 40 classified endpoints, or a filter that matches none, return 400 spec_requires_selector. ' +
329 'An unsynced provider returns 404 no_endpoints. ?model= pins the live model enum on provider-grained specs; it does not drop endpoints.',
330 parameters: [
331 providerParam,
332 {
333 name: 'model',
334 in: 'query',
335 description:
336 'Pin to one model (raw id or slug). Required for model-grained providers.',
337 schema: { type: 'string' },
338 },
339 {
340 name: 'activity',
341 in: 'query',
342 description: 'Restrict to one activity group.',
343 schema: { type: 'string', enum: activityEnum },
344 },
345 ],
346 responses: {
347 '200': {
348 description: 'OpenAPI 3.1 document.',
349 content: {
350 'application/openapi+json': { schema: { type: 'object' } },
351 'application/json': { schema: { type: 'object' } },
352 },
353 },
354 '400': errorResponse,
355 '404': errorResponse,
356 '500': errorResponse,
357 },
358 },
359 },
360 '/v1/validate': {
361 post: {
362 operationId: 'validatePayload',
363 summary: 'Validate a payload against a provider endpoint schema',
364 requestBody: {
365 required: true,
366 content: {
367 'application/json': {
368 schema: { $ref: '#/components/schemas/ValidateRequest' },
369 },
370 },
371 },
372 responses: {
373 '200': {
374 description: 'Validation result.',
375 content: {
376 'application/json': {
377 schema: { $ref: '#/components/schemas/ValidateResult' },
378 },
379 },
380 },
381 '400': errorResponse,
382 '404': errorResponse,
383 },
384 },
385 },
386 '/v1/estimate': {
387 post: {
388 operationId: 'estimateCost',
389 summary: 'Evaluate a stored rate card against request and usage',
390 requestBody: {
391 required: true,
392 content: {
393 'application/json': {
394 schema: { $ref: '#/components/schemas/EstimateRequest' },
395 },
396 },
397 },
398 responses: {
399 '200': {
400 description:
401 'The amount for this call and its currency, the card source, and which inputs (if any) were estimated.',
402 content: {
403 'application/json': {
404 schema: { $ref: '#/components/schemas/EstimateResult' },
405 },
406 },
407 },
408 '400': errorResponse,
409 '404': errorResponse,
410 '422': errorResponse,
411 },
412 },
413 },
414 '/v1/changes': {
415 get: {
416 operationId: 'listChanges',
417 summary: 'Changelog feed (cursor-paginated)',
418 description: 'The polling-friendly alternative to webhooks.',
419 parameters: [
420 {
421 name: 'since',
422 in: 'query',
423 description: 'Unix epoch seconds lower bound.',
424 schema: { type: 'integer' },
425 },
426 { name: 'provider', in: 'query', schema: { type: 'string' } },
427 {
428 name: 'type',
429 in: 'query',
430 schema: { type: 'string', enum: changeTypeEnum },
431 },
432 { name: 'cursor', in: 'query', schema: { type: 'string' } },
433 {
434 name: 'wait',
435 in: 'query',
436 description:
437 'Long-poll: hold up to N seconds (cap 60; "30s" form accepted) until new data exists, then return current data.',
438 schema: { type: 'string' },
439 },
440 {
441 name: 'limit',
442 in: 'query',
443 schema: { type: 'integer', minimum: 1, maximum: 200 },
444 },
445 ],
446 responses: {
447 '200': {
448 description: 'Changes page with next cursor.',
449 content: { 'application/json': { schema: { type: 'object' } } },
450 },
451 },
452 },
453 },
454 '/v1/admin/sync/{provider}': {
455 post: {
456 operationId: 'syncProvider',
457 summary: 'Manually trigger a provider spec sync (admin only)',
458 parameters: [providerParam],
459 security: [{ adminKey: [] }],
460 responses: {
461 '200': {
462 description: 'Sync outcome.',
463 content: { 'application/json': { schema: { type: 'object' } } },
464 },
465 '401': errorResponse,
466 '404': errorResponse,
467 '502': errorResponse,
468 },
469 },
470 },
471 '/v1/admin/extract/fal': {
472 post: {
473 operationId: 'extractFalPricing',
474 summary:
475 'Manually trigger the FAL llms.txt rate-card extract (admin only). Spec sync stays on POST /v1/admin/sync/fal.',
476 security: [{ adminKey: [] }],
477 responses: {
478 '200': {
479 description: 'Extract outcome.',
480 content: { 'application/json': { schema: { type: 'object' } } },
481 },
482 '401': errorResponse,
483 '502': errorResponse,
484 },
485 },
486 },
487 },
488 components: {
489 securitySchemes: {
490 adminKey: {
491 type: 'apiKey',
492 in: 'header',
493 name: 'X-Admin-Key',
494 },
495 bearerAuth: {
496 type: 'http',
497 scheme: 'bearer',
498 description: 'Agent JWT (agent-auth) or API key.',
499 },
500 },
501 schemas: {
502 Error: {
503 type: 'object',
504 required: ['error'],
505 properties: {
506 error: {
507 type: 'object',
508 required: ['code', 'message'],
509 properties: {
510 code: { type: 'string' },
511 message: { type: 'string' },
512 },
513 },
514 },
515 },
516 ServiceStatus: {
517 type: 'object',
518 required: ['service', 'time', 'providers'],
519 properties: {
520 service: { type: 'string', const: 'modelschemas' },
521 time: { type: 'integer' },
522 completenessComputedAt: {
523 type: ['integer', 'null'],
524 description:
525 '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.',
526 },
527 providers: {
528 type: 'array',
529 items: {
530 type: 'object',
531 properties: {
532 id: { type: 'string' },
533 displayName: { type: 'string' },
534 status: {
535 type: 'string',
536 enum: ['active', 'degraded', 'disabled', 'pending'],
537 },
538 lastPolledAt: { type: ['integer', 'null'] },
539 lastSyncedAt: { type: ['integer', 'null'] },
540 docsFailing: {
541 type: 'object',
542 description:
543 '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.',
544 required: [
545 'since',
546 'polls',
547 'lastAt',
548 'failed',
549 'skipped',
550 'sources',
551 'error',
552 ],
553 properties: {
554 since: {
555 type: 'integer',
556 description: 'Epoch seconds of the first failing poll.',
557 },
558 polls: {
559 type: 'integer',
560 description: 'Consecutive failing polls.',
561 },
562 lastAt: {
563 type: 'integer',
564 description: 'Epoch seconds of the latest failing poll.',
565 },
566 failed: {
567 type: 'integer',
568 description: 'Documents that failed in the latest poll.',
569 },
570 skipped: {
571 type: 'integer',
572 description:
573 'Documents not attempted after the failure budget.',
574 },
575 sources: {
576 type: 'array',
577 items: { type: 'string' },
578 description: 'The first few failing documents.',
579 },
580 error: {
581 type: 'string',
582 description:
583 'First error of the latest poll, at most 500 characters.',
584 },
585 },
586 },
587 priceClearsRefused: {
588 type: 'object',
589 description:
590 '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.',
591 required: ['since', 'polls', 'lastAt', 'refused', 'priced'],
592 properties: {
593 since: {
594 type: 'integer',
595 description: 'Epoch seconds of the first refusing poll.',
596 },
597 polls: {
598 type: 'integer',
599 description: 'Consecutive refusing polls.',
600 },
601 lastAt: {
602 type: 'integer',
603 description: 'Epoch seconds of the latest refusing poll.',
604 },
605 refused: {
606 type: 'integer',
607 description:
608 'Stored prices the latest poll asked to clear; none was cleared.',
609 },
610 priced: {
611 type: 'integer',
612 description:
613 'Listed models holding a stored price at that poll.',
614 },
615 },
616 },
617 completeness: {
618 type: 'object',
619 description:
620 '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.',
621 required: ['score', 'chat', 'filled', 'needed', 'silent'],
622 properties: {
623 score: {
624 type: ['number', 'null'],
625 description:
626 '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.',
627 },
628 chat: {
629 type: 'integer',
630 description: 'Live chat models scored.',
631 },
632 filled: {
633 type: 'integer',
634 description:
635 'Facts carried, summed over those models; silent facts left out.',
636 },
637 needed: {
638 type: 'integer',
639 description:
640 'Facts that apply, summed over those models; silent facts left out.',
641 },
642 silent: {
643 type: 'array',
644 items: { type: 'string' },
645 description:
646 'Facts the provider does not publish, left out of the score.',
647 },
648 },
649 },
650 counts: {
651 type: 'object',
652 description:
653 'Model tallies count live models only: what GET /v1/models lists by default. Deprecated models are in deprecated and nowhere else.',
654 properties: {
655 models: { type: 'integer' },
656 deprecated: {
657 type: 'integer',
658 description:
659 'Models no longer listed upstream (GET /v1/models?deprecated=true).',
660 },
661 priced: {
662 type: 'integer',
663 description:
664 'Models with a stored rate card. priced / models is the price score.',
665 },
666 reasoning: {
667 type: 'integer',
668 description:
669 'Models with stored reasoning metadata. reasoning / chat is the reasoning score.',
670 },
671 chat: {
672 type: 'integer',
673 description: 'Models whose activity is chat.',
674 },
675 endpoints: { type: 'integer' },
676 schemas: { type: 'integer' },
677 },
678 },
679 },
680 },
681 },
682 },
683 },
684 ValidateRequest: {
685 type: 'object',
686 required: ['provider', 'endpointId', 'payload'],
687 properties: {
688 provider: { type: 'string' },
689 endpointId: { type: 'string' },
690 kind: { type: 'string', enum: ['input', 'output'] },
691 payload: {},
692 },
693 },
694 ValidateResult: {
695 type: 'object',
696 required: ['valid', 'errors'],
697 properties: {
698 valid: { type: 'boolean' },
699 errors: {
700 type: 'array',
701 items: {
702 type: 'object',
703 properties: {
704 path: { type: 'string' },
705 message: { type: 'string' },
706 keyword: { type: 'string' },
707 },
708 },
709 },
710 },
711 },
712 CompactPricing: {
713 type: 'object',
714 description:
715 '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.',
716 required: ['currency', 'per'],
717 properties: {
718 currency: {
719 type: 'string',
720 pattern: '^[A-Z]{3}$',
721 description:
722 'ISO-4217 code the rates are in. Rows in different currencies do not compare; nothing is converted.',
723 },
724 per: {
725 type: 'string',
726 enum: ['token', 'second', 'character', 'image', 'request', 'unit'],
727 },
728 inputPerMillion: { type: 'number' },
729 outputPerMillion: { type: 'number' },
730 tiered: { type: 'boolean', enum: [true] },
731 },
732 },
733 RateCardSource: {
734 type: 'object',
735 required: ['url', 'hash', 'extractedAt'],
736 properties: {
737 url: { type: 'string', format: 'uri' },
738 hash: { type: 'string', pattern: '^[0-9a-f]{64}$' },
739 extractedAt: { type: 'string', format: 'date-time' },
740 expiresAt: { type: 'string', format: 'date-time' },
741 },
742 },
743 RateCardExample: {
744 type: 'object',
745 required: ['params', 'usd', 'quote'],
746 properties: {
747 params: { type: 'object' },
748 usd: {
749 type: 'number',
750 description: "In the card's currency; the name predates currency.",
751 },
752 quote: { type: 'string' },
753 },
754 },
755 RateCardInput: {
756 type: 'object',
757 required: ['param', 'kind'],
758 properties: {
759 param: { type: 'string' },
760 bound: { type: 'string', enum: ['request', 'usage'] },
761 kind: {
762 type: 'string',
763 enum: ['number', 'enum', 'boolean', 'count', 'dimensions'],
764 },
765 estimate: {
766 type: 'object',
767 description:
768 '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.',
769 required: ['inputs', 'value', 'source'],
770 properties: {
771 inputs: {
772 type: 'object',
773 additionalProperties: {
774 $ref: '#/components/schemas/RateCardInput',
775 },
776 },
777 value: {
778 description: 'JSONLogic expression over the closed op set.',
779 },
780 source: {
781 type: 'object',
782 required: ['url', 'hash'],
783 properties: {
784 url: { type: 'string', format: 'uri' },
785 hash: { type: 'string', pattern: '^[0-9a-f]{64}$' },
786 },
787 },
788 },
789 },
790 },
791 },
792 RateCard: {
793 type: 'object',
794 required: ['inputs', 'tables', 'price', 'examples', 'source'],
795 properties: {
796 inputs: {
797 type: 'object',
798 additionalProperties: {
799 $ref: '#/components/schemas/RateCardInput',
800 },
801 },
802 tables: { type: 'object' },
803 price: {
804 description:
805 '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.',
806 },
807 examples: {
808 type: 'array',
809 items: { $ref: '#/components/schemas/RateCardExample' },
810 },
811 source: { $ref: '#/components/schemas/RateCardSource' },
812 },
813 },
814 ChatRequestMap: {
815 type: 'object',
816 description:
817 '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.',
818 properties: {
819 thinking: {
820 oneOf: [
821 {
822 type: 'object',
823 required: ['on', 'off', 'levels'],
824 properties: {
825 on: {
826 type: 'object',
827 description: 'Request body for thinking on at effort high.',
828 additionalProperties: true,
829 },
830 off: {
831 description:
832 'Request body that turns thinking off, or null when silence is off.',
833 },
834 levels: {
835 description:
836 'Shared effort levels to the value this model accepts. null omits the field. The object itself is null when the subset is unverified.',
837 oneOf: [
838 {
839 type: 'object',
840 required: [
841 'off',
842 'minimal',
843 'low',
844 'medium',
845 'high',
846 'xhigh',
847 'max',
848 ],
849 properties: {
850 off: { type: ['string', 'null'] },
851 minimal: { type: ['string', 'null'] },
852 low: { type: ['string', 'null'] },
853 medium: { type: ['string', 'null'] },
854 high: { type: ['string', 'null'] },
855 xhigh: { type: ['string', 'null'] },
856 max: { type: ['string', 'null'] },
857 },
858 },
859 { type: 'null' },
860 ],
861 },
862 },
863 },
864 { type: 'null' },
865 ],
866 },
867 maxTokensField: {
868 type: ['string', 'null'],
869 enum: ['max_completion_tokens', 'max_tokens', null],
870 },
871 developerRole: { type: ['boolean', 'null'] },
872 replayReasoningContent: { type: ['boolean', 'null'] },
873 store: { type: ['boolean', 'null'] },
874 strictTools: { type: ['boolean', 'null'] },
875 sessionAffinity: { type: ['boolean', 'null'] },
876 cacheControl: {
877 type: ['string', 'null'],
878 enum: ['anthropic', null],
879 },
880 toolStream: { type: ['boolean', 'null'] },
881 reasoningEffort: { type: ['boolean', 'null'] },
882 },
883 },
884 Model: {
885 type: 'object',
886 properties: {
887 id: { type: 'string' },
888 provider: { type: 'string' },
889 rawId: { type: 'string' },
890 sameAs: {
891 description:
892 "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.",
893 oneOf: [
894 {
895 type: 'object',
896 required: ['provider', 'rawId'],
897 properties: {
898 provider: { type: 'string' },
899 rawId: { type: 'string' },
900 },
901 },
902 { type: 'null' },
903 ],
904 },
905 activity: { type: ['string', 'null'], enum: [...activityEnum, null] },
906 displayName: { type: ['string', 'null'] },
907 schemaEndpointId: { type: ['string', 'null'] },
908 contextWindow: { type: ['integer', 'null'] },
909 maxOutput: { type: ['integer', 'null'] },
910 modalities: {},
911 pricing: {
912 description:
913 '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.',
914 oneOf: [
915 { $ref: '#/components/schemas/RateCard' },
916 { $ref: '#/components/schemas/CompactPricing' },
917 { type: 'null' },
918 ],
919 },
920 capabilities: {
921 description:
922 "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.",
923 type: ['object', 'null'],
924 additionalProperties: { type: 'boolean' },
925 },
926 providerMetadata: {
927 description:
928 "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.",
929 type: ['object', 'null'],
930 additionalProperties: true,
931 },
932 reasoning: {
933 description:
934 "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.",
935 oneOf: [
936 {
937 type: 'object',
938 required: ['mode', 'mandatory'],
939 properties: {
940 mode: {
941 type: 'string',
942 enum: ['adaptive', 'budget', 'effort', 'toggle'],
943 },
944 mandatory: { type: ['boolean', 'null'] },
945 efforts: { type: 'array', items: { type: 'string' } },
946 },
947 },
948 { type: 'null' },
949 ],
950 },
951 serverTools: {
952 description:
953 "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.",
954 type: ['array', 'null'],
955 items: { type: 'string' },
956 },
957 requestMap: {
958 description:
959 "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).",
960 oneOf: [
961 { $ref: '#/components/schemas/ChatRequestMap' },
962 { type: 'null' },
963 ],
964 },
965 aliases: {
966 description:
967 '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.',
968 type: ['array', 'null'],
969 items: { type: 'string' },
970 },
971 factSources: {
972 description:
973 'Per-field provenance, included by default on detail and list responses (provenance=0 explicitly omits it on lists). 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.',
974 },
975 releasedAt: {
976 description:
977 "The provider's own stated release or creation date, epoch seconds. null when the provider reports none. Unlike firstSeenAt it is never our observation.",
978 type: ['integer', 'null'],
979 },
980 knowledgeCutoff: {
981 description:
982 '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.',
983 type: ['string', 'null'],
984 pattern: '^\\d{4}-\\d{2}(-\\d{2})?$',
985 },
986 openWeights: {
987 description:
988 '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.',
989 type: ['boolean', 'null'],
990 },
991 weightsUrl: {
992 description:
993 'Where the provider says the weights are. Set only when openWeights is true.',
994 type: ['string', 'null'],
995 },
996 firstSeenAt: {
997 description:
998 '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.',
999 type: 'integer',
1000 },
1001 lastSeenAt: { type: 'integer' },
1002 deprecatedAt: { type: ['integer', 'null'] },
1003 },
1004 },
1005 ModelList: {
1006 type: 'object',
1007 properties: {
1008 count: { type: 'integer' },
1009 models: {
1010 type: 'array',
1011 items: { $ref: '#/components/schemas/Model' },
1012 },
1013 },
1014 },
1015 EstimateRequest: {
1016 type: 'object',
1017 required: ['provider', 'model'],
1018 properties: {
1019 provider: { type: 'string' },
1020 model: { type: 'string' },
1021 request: { type: 'object' },
1022 usage: { type: 'object' },
1023 },
1024 },
1025 EstimateResult: {
1026 type: 'object',
1027 required: ['amount', 'currency', 'cardSource', 'estimated'],
1028 properties: {
1029 amount: {
1030 type: 'number',
1031 description: 'The price, in currency. Never converted.',
1032 },
1033 currency: {
1034 type: 'string',
1035 pattern: '^[A-Z]{3}$',
1036 description: "ISO-4217 code of the card's currency.",
1037 },
1038 usd: {
1039 type: 'number',
1040 deprecated: true,
1041 description:
1042 'Deprecated: read amount and currency. Repeats amount when currency is USD; absent for any other currency.',
1043 },
1044 cardSource: { $ref: '#/components/schemas/RateCardSource' },
1045 estimated: {
1046 type: 'array',
1047 items: { type: 'string' },
1048 description:
1049 '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.',
1050 },
1051 },
1052 },
1053 },
1054 },
1055} as const