@ai-sdk/gateway 4.0.98 → 4.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -625,16 +625,20 @@ const result = await generateText({
625
625
  });
626
626
 
627
627
  // Get the generation ID from provider metadata
628
- const generationId = result.providerMetadata?.gateway?.generationId;
628
+ const generationId = result.providerMetadata?.gateway?.generationId as
629
+ | string
630
+ | undefined;
629
631
 
630
632
  // Look up detailed generation info
631
- const generation = await gateway.getGenerationInfo({ id: generationId });
633
+ if (generationId) {
634
+ const generation = await gateway.getGenerationInfo({ id: generationId });
632
635
 
633
- console.log(`Model: ${generation.model}`);
634
- console.log(`Cost: $${generation.totalCost.toFixed(6)}`);
635
- console.log(`Latency: ${generation.latency}ms`);
636
- console.log(`Prompt tokens: ${generation.promptTokens}`);
637
- console.log(`Completion tokens: ${generation.completionTokens}`);
636
+ console.log(`Model: ${generation.model}`);
637
+ console.log(`Cost: $${generation.totalCost.toFixed(6)}`);
638
+ console.log(`Latency: ${generation.latency}ms`);
639
+ console.log(`Prompt tokens: ${generation.promptTokens}`);
640
+ console.log(`Completion tokens: ${generation.completionTokens}`);
641
+ }
638
642
  ```
639
643
 
640
644
  With `streamText`, you can capture the generation ID from the first chunk via `stream`:
@@ -1478,7 +1482,7 @@ The following gateway provider options are available:
1478
1482
 
1479
1483
  Example: `models: ['openai/gpt-5.4-nano', 'google/gemini-3.8-flash']` will try the fallback models in order if the primary model fails.
1480
1484
 
1481
- A direct condition uses `{ question, confidenceBelow }` for Choice and Score questions, or `{ question, probabilityBetween: [minimum, maximum] }` for Boolean questions. Boolean probability is P(true), not confidence in the selected Boolean outcome. Bounds are inclusive, finite, ordered, and within `[0, 1]`.
1485
+ A direct condition uses `{ question, confidenceBelow }` for Choice and Score questions, or `{ question, probabilityBetween: [minimum, maximum] }` for Boolean questions. Leave out `question` to check every question of that type: `{ confidenceBelow: 0.6 }` matches when any Choice or Score answer is below 0.6, and a request with no Choice or Score questions never matches it. Boolean probability is P(true), not confidence in the selected Boolean outcome. Bounds are inclusive, finite, ordered, and within `[0, 1]`.
1482
1486
 
1483
1487
  Combine conditions with `{ any: [...] }`, `{ all: [...] }`, or `{ atLeast: { count, conditions: [...] } }`. Each condition list holds 1 to 20 conditions. `atLeast.count` must be an integer from `1` through the number of conditions. Conditions nest at most 5 levels deep. Question IDs are 1 to 256 characters, and the conditional `model` must not be empty. The SDK checks these bounds before sending the request, and the gateway also checks that each question exists and has a kind that matches its condition. String error fallbacks may follow the conditional entry.
1484
1488
 
@@ -1600,15 +1604,15 @@ const { text } = await generateText({
1600
1604
  prompt: 'Write a TypeScript haiku',
1601
1605
  providerOptions: {
1602
1606
  gateway: {
1603
- models: ['openai/gpt-5.4-nano', 'gemini-3.8-flash'], // Fallback models
1607
+ models: ['openai/gpt-5.4-nano', 'google/gemini-3.8-flash'], // Fallback models
1604
1608
  } satisfies GatewayProviderOptions,
1605
1609
  },
1606
1610
  });
1607
1611
 
1608
1612
  // This will:
1609
- // 1. Try openai/gpt-5.4 first
1613
+ // 1. Try openai/gpt-6-astra first
1610
1614
  // 2. If it fails, try openai/gpt-5.4-nano
1611
- // 3. If that fails, try gemini-3-flash-preview
1615
+ // 3. If that fails, try google/gemini-3.8-flash
1612
1616
  // 4. Return the result from the first model that succeeds
1613
1617
  ```
1614
1618
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-sdk/gateway",
3
3
  "private": false,
4
- "version": "4.0.98",
4
+ "version": "4.0.101",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "sideEffects": false,
@@ -30,15 +30,15 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@ai-sdk/provider": "4.0.19",
34
- "@ai-sdk/provider-utils": "5.0.50",
33
+ "@ai-sdk/provider": "4.0.20",
34
+ "@ai-sdk/provider-utils": "5.0.52",
35
35
  "@vercel/oidc": "3.2.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@ai-sdk/test-server": "2.0.2",
38
+ "@ai-sdk/test-server": "2.0.3",
39
39
  "@types/node": "22.19.19",
40
40
  "@vercel/ai-tsconfig": "0.0.0",
41
- "tsup": "^8.5.1",
41
+ "tsdown": "^0.23.0",
42
42
  "tsx": "4.23.12",
43
43
  "typescript": "5.8.3",
44
44
  "zod": "3.25.76"
@@ -66,9 +66,9 @@
66
66
  "ai"
67
67
  ],
68
68
  "scripts": {
69
- "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
70
- "build:watch": "pnpm clean && tsup --watch",
71
- "clean": "del-cli dist docs *.tsbuildinfo",
69
+ "build": "pnpm clean && tsdown",
70
+ "build:watch": "pnpm clean && tsdown --watch",
71
+ "clean": "del-cli docs *.tsbuildinfo",
72
72
  "generate-model-settings": "tsx scripts/generate-model-settings.ts",
73
73
  "type-check": "tsc --build",
74
74
  "test": "pnpm test:node && pnpm test:edge",
@@ -95,13 +95,13 @@ export type GatewayModelId =
95
95
  | 'inception/mercury-coder-small'
96
96
  | 'inclusionai/ling-3.0-flash'
97
97
  | 'inclusionai/ling-3.0-flash-fin'
98
- | 'inclusionai/ling-3.0-flash-fin-free'
99
98
  | 'inclusionai/ling-3.0-flash-sante'
100
99
  | 'inclusionai/ling-3.0-flash-sante-free'
101
100
  | 'inclusionai/ling-3.0-flash-vl'
102
101
  | 'inference-net/schematron-v2-small'
103
102
  | 'inference-net/schematron-v2-turbo'
104
103
  | 'interfaze/interfaze-beta'
104
+ | 'meituan/longcat-2.5-preview'
105
105
  | 'meta/llama-3.1-70b'
106
106
  | 'meta/llama-3.1-8b'
107
107
  | 'meta/llama-3.3-70b'
@@ -193,6 +193,7 @@ export type GatewayModelId =
193
193
  | 'openai/gpt-5.6-terra-fast'
194
194
  | 'openai/gpt-6-astra'
195
195
  | 'openai/gpt-6-astra-fast'
196
+ | 'openai/gpt-6.1-sol'
196
197
  | 'openai/gpt-6-luna'
197
198
  | 'openai/gpt-6-luna-fast'
198
199
  | 'openai/gpt-6-sol'
@@ -209,8 +210,6 @@ export type GatewayModelId =
209
210
  | 'openai/o4-mini'
210
211
  | 'openai/o4-mini-fast'
211
212
  | 'perplexity/sonar'
212
- | 'perplexity/sonar-pro'
213
- | 'perplexity/sonar-reasoning-pro'
214
213
  | 'poolside/laguna-s-2.1'
215
214
  | 'poolside/laguna-s-2.1-free'
216
215
  | 'quiverai/arrow-2'
@@ -232,6 +231,7 @@ export type GatewayModelId =
232
231
  | 'spacexai/grok-4.6'
233
232
  | 'spacexai/grok-4.7'
234
233
  | 'spacexai/grok-build-0.1'
234
+ | 'stealth/pixel-canary'
235
235
  | 'stepfun/step-3.5-flash'
236
236
  | 'stepfun/step-3.7-flash'
237
237
  | 'stepfun/step-5-preview'
@@ -19,13 +19,15 @@ export const gatewayEvaluationProviderOptionsSchema = lazySchema(() =>
19
19
 
20
20
  /**
21
21
  * A condition on the primary model's answers. `QUESTION_ID` narrows
22
- * `question` to your question IDs. Groups nest at most five levels deep,
23
- * which the SDK checks at runtime.
22
+ * `question` to your question IDs. Without `question`, `confidenceBelow`
23
+ * checks every Choice and Score question and `probabilityBetween` every
24
+ * Boolean question. Groups nest at most five levels deep, which the SDK
25
+ * checks at runtime.
24
26
  */
25
27
  export type EvaluationFallbackCondition<QUESTION_ID extends string = string> =
26
- | ExclusiveCondition<{ question: QUESTION_ID; confidenceBelow: number }>
28
+ | ExclusiveCondition<{ question?: QUESTION_ID; confidenceBelow: number }>
27
29
  | ExclusiveCondition<{
28
- question: QUESTION_ID;
30
+ question?: QUESTION_ID;
29
31
  probabilityBetween: [number, number];
30
32
  }>
31
33
  | ExclusiveCondition<{ any: EvaluationFallbackConditionList<QUESTION_ID> }>
@@ -162,13 +164,13 @@ const questionSchema = z
162
164
  const directConditionSchema = z.union([
163
165
  z
164
166
  .object({
165
- question: questionSchema,
167
+ question: questionSchema.optional(),
166
168
  confidenceBelow: probabilitySchema,
167
169
  })
168
170
  .strict(),
169
171
  z
170
172
  .object({
171
- question: questionSchema,
173
+ question: questionSchema.optional(),
172
174
  probabilityBetween: z
173
175
  .array(probabilitySchema)
174
176
  .length(2)
@@ -330,7 +330,7 @@ export function createGateway(
330
330
  : {}),
331
331
  ...options.headers,
332
332
  },
333
- `ai-sdk/gateway/${VERSION}`,
333
+ `ai-sdk-gateway/${VERSION}`,
334
334
  );
335
335
 
336
336
  const getHeaders = async () => {