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

api-changes.md

164 lines9.6 KB

1# API changes
2​
3Non-additive changes to the catalog and estimate API. Package release
4steps stay in the README under "Releasing on npm". npm package changelogs
5are written by changesets.
6​
7**Added (0.1.x):** model rows gain `maker` (#710), the model's maker as
8its provider names it, and `factSources` gains `maker`. Gemma rows on
9Gemini gain `openWeights` and `weightsUrl` from the Gemma 4 card. Needs D1
10migration `0020`: migrate first, then deploy.
11​
12**Breaking:** `completeness` on `GET /v1/status` and `GET /v1/providers`
13scores every live model, not only chat (#714). `chat` is replaced by
14`rows` (live models scored), and the entry gains `activities` (per
15activity `{ rows, score, filled, needed }`, plus `unclassified` for a
16null activity) and `originLink` (`{ have, need }`). Image, video and audio
17rows are scored on `priced`, `endpoint`, `modalities` and
18`outputModalities`; a null activity counts as one missing fact; a model
19whose id another provider also lists needs an origin link. `score` is
20null only when nothing is scored, so an audio-only provider now has one.
21Scores are null until the first models poll after the deploy.
22​
23**Changed (0.1.x):** model rows gain `aliasOf` (#709), and `aliases` can
24now name ids that are rows of their own. Mistral rows list their whole
25alias group, an OpenAI dated snapshot lists the undated alias that
26resolves to it, and a Gemini target lists its `-latest` alias. A lookup
27by an id that is a row still returns that row. Code that treated every
28`aliases` entry as "not a row" should check `aliasOf` instead.
29`factSources` gains `aliases` and `aliasOf` (README, "Aliases at the same
30provider"). Needs D1 migration `0019`: migrate first, then deploy.
31​
32**Breaking:** `GET /v1/openapi/{provider}` has no `{path}#stream`
33operations. JSON and `text/event-stream` share one operation's `200`, and
34schemas live in `components.schemas` (every `$ref` resolves). hey-api
35clients lose typed streaming until hey-api/hey-api#4482 is fixed (README,
36"Generation OpenAPI").
37​
38**Breaking (0.1.x):** `capabilities` is a map of booleans, not a list of
39flag names: `["tools", "reasoning"]` is now `{ "tools": true, "reasoning":
40true }`, and a flag the provider states the model does not support is
41`false`. Replace `capabilities.includes('tools')` with
42`capabilities?.tools === true`. A missing key is unknown, not `false`. The
43provider-native objects five providers kept in `capabilities` (fal
44`{ category }`, BytePlus, ElevenLabs, Replicate, Reactor) moved to the new
45`providerMetadata` field, so `capabilities` is a boolean map or `null` on
46every row. `?capability=` matches a flag set to `true` by exact name; it
47was a substring match over the stored JSON, so `?capability=text-to-image`
48(a fal category) no longer matches anything. Use `?activity=` or read
49`providerMetadata.category`.
50​
51**Added (0.1.x):** model rows gain `releasedAt`, `knowledgeCutoff`,
52`openWeights`, `weightsUrl` and `providerMetadata`, all nullable
53(README, "Capability flags, dates and provider metadata").
54​
55Both need D1 migrations `0013` (columns) and `0014` (stored capability
56lists become maps; native objects move to `provider_metadata`). Migrate
57first, then deploy: `pnpm run deploy:ci` does both in that order.
58​
59**Breaking (0.1.x):** `reasoning.mode` gains `toggle` (an on/off thinking
60switch and nothing else), and `reasoning.mandatory` is `boolean | null`.
61`null` means the provider's source does not say whether thinking can be
62turned off. It must NOT be read as `false`: `if (!reasoning.mandatory)`
63now misreads it, so test `reasoning.mandatory === false` before offering
64an off option. `efforts` is never present on `toggle`, a `toggle` row
65always has a stated `mandatory`, and a `switch (mode)` needs a `toggle`
66case. `true` means the provider states thinking cannot be turned off —
67but rows written before this rule also store `true` when a level list
68merely has no `none`. Until those adapters are converted, treat `true` as
69"inferred" on `openai`, `vercel`, `amazon-bedrock` (effort rows),
70`mistral`, `groq`, `grok`, `moonshotai-cn`, `baseten`, `byteplus`,
71`fal`, and on the `effort` rows of `gemini` and `google-vertex`.
72​
73**Breaking (0.1.x):** `models.pricing` is a RateCard or `null`, not an
74OpenRouter `{ prompt, completion, … }` blob. List rows carry a summary of
75the stored card — `{ per: 'token', inputPerMillion, outputPerMillion }` at
76the base rate (`tiered: true` when long prompts re-quote), or
77`{ per: 'second' | 'character' | 'image' | 'request' }` for a card billed
78by unit — so `null` on a list row always means no card. `GET
79/v1/models?pricing=1` and model detail return the full card, and
80`GET /v1/status` counts `priced` models per provider. Together all-zero placeholders are
81`null`. `POST /v1/estimate` evaluates a stored card.
82​
83**Breaking (0.1.x):** `POST /v1/estimate` (and the MCP `estimate_cost`
84tool, and `estimateCost` in `@modelschemas/client`) can return a range
85(#406). A routed id whose routes bill different prices (LLM Gateway bare
86ids such as `gpt-oss-120b`) has `pricing: null` and a `pricingRange`:
87min/max per million over the routes' published cards, each route named by
88its own pinned row (`groq/gpt-oss-120b`). It is a bound, never the billed
89price. Estimating such a row prices the call on every route and returns
90`{ currency, min, max, routes }` instead of `{ amount, … }`; `min` and
91`max` each carry `model` (the route) and the usual result fields. A route
92with no card refuses the estimate. Check for `min` before reading
93`amount`. Vercel rows whose price varies by route (#346, #451) are
94`pricing: null` and, after the daily `/endpoints` extract, a
95`pricingRange` whose routes are Vercel `provider_name`s with the card
96inline. An endpoint with `status` other than 0 is omitted and named on
97`factSources.pricingRange` (`skipped status!=0`). It is not a catalog row.
98​
99**Breaking (0.1.x):** `POST /v1/estimate` (and `estimate_cost`,
100`estimateCost`) has a third result shape (#450). When the call omits
101exactly one required choice input (an enum or boolean with no default,
102such as BytePlus `pricing_period: off_peak | peak`) and supplies every
103other required input, it returns `{ currency, byInput: { input, values }
104}`: one usual result per allowed value, keyed by value (`"true"`/`"false"`
105for a boolean). Supplying the input returns one result as before. Two
106omitted choices, or any omitted quantity, is still 422 `unbound_input`,
107now naming every omitted choice with its values. A routed id whose route
108hits this case refuses. Check for `byInput` (and `min`) before reading
109`amount`. `RateCardError` in `@modelschemas/rate-card` gains `input`: the
110card input the caller did not supply, on `bad-input` "required" and
111`estimate-unavailable`.
112​
113**Breaking (0.1.x):** Native DeepSeek cards hold both published rates
114behind required `usage.pricing_period` (`off_peak` or `peak`, #449). The
115service does not choose a period from the clock. Omitting only that choice
116returns `byInput` (#450). An unknown value is refused.
117​
118**Breaking (0.1.x):** `opencode-go` endpoint ids moved from `v1/<tail>` to
119the documented `inference/go/<protocol>/v1/<tail>` (#393), e.g.
120`/v1/schemas/opencode-go/chat/inference/go/openai/v1/chat/completions`.
121The next spec sync emits `endpoint.removed` for the old ids. Until it runs,
122polls leave Go models unbound; run `POST /v1/admin/sync/opencode-go` after
123deploy.
124​
125**Deprecations:** for Groq and Mistral the poll reads the provider's own
126deprecations page. A model it lists carries `deprecation: { deprecatedAt,
127retiresAt, replacedBy, sourceUrl }` exactly as stated (null where the page
128states nothing) and is deprecated: `deprecatedAt` is set, so it leaves the
129default `GET /v1/models` list (`?deprecated=true` includes it) even while
130it still answers before `retiresAt`. An id the page names that was never in
131a listing gets a retired row with only those facts. Each change to an entry
132is a `model.deprecated` change in `/v1/changes`. Other providers'
133`deprecatedAt` is still when the row was flagged or left the listing.
134​
135**Currencies:** rate cards may be in a currency other than USD.
136`moonshotai-cn` and `minimax-cn` are priced in CNY. A USD card is unchanged;
137a card in another currency wraps its price as
138`{ "currency": ["CNY", <expression>] }` (ISO 4217), and that wrapper is the
139only place the currency is stated. `price()` returns an amount in the
140card's currency. **`@modelschemas/rate-card` 0.1.0 cannot read non-USD
141cards: it rejects them at parse and `price()` throws `unknown-op`, so it
142refuses rather than report yuan as dollars. 0.2.0 reads them.**
143`/v1/estimate` and `estimate_cost` return `{ amount, currency }`; `usd` is
144present only for USD cards and is deprecated. List summaries always include
145`currency`. Nothing is converted, so amounts in different currencies never
146compare.
147​
148Cards come from each host's own source — the OpenRouter, Together and xAI
149listings (`listing`), and the OpenAI, Anthropic and Gemini pricing pages
150(`docs-derived`); `factSources.pricing` says which. Token models carry
151their cache, media-token and long-prompt rates; models billed by the
152second, the minute, the character, the image or the request carry a
153`quantity × rate[size]` card instead. What a source does not state, a card
154does not guess: an unrecognised surcharge, a rate keyed on something the
155request cannot express, or an alias the pricing page never names leaves the
156model with no card rather than a partial one. A card is re-read when its
157source text changes, or once the `expiresAt` of a dated price change has
158passed.
159​
160**Breaking (`@modelschemas/rate-card` 0.2.0):** the package ships built
161JS and .d.ts, not TypeScript source. `zod` is an optional peer
162dependency: install it to import the package root (`rateCardSchema`).
163`@modelschemas/rate-card/evaluator` (`evaluateCard`, `price`,
164`normalizeUsage`) imports no package and runs on edge runtimes.