Skip to content
Source
Sign inSign up
TanStack/ai

feat: add defaultModelOptions to every adapter #2254

MergedAlemTuzlakmerged 17 commits intomain fromfeat/default-model-options-all-adaptersmerged by tombeckenham View on GitHub

Showing 235 changed files with 77 additions and 0 deletions (loading 231).

x
0 of 235 viewed, 235 left
3 additions and 0 deletions.agent/domain-map.jsonModified
View file
@@ -35,6 +35,9 @@
"packages/ai-vertex",
"packages/ai-worldlabs",
"packages/ai-meshy",
+ "packages/ai-cartesia",
+ "packages/ai-muse",
+ "packages/ai-uthana",
"packages/ai-tripo"
],
"talksTo": ["core"]
16 additions and 0 deletions.changeset/adapter-default-model-options.mdAdded
View file
@@ -0,0 +1,16 @@
+---
+'@tanstack/ai': minor
+'@tanstack/ai-openrouter': minor
+---
+​
+Text adapters can carry `defaultModelOptions`. `chat()` merges them under the `modelOptions` of each call, one level deep. A key that the call sets replaces the default key in full. The engine, the middleware, and the adapter all get the merged value.
+​
+`createOpenRouterText()`, `openRouterText()`, `createOpenRouterResponsesText()`, and `openRouterResponsesText()` take a `defaultModelOptions` option, for example to set provider routing for every call:
+​
+```ts
+const adapter = openRouterText('openai/gpt-6.1-sol', {
+ defaultModelOptions: {
+ provider: { sort: 'latency', preferredMaxLatency: { p90: 2.5 } },
+ },
+})
+```