Open History to see the last commit
1/**
2 * The /llms.txt agent guide (PLAN.md task 4.1). Shared module so the /docs
3 * page (7.3) and the distributable skill (7.6) render from the same source.
4 */
5export const llmsTxt = `# modelschemas
6
7Live AI model schema service. Per-endpoint request/response JSON Schemas and
8model metadata for 30+ monitored providers (OpenAI, Anthropic, Gemini, xAI
9Grok, Mistral, Groq, DeepSeek, and more — GET /v1/providers for the full
10roster), refreshed automatically: model lists every 15 minutes, full OpenAPI
11spec syncs daily. Responses are JSON unless noted (\`text/typescript\`,
12\`application/openapi+json\`).
13
14## Why use this
15
16- Discover which models exist *right now*, across providers, by activity
17 (chat, image, video, audio, embeddings, moderation). Grain=provider
18 catalogs (Grok, OpenAI, …) set \`activity\` on each row and
19 \`schemaEndpointId\` pointing at the shared generation route
20 (\`v1/images/generations\`, \`images/generations\`, …). \`pricing\` is a
21 RateCard (or null when no price is stored). List rows carry a summary:
22 \`{currency, per: 'token', inputPerMillion, outputPerMillion, tiered?}\`
23 at the base rate, or \`{currency, per: 'second' | 'character' | 'image' | …}\`
24 for a card billed by unit. \`currency\` is ISO 4217 (mostly USD; nothing
25 is converted, so compare only like with like); \`?pricing=1\` returns
26 the full card. \`/v1/status\` counts live \`priced\` models per provider
27 and scores \`completeness\` (the share of chat facts filled; \`score\` is
28 null with no chat models). A provider there carries \`docsFailing\` or
29 \`priceClearsRefused\` while its stored docs facts or prices may be stale.
30- Fetch a self-contained JSON Schema (refs bundled under $defs) for any
31 provider generation endpoint — request (input) and response (output).
32 A listed model rawId also works as \`{endpointId}\`: it aliases onto that
33 route and pins the request \`model\` field to the one id.
34- Validate a payload server-side before spending tokens on a provider call.
35- Estimate the cost of a call from the stored rate card, in the card's
36 currency (\`POST /v1/estimate\`).
37- Poll /v1/changes (or subscribe via webhooks) to hear about new models and
38 API revisions.
39
40## Quickstart (no auth needed for reads)
41
421. GET /v1 — endpoint index.
432. GET /v1/models?activity=chat — cross-provider catalog of chat models.
443. GET /v1/schemas — system-wide index: every provider's activities and
45 endpoint ids in one response (all schemas on the system).
464. GET /v1/schemas/anthropic — activities + endpoint ids for one provider.
475. GET /v1/schemas/anthropic/chat/{endpointId}?kind=input — the JSON Schema
48 for a request body (endpoint ids contain slashes; URL-encode them).
49 Grain=provider models also accept the raw id:
50 \`/v1/schemas/grok/image/grok-imagine-image-2.0?kind=input\`.
516. GET /v1/openapi/{provider} — generation-only OpenAPI (servers, auth,
52 paths). FAL requires ?model=. Over 40 endpoints, or a filter that
53 matches none: 400 spec_requires_selector. HTTP only (no MCP tool).
547. POST /v1/validate {"provider","endpointId","payload"} — check a payload.
558. POST /v1/estimate {"provider","model","request"?,"usage"?} — {amount,
56 currency} for a call from the stored rate card. Missing levers → 422;
57 no card → 404 unknown_pricing.
589. GET /v1/changes?since=<unix epoch> — what changed.
59
60## TypeScript types
61
62Add \`?format=types\` to a schema read
63(GET /v1/schemas/{provider}/{activity}/{endpointId}) to get a self-contained
64TypeScript module instead of JSON: the schema as a pure const plus generated
65interfaces (\`text/typescript\`, zero imports, tree-shakeable, same ETag
66discipline). \`?optional=undefined\` widens optional properties to
67\`T | undefined\` for exactOptionalPropertyTypes consumers; default is
68\`foo?: T\`. A request \`model\` field is the live catalog union plus
69\`ListedModelId<'provider'>\` (still branded when the catalog is empty).
70Minted by \`listModels\` / \`listProviderModels\` / \`getModel\` (or
71\`asListedModelId\`). Arbitrary \`string\` values do not assign.
72
73## Hypermedia (HAL, extended)
74
75Every JSON read response carries \`_links\`: HAL link objects extended with
76\`method\`, \`contentType\`, and an inline \`example\` (a resolvable URL for
77GETs, a request body for POSTs) so you can follow the API without consulting
78docs. Templated hrefs (RFC 6570) set \`"templated": true\` and always include
79an example. Start at GET /v1 and follow \`_links\`.
80
81## Long-polling
82
83No sleep tool? Add \`?wait=30\` (seconds, cap 60, \`30s\` form accepted) to
84GET /v1/changes or GET /v1/status: the request holds until new data lands or
85the window expires, then returns whatever is current. One request, one
86rate-limit token.
87
88## Caching
89
90Read responses carry ETag (content hash), Last-Modified, Cache-Control with
91stale-while-revalidate, X-Fetched-At and X-Stale-At (unix epoch seconds).
92Send If-None-Match to get 304s.
93
94## Auth (optional — unlocks higher rate limits + webhooks)
95
96- Agent-auth protocol: discovery at /.well-known/agent-configuration,
97 register at POST /api/auth/agent/register, then execute capabilities with
98 short-lived JWTs.
99- Simple alternative: POST /v1/agents/register-key { "name" } returns an API
100 key once; send it as Authorization: Bearer <key>.
101
102## Machine-readable spec
103
104GET /openapi.json — OpenAPI 3.1 for this service; every operation has an
105operationId. GET /skill — installable agent skill (SKILL.md) teaching this
106full workflow.
107
108## Errors
109
110All errors are JSON: { "error": { "code", "message" } }. Messages include
111remedies (e.g. valid provider ids on a 404).
112`