fix: make model option types match what OpenAI and Anthropic accept #2242
Showing 46 changed files with 20 additions and 5 deletions (loading 43).
x
@@ -0,0 +1,13 @@
+---
+'@tanstack/ai': minor
+'@tanstack/ai-openai': minor
+'@tanstack/ai-anthropic': patch
+---
+
+Fix model option types that did not match what the provider accepts.
+
+- `@tanstack/ai`: an adapter can mark `modelOptions` keys that work only with `reasoning: 'off'` (`offOnlyOptions` on its reasoning capability). `chat()`, `ctx.chat()` and `createChatOptions()` then make those keys a type error when `reasoning` is not `'off'` or not set.
+- `@tanstack/ai-openai`: on reasoning models (o-series, `gpt-5*`, `gpt-6*`, except `*-chat-latest`), `temperature`, `top_p` and `top_logprobs` type-check only with `reasoning: 'off'`. `o3-deep-research` and `o4-mini-deep-research` have no `'off'` level, so these options are always a type error there. The adapter still drops them at runtime for JS callers. Before, the types accepted them and nothing told you that they were dropped.
+- `@tanstack/ai-openai`: `gpt-6.1-terra` (`off` to `max`) and `gpt-6.1-terra-pro` (`low` to `max`) now have their reasoning levels. Before, every `reasoning` value was a type error, and the adapter sent no reasoning effort.
+- `@tanstack/ai-openai`: `service_tier` uses the `ServiceTier` type of the OpenAI SDK. It now accepts `'scale'`, `'fast'` and `'ultrafast'`.
+- `@tanstack/ai-anthropic`: `claude-opus-5` and `claude-opus-5-5` no longer accept `temperature`, `top_p` or `top_k`. Anthropic returns a 400 for them on these models.
@@ -361,10 +361,12 @@
-- OpenAI rejects `temperature`, `top_p`, and `top_logprobs` on the reasoning models. `openaiText` drops the three options for these model ids:
- - The `o` models (`o1`, `o3`, `o4-mini`, and so on).
+- On a reasoning model, `temperature`, `top_p`, and `top_logprobs` type-check only with `reasoning: "off"`. OpenAI rejects them at other efforts.
+- This rule applies to these model ids:
+ - The `o` models (`o1`, `o3`, `o4-mini`, and more).
-- When reasoning effort is `none` (`reasoning: "off"`), OpenAI accepts the three options, so `openaiText` keeps them.
+- Some models have no `"off"` level (for example `gpt-6.1-sol`, `o3-deep-research`, and `o4-mini-deep-research`). On these models, the three options are always a type error.
+- `service_tier` takes the tiers of the OpenAI SDK: `"auto"`, `"default"`, `"flex"`, `"scale"`, `"priority"`, `"fast"`, and `"ultrafast"`. Not every model has every tier.