ai 7.0.173 → 7.0.175
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.
- package/CHANGELOG.md +26 -0
- package/dist/index.d.ts +68 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +292 -80
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +11 -9
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +16 -3
- package/dist/internal/index.js.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +3 -0
- package/docs/03-agents/06-memory.mdx +28 -1
- package/docs/03-ai-sdk-core/33-extractions.mdx +58 -1
- package/docs/03-ai-sdk-core/42-batch.mdx +54 -0
- package/docs/03-ai-sdk-core/45-provider-management.mdx +8 -0
- package/docs/07-reference/01-ai-sdk-core/14-extract.mdx +13 -13
- package/docs/07-reference/01-ai-sdk-core/20-start-batch.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/22-get-batch-results.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +14 -0
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +13 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-model-error.mdx +3 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-provider-error.mdx +3 -0
- package/package.json +12 -12
- package/src/batch/batch-types.ts +70 -18
- package/src/batch/batch.ts +93 -7
- package/src/extract/extract.ts +23 -4
- package/src/extract/extraction-provider.ts +5 -0
- package/src/extract/extraction-result.ts +1 -1
- package/src/generate-text/stream-text.ts +1 -1
- package/src/global.ts +1 -0
- package/src/model/resolve-model.ts +25 -0
- package/src/registry/custom-provider.ts +37 -0
- package/src/registry/index.ts +1 -0
- package/src/registry/no-such-provider-error.ts +1 -0
- package/src/registry/provider-registry.ts +59 -5
- package/src/telemetry/redact-telemetry-credentials.ts +22 -4
- package/src/types/citation.ts +41 -25
- package/src/ui/validate-ui-messages.ts +46 -91
- package/src/util/normalize-json-value.ts +182 -0
|
@@ -100,6 +100,7 @@ The open-source community has created the following providers:
|
|
|
100
100
|
- [Interfaze Provider](/providers/community-providers/interfaze) (`@interfaze-ai/ai-sdk`)
|
|
101
101
|
- [Telnyx Provider](/providers/community-providers/telnyx) (`@telnyx/ai-sdk-provider`)
|
|
102
102
|
- [ZeroGPU Provider](/providers/community-providers/zerogpu) (`@zerogpu/ai-sdk-provider`)
|
|
103
|
+
- [Upstash AgentKit Provider](/providers/community-providers/upstash-agentkit) (`@upstash/agentkit-ai-sdk`)
|
|
103
104
|
|
|
104
105
|
## Self-Hosted Models
|
|
105
106
|
|
|
@@ -135,6 +136,8 @@ Here are the capabilities of popular models:
|
|
|
135
136
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
136
137
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
137
138
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3-mini` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
139
|
+
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6.2-astra` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
140
|
+
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6.2-sol` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
138
141
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6-astra` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
139
142
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6.1-sol` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
140
143
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-6.1-terra` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
@@ -260,7 +260,7 @@ MongoDB memory works with any AI SDK model and embedding provider, with no vendo
|
|
|
260
260
|
|
|
261
261
|
### Redis Agent Memory
|
|
262
262
|
|
|
263
|
-
[Redis Agent Memory](https://redis.io/agent-memory/) is a managed memory layer that combines session history with long-term memories. The [
|
|
263
|
+
[Redis Agent Memory](https://redis.io/agent-memory/) is a managed memory layer that combines session history with long-term memories. The [`@redis/vercel-ai-sdk`](https://www.npmjs.com/package/@redis/vercel-ai-sdk) package wraps a model you have already configured, restores the user's session and recalls relevant long-term memories before each call, and records the conversation afterwards. The model does not need memory tools. It also exposes memory tools for agents that should manage their own memory.
|
|
264
264
|
|
|
265
265
|
```bash
|
|
266
266
|
pnpm add @redis/vercel-ai-sdk
|
|
@@ -300,6 +300,33 @@ The package requires AI SDK 7. It accepts configured model objects, not model-na
|
|
|
300
300
|
|
|
301
301
|
See the [Redis Agent Memory provider documentation](/providers/community-providers/redis-agent-memory) for full setup and configuration.
|
|
302
302
|
|
|
303
|
+
### Upstash AgentKit
|
|
304
|
+
|
|
305
|
+
[Upstash AgentKit](https://upstash.com/docs/redis/sdks/agentkit/ai-sdk) stores long-term memory in Upstash Redis. The [`@upstash/agentkit-ai-sdk`](https://www.npmjs.com/package/@upstash/agentkit-ai-sdk) package provides `recall_memory` and `save_memory` tools, so the model decides what to save and when to look it up. Recall runs on Upstash Redis Search, so you do not need a separate vector database.
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
pnpm add @upstash/agentkit-ai-sdk
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
__PROVIDER_IMPORT__;
|
|
313
|
+
import { createMemoryTools } from '@upstash/agentkit-ai-sdk';
|
|
314
|
+
import { ToolLoopAgent } from 'ai';
|
|
315
|
+
|
|
316
|
+
const agent = new ToolLoopAgent({
|
|
317
|
+
model: __MODEL__,
|
|
318
|
+
tools: createMemoryTools({ userId: 'user-123' }),
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
const result = await agent.generate({
|
|
322
|
+
prompt: 'Remember that my favorite editor is Neovim',
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
The tools read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment by default. `userId` is the only tenant boundary, so take it from your authenticated session. In multi-user apps, call `createMemoryTools` inside your request handler so each request uses the right user. The package requires AI SDK 7 and works with any AI SDK provider.
|
|
327
|
+
|
|
328
|
+
See the [Upstash AgentKit provider documentation](/providers/community-providers/upstash-agentkit) for full setup and configuration. It also covers chat history, search tools for RAG, rate limiting, and tool caching.
|
|
329
|
+
|
|
303
330
|
## Custom Tool
|
|
304
331
|
|
|
305
332
|
Building your own memory tool from scratch is the most flexible approach. You control the storage format, the interface, and the retrieval logic. This requires the most upfront work but gives you full ownership of how memory works, with no provider lock-in and no external dependencies.
|
|
@@ -12,7 +12,8 @@ string, JSON object, or an array of ordered text, file, and JSON parts, the same
|
|
|
12
12
|
as [decisions](/docs/ai-sdk-core/decisions).
|
|
13
13
|
|
|
14
14
|
This API and the extraction model specification are experimental and may change
|
|
15
|
-
in patch releases. Pass an extraction model instance
|
|
15
|
+
in patch releases. Pass an extraction model instance, resolve a model through a
|
|
16
|
+
provider registry, or use a string ID resolved by a configured default provider.
|
|
16
17
|
|
|
17
18
|
```ts
|
|
18
19
|
import { experimental_extract, type Experimental_ExtractionModel } from 'ai';
|
|
@@ -124,6 +125,62 @@ choosing a model for a task.
|
|
|
124
125
|
as refused and `experimental_extract` throws
|
|
125
126
|
`Experimental_ExtractionRefusalError`.
|
|
126
127
|
|
|
128
|
+
## Model aliases and registries
|
|
129
|
+
|
|
130
|
+
Use `customProvider` to give extraction models application-specific names, then
|
|
131
|
+
register providers with `createProviderRegistry`:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { anthropic } from '@ai-sdk/anthropic';
|
|
135
|
+
import { openai } from '@ai-sdk/openai';
|
|
136
|
+
import {
|
|
137
|
+
createProviderRegistry,
|
|
138
|
+
customProvider,
|
|
139
|
+
experimental_extract,
|
|
140
|
+
} from 'ai';
|
|
141
|
+
|
|
142
|
+
const registry = createProviderRegistry({
|
|
143
|
+
invoices: customProvider({
|
|
144
|
+
extractionModels: {
|
|
145
|
+
fast: openai.extractionModel('gpt-6.1-sol'),
|
|
146
|
+
careful: anthropic.extractionModel('claude-sonnet-5-5'),
|
|
147
|
+
},
|
|
148
|
+
fallbackProvider: openai,
|
|
149
|
+
}),
|
|
150
|
+
anthropic,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const { answers } = await experimental_extract({
|
|
154
|
+
model: registry.extractionModel('invoices:fast'),
|
|
155
|
+
state: 'Invoice INV-2041, total due $1,250.00.',
|
|
156
|
+
fields: { total: { type: 'number', decimals: 2 } },
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Registry IDs use `providerId:modelId`. Custom aliases take precedence over a
|
|
161
|
+
fallback provider, and a fallback only resolves unknown model IDs.
|
|
162
|
+
|
|
163
|
+
String IDs passed directly to `experimental_extract` resolve through
|
|
164
|
+
`globalThis.AI_SDK_DEFAULT_PROVIDER.extractionModel(id)`. Vercel AI Gateway does
|
|
165
|
+
not provide extraction models yet, so configure a default provider with an
|
|
166
|
+
`extractionModel` method to use strings. This exposes an alias from the registry
|
|
167
|
+
above through a custom provider:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
globalThis.AI_SDK_DEFAULT_PROVIDER = customProvider({
|
|
171
|
+
extractionModels: { careful: registry.extractionModel('invoices:careful') },
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
await experimental_extract({
|
|
175
|
+
model: 'careful',
|
|
176
|
+
state: 'Invoice INV-2041, total due $1,250.00.',
|
|
177
|
+
fields: { total: { type: 'number', decimals: 2 } },
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Resolution errors use `NoSuchModelError` and `NoSuchProviderError` with
|
|
182
|
+
`modelType: 'extractionModel'`.
|
|
183
|
+
|
|
127
184
|
## Answers
|
|
128
185
|
|
|
129
186
|
Every answer has the field's `type` and a `value`. `value` is `null` when the
|
|
@@ -224,6 +224,60 @@ the provider when supported by that provider's batch API. Their tool calls and
|
|
|
224
224
|
results are returned as normalized `content` parts. See the provider
|
|
225
225
|
documentation for the tools and models available in batches.
|
|
226
226
|
|
|
227
|
+
## Structured output
|
|
228
|
+
|
|
229
|
+
`startBatch` accepts an `output` option for structured output. It is used by every
|
|
230
|
+
text request in the batch. Other batch formats, like image requests, ignore it.
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import {
|
|
234
|
+
experimental_getBatchResults as getBatchResults,
|
|
235
|
+
experimental_startBatch as startBatch,
|
|
236
|
+
Output,
|
|
237
|
+
} from 'ai';
|
|
238
|
+
import { z } from 'zod';
|
|
239
|
+
|
|
240
|
+
const output = Output.object({
|
|
241
|
+
schema: z.object({ translation: z.string() }),
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const batch = await startBatch({
|
|
245
|
+
output,
|
|
246
|
+
requests: [
|
|
247
|
+
{
|
|
248
|
+
id: 'translate-1',
|
|
249
|
+
type: 'text',
|
|
250
|
+
model: 'openai/gpt-5-mini',
|
|
251
|
+
prompt: 'Translate to English: Directeur commercial',
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Results are retrieved separately, so the AI SDK cannot carry the output type
|
|
258
|
+
across the two calls. Pass the same `output` to `getBatchResults` to parse and
|
|
259
|
+
validate each successful item:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
for await (const item of getBatchResults({ batch, output })) {
|
|
263
|
+
if (item.type === 'text' && item.status === 'succeeded') {
|
|
264
|
+
if (item.outputError == null) {
|
|
265
|
+
console.log(item.id, item.output); // typed from the schema
|
|
266
|
+
} else {
|
|
267
|
+
console.error(item.id, item.outputError.message, item.text);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Parsing or validation failures don't fail the entire item. Instead, items get
|
|
274
|
+
an `outputError` instead of `output`. This lets you resubmit only the
|
|
275
|
+
requests whose response was not valid. Without `output`, the raw JSON is
|
|
276
|
+
available in `text`.
|
|
277
|
+
|
|
278
|
+
Because `output` applies to the whole batch, all text items are parsed with the
|
|
279
|
+
same specification. To use different schemas, start separate batches.
|
|
280
|
+
|
|
227
281
|
## Checking batch status
|
|
228
282
|
|
|
229
283
|
The start result includes the initial status. Use `getBatchStatus` to retrieve
|
|
@@ -478,3 +478,11 @@ explicitly configured default provider with a `decisionModel` method. Registry
|
|
|
478
478
|
middleware for language and image models does not apply to decision.
|
|
479
479
|
See [Decisions](/docs/ai-sdk-core/decisions#model-aliases-and-registries)
|
|
480
480
|
for aliases, default-provider configuration, and capability differences.
|
|
481
|
+
|
|
482
|
+
## Experimental extraction models
|
|
483
|
+
|
|
484
|
+
Custom providers accept `extractionModels` aliases, and registries expose
|
|
485
|
+
`extractionModel('provider:model')`. These methods return model instances for
|
|
486
|
+
`experimental_extract`. Direct string IDs use an explicitly configured default
|
|
487
|
+
provider with an `extractionModel` method. See
|
|
488
|
+
[Extractions](/docs/ai-sdk-core/extractions#model-aliases-and-registries).
|
|
@@ -14,19 +14,19 @@ Extracts a nonempty map of typed fields from one state. See
|
|
|
14
14
|
|
|
15
15
|
## Parameters
|
|
16
16
|
|
|
17
|
-
| Parameter | Type | Description
|
|
18
|
-
| ----------------------- | ---------------------------------------------------------------------------------------------- |
|
|
19
|
-
| `model` | `Experimental_ExtractionModel` | Required experimental v4 extraction model instance.
|
|
20
|
-
| `state` | `Experimental_ExtractionState` | Required string, JSON object, or ordered array of text, file, and JSON parts.
|
|
21
|
-
| `fields` | `Record<string, Experimental_ExtractionField>` | Required nonempty field map.
|
|
22
|
-
| `referenceDate` | `string` | Optional `YYYY-MM-DD` date that anchors relative dates.
|
|
23
|
-
| `maxOutputTokens` | `number` | Optional maximum output tokens, an integer >= 1.
|
|
24
|
-
| `reasoning` | `'provider-default' \| 'none' \| 'minimal' \| 'low' \| 'medium' \| 'high' \| 'xhigh' \| 'max'` | Optional reasoning effort for supported models.
|
|
25
|
-
| `maxRetries` | `number` | Nonnegative integer; defaults to 2.
|
|
26
|
-
| `abortSignal` | `AbortSignal` | Cancels the extraction request.
|
|
27
|
-
| `experimental_download` | `Experimental_DownloadFunction` | Required for remote file URLs in state. Use `createDownload({ fetch })` with a DNS-protected transport for untrusted URLs.
|
|
28
|
-
| `headers` | `Record<string, string>` | Additional HTTP headers.
|
|
29
|
-
| `providerOptions` | `ProviderOptions` | Provider-specific options.
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| ----------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| `model` | `Experimental_ExtractionModel` | Required experimental v4 extraction model instance, or a string ID resolved by a configured default provider with an `extractionModel` method. |
|
|
20
|
+
| `state` | `Experimental_ExtractionState` | Required string, JSON object, or ordered array of text, file, and JSON parts. |
|
|
21
|
+
| `fields` | `Record<string, Experimental_ExtractionField>` | Required nonempty field map. |
|
|
22
|
+
| `referenceDate` | `string` | Optional `YYYY-MM-DD` date that anchors relative dates. |
|
|
23
|
+
| `maxOutputTokens` | `number` | Optional maximum output tokens, an integer >= 1. |
|
|
24
|
+
| `reasoning` | `'provider-default' \| 'none' \| 'minimal' \| 'low' \| 'medium' \| 'high' \| 'xhigh' \| 'max'` | Optional reasoning effort for supported models. |
|
|
25
|
+
| `maxRetries` | `number` | Nonnegative integer; defaults to 2. |
|
|
26
|
+
| `abortSignal` | `AbortSignal` | Cancels the extraction request. |
|
|
27
|
+
| `experimental_download` | `Experimental_DownloadFunction` | Required for remote file URLs in state. Use `createDownload({ fetch })` with a DNS-protected transport for untrusted URLs. |
|
|
28
|
+
| `headers` | `Record<string, string>` | Additional HTTP headers. |
|
|
29
|
+
| `providerOptions` | `ProviderOptions` | Provider-specific options. |
|
|
30
30
|
|
|
31
31
|
Remote file URLs are rejected with `DownloadError` unless `experimental_download`
|
|
32
32
|
is supplied. The model's `fetch` option does not apply to these downloads. See
|
|
@@ -50,6 +50,13 @@ const batch = await startBatch({
|
|
|
50
50
|
description:
|
|
51
51
|
'The independent requests to process. Each request must have a unique, non-empty id, a supported type, and type-specific properties such as model and prompt or messages for text requests.',
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
name: 'output',
|
|
55
|
+
type: 'Output',
|
|
56
|
+
isOptional: true,
|
|
57
|
+
description:
|
|
58
|
+
'Specification for structured data in text responses, as in generateText. Its response format is sent with every text request; image requests ignore it. Pass the same value to getBatchResults to parse and validate results.',
|
|
59
|
+
},
|
|
53
60
|
{
|
|
54
61
|
name: 'providerOptions',
|
|
55
62
|
type: 'ProviderOptions',
|
|
@@ -59,6 +59,13 @@ for await (const item of getBatchResults({ provider: anthropic, batch })) {
|
|
|
59
59
|
description:
|
|
60
60
|
'The client-defined tools provided on requests in the batch. Used to validate and normalize returned tool calls; execute functions are never invoked.',
|
|
61
61
|
},
|
|
62
|
+
{
|
|
63
|
+
name: 'output',
|
|
64
|
+
type: 'Output',
|
|
65
|
+
isOptional: true,
|
|
66
|
+
description:
|
|
67
|
+
'The output specification that was provided on requests in the batch. When set, the text of each successful item is parsed and validated. Items have either an `output` or an `outputError`; a parsing failure does not fail the item.',
|
|
68
|
+
},
|
|
62
69
|
{
|
|
63
70
|
name: 'providerOptions',
|
|
64
71
|
type: 'ProviderOptions',
|
|
@@ -316,3 +316,17 @@ added to the stable `ProviderV4` contract. Direct decision string IDs default
|
|
|
316
316
|
to Gateway when no default provider is configured.
|
|
317
317
|
See [Decisions](/docs/ai-sdk-core/decisions#model-aliases-and-registries)
|
|
318
318
|
for runnable usage patterns.
|
|
319
|
+
|
|
320
|
+
## Experimental extraction models
|
|
321
|
+
|
|
322
|
+
The inferred return type also exposes `extractionModel('providerId:modelId')`,
|
|
323
|
+
returning `Experimental_ExtractionModelV4`. The provider must expose an
|
|
324
|
+
`extractionModel` factory. Custom separators and model ID inference work as they
|
|
325
|
+
do for decision models, and middleware does not wrap extraction models. Use the
|
|
326
|
+
inferred return type or `Experimental_ExtractionProviderRegistry`, which also
|
|
327
|
+
includes decision access, to retain experimental extraction access.
|
|
328
|
+
|
|
329
|
+
Unavailable extraction capabilities or models throw `NoSuchModelError` with
|
|
330
|
+
`modelType: 'extractionModel'`; unknown registry providers throw
|
|
331
|
+
`NoSuchProviderError`. See
|
|
332
|
+
[Extractions](/docs/ai-sdk-core/extractions#model-aliases-and-registries).
|
|
@@ -219,3 +219,16 @@ added to the stable `ProviderV4` contract. Direct decision string IDs default
|
|
|
219
219
|
to Gateway when no default provider is configured.
|
|
220
220
|
See [Decisions](/docs/ai-sdk-core/decisions#model-aliases-and-registries)
|
|
221
221
|
for runnable usage patterns.
|
|
222
|
+
|
|
223
|
+
## Experimental extraction models
|
|
224
|
+
|
|
225
|
+
Pass `extractionModels: Record<string, Experimental_ExtractionModel>` to define
|
|
226
|
+
aliases for extraction model instances or string IDs. The returned provider adds
|
|
227
|
+
`extractionModel(alias): Experimental_ExtractionModelV4`. String aliases resolve
|
|
228
|
+
through an explicitly configured default provider with an `extractionModel`
|
|
229
|
+
method. Unknown aliases use the fallback provider's extraction factory when
|
|
230
|
+
available.
|
|
231
|
+
|
|
232
|
+
Unavailable extraction capabilities or models throw `NoSuchModelError` with
|
|
233
|
+
`modelType: 'extractionModel'`. See
|
|
234
|
+
[Extractions](/docs/ai-sdk-core/extractions#model-aliases-and-registries).
|
|
@@ -28,3 +28,6 @@ if (NoSuchModelError.isInstance(error)) {
|
|
|
28
28
|
Experimental decision resolution uses `modelType: 'decisionModel'`. This
|
|
29
29
|
includes unavailable decision capabilities and unknown decision model or
|
|
30
30
|
provider IDs. See [Decisions](/docs/ai-sdk-core/decisions#default-provider-strings).
|
|
31
|
+
|
|
32
|
+
Experimental extraction resolution uses `modelType: 'extractionModel'`. See
|
|
33
|
+
[Extractions](/docs/ai-sdk-core/extractions#model-aliases-and-registries).
|
|
@@ -30,3 +30,6 @@ if (NoSuchProviderError.isInstance(error)) {
|
|
|
30
30
|
Experimental decision resolution uses `modelType: 'decisionModel'`. This
|
|
31
31
|
includes unavailable decision capabilities and unknown decision model or
|
|
32
32
|
provider IDs. See [Decisions](/docs/ai-sdk-core/decisions#default-provider-strings).
|
|
33
|
+
|
|
34
|
+
Experimental extraction resolution uses `modelType: 'extractionModel'`. See
|
|
35
|
+
[Extractions](/docs/ai-sdk-core/extractions#model-aliases-and-registries).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.175",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ai-sdk/gateway": "4.0.
|
|
46
|
-
"@ai-sdk/provider": "4.0.
|
|
47
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
45
|
+
"@ai-sdk/gateway": "4.0.148",
|
|
46
|
+
"@ai-sdk/provider": "4.0.39",
|
|
47
|
+
"@ai-sdk/provider-utils": "5.0.82"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@ai-sdk/amazon-bedrock": "5.0.
|
|
51
|
-
"@ai-sdk/deepseek": "3.0.
|
|
52
|
-
"@ai-sdk/google": "4.0.
|
|
53
|
-
"@ai-sdk/groq": "4.0.
|
|
54
|
-
"@ai-sdk/huggingface": "2.0.
|
|
55
|
-
"@ai-sdk/moonshotai": "3.0.
|
|
56
|
-
"@ai-sdk/openai": "4.0.
|
|
50
|
+
"@ai-sdk/amazon-bedrock": "5.0.144",
|
|
51
|
+
"@ai-sdk/deepseek": "3.0.88",
|
|
52
|
+
"@ai-sdk/google": "4.0.122",
|
|
53
|
+
"@ai-sdk/groq": "4.0.85",
|
|
54
|
+
"@ai-sdk/huggingface": "2.0.94",
|
|
55
|
+
"@ai-sdk/moonshotai": "3.0.94",
|
|
56
|
+
"@ai-sdk/openai": "4.0.120",
|
|
57
57
|
"@ai-sdk/test-server": "2.0.4",
|
|
58
|
-
"@ai-sdk/xai": "5.0.
|
|
58
|
+
"@ai-sdk/xai": "5.0.47",
|
|
59
59
|
"@edge-runtime/vm": "^5.0.0",
|
|
60
60
|
"@smithy/eventstream-codec": "^4.3.3",
|
|
61
61
|
"@smithy/util-utf8": "^4.3.3",
|
package/src/batch/batch-types.ts
CHANGED
|
@@ -13,6 +13,8 @@ import type {
|
|
|
13
13
|
ToolSet,
|
|
14
14
|
} from '@ai-sdk/provider-utils';
|
|
15
15
|
import type { ContentPart } from '../generate-text/content-part';
|
|
16
|
+
import type { Output } from '../generate-text/output';
|
|
17
|
+
import type { InferCompleteOutput } from '../generate-text/output-utils';
|
|
16
18
|
import type { ToolOrder } from '../generate-text/tool-order';
|
|
17
19
|
import type { LanguageModelCallOptions } from '../prompt/language-model-call-options';
|
|
18
20
|
import type { Prompt } from '../prompt/prompt';
|
|
@@ -125,6 +127,16 @@ export type StartBatchOptions<
|
|
|
125
127
|
|
|
126
128
|
providerOptions?: ProviderOptions;
|
|
127
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Specification for structured data in the text responses. Its response
|
|
132
|
+
* format is sent with every text request in the batch; image requests
|
|
133
|
+
* ignore it.
|
|
134
|
+
*
|
|
135
|
+
* Pass the same specification to `getBatchResults` as `output` to parse and
|
|
136
|
+
* validate each result.
|
|
137
|
+
*/
|
|
138
|
+
output?: Output;
|
|
139
|
+
|
|
128
140
|
/**
|
|
129
141
|
* URL that the provider should notify when the batch reaches a terminal
|
|
130
142
|
* state. Providers that do not support completion webhooks return an
|
|
@@ -193,16 +205,26 @@ export type GetBatchStatusOptions = {
|
|
|
193
205
|
/**
|
|
194
206
|
* Options for retrieving batch results.
|
|
195
207
|
*/
|
|
196
|
-
export type GetBatchResultsOptions<
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
208
|
+
export type GetBatchResultsOptions<
|
|
209
|
+
TOOLS extends ToolSet = ToolSet,
|
|
210
|
+
OUTPUT extends Output | undefined = undefined,
|
|
211
|
+
> = GetBatchStatusOptions & {
|
|
212
|
+
/**
|
|
213
|
+
* Definitions for client tools that were provided to `startBatch` requests.
|
|
214
|
+
*
|
|
215
|
+
* The definitions are used only to validate and normalize returned tool
|
|
216
|
+
* calls. Their `execute` functions are never invoked.
|
|
217
|
+
*/
|
|
218
|
+
tools?: TOOLS;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The output specification that was provided to `startBatch` requests.
|
|
222
|
+
*
|
|
223
|
+
* When provided, the text of each successful item is parsed and validated
|
|
224
|
+
* with it. The item then has either `output` or `outputError`.
|
|
225
|
+
*/
|
|
226
|
+
output?: OUTPUT;
|
|
227
|
+
};
|
|
206
228
|
|
|
207
229
|
/**
|
|
208
230
|
* A normalized result for a successful text batch item.
|
|
@@ -222,16 +244,45 @@ export type TextBatchGenerationResult<TOOLS extends ToolSet = ToolSet> = {
|
|
|
222
244
|
readonly providerMetadata?: ProviderMetadata;
|
|
223
245
|
};
|
|
224
246
|
|
|
247
|
+
/**
|
|
248
|
+
* The parsed output of a successful text batch item, or the reason it could
|
|
249
|
+
* not be produced. Only present when `output` is passed to `getBatchResults`.
|
|
250
|
+
*
|
|
251
|
+
* A parsing failure does not fail the item: `text`, `usage` and the other
|
|
252
|
+
* generation results remain available.
|
|
253
|
+
*/
|
|
254
|
+
export type TextBatchOutputResult<OUTPUT extends Output | undefined> =
|
|
255
|
+
OUTPUT extends Output
|
|
256
|
+
?
|
|
257
|
+
| {
|
|
258
|
+
readonly output: InferCompleteOutput<OUTPUT>;
|
|
259
|
+
readonly outputError?: undefined;
|
|
260
|
+
}
|
|
261
|
+
| {
|
|
262
|
+
readonly output?: undefined;
|
|
263
|
+
/**
|
|
264
|
+
* Why no output is available, e.g. the text was not valid JSON,
|
|
265
|
+
* did not match the schema, or the item did not finish with a
|
|
266
|
+
* complete response.
|
|
267
|
+
*/
|
|
268
|
+
readonly outputError: BatchError;
|
|
269
|
+
}
|
|
270
|
+
: unknown;
|
|
271
|
+
|
|
225
272
|
/**
|
|
226
273
|
* A complete terminal result for one request in a text batch.
|
|
227
274
|
*/
|
|
228
|
-
export type TextBatchItemResult<
|
|
275
|
+
export type TextBatchItemResult<
|
|
276
|
+
TOOLS extends ToolSet = ToolSet,
|
|
277
|
+
OUTPUT extends Output | undefined = undefined,
|
|
278
|
+
> = {
|
|
229
279
|
readonly type: 'text';
|
|
230
280
|
} & (
|
|
231
|
-
| (TextBatchGenerationResult<TOOLS> &
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
281
|
+
| (TextBatchGenerationResult<TOOLS> &
|
|
282
|
+
TextBatchOutputResult<OUTPUT> & {
|
|
283
|
+
readonly id: string;
|
|
284
|
+
readonly status: 'succeeded';
|
|
285
|
+
})
|
|
235
286
|
| {
|
|
236
287
|
readonly id: string;
|
|
237
288
|
readonly status: 'failed';
|
|
@@ -282,6 +333,7 @@ export type ImageBatchItemResult = { readonly type: 'image' } & (
|
|
|
282
333
|
/**
|
|
283
334
|
* A complete terminal result for one request in a batch.
|
|
284
335
|
*/
|
|
285
|
-
export type BatchItemResult<
|
|
286
|
-
|
|
287
|
-
|
|
|
336
|
+
export type BatchItemResult<
|
|
337
|
+
TOOLS extends ToolSet = ToolSet,
|
|
338
|
+
OUTPUT extends Output | undefined = undefined,
|
|
339
|
+
> = TextBatchItemResult<TOOLS, OUTPUT> | ImageBatchItemResult;
|