ai 7.0.94 → 7.0.95

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.
@@ -0,0 +1,109 @@
1
+ ---
2
+ title: experimental_getBatchResults
3
+ description: API Reference for experimental_getBatchResults.
4
+ ---
5
+
6
+ # `experimental_getBatchResults()`
7
+
8
+ <Note type="warning">
9
+ Batch support is experimental and the API may change in patch releases.
10
+ </Note>
11
+
12
+ Returns an async iterable of terminal results for the requests in an
13
+ asynchronous batch. For a complete guide to the batch lifecycle, see
14
+ [Batch](/docs/ai-sdk-core/batch).
15
+
16
+ ```ts
17
+ import { anthropic } from '@ai-sdk/anthropic';
18
+ import { experimental_getBatchResults as getBatchResults } from 'ai';
19
+
20
+ for await (const item of getBatchResults({ provider: anthropic, batch })) {
21
+ if (item.status === 'succeeded') {
22
+ console.log(item.id, item.text);
23
+ } else {
24
+ console.error(item.id, item.error);
25
+ }
26
+ }
27
+ ```
28
+
29
+ ## Import
30
+
31
+ <Snippet
32
+ text={`import { experimental_getBatchResults } from "ai"`}
33
+ prompt={false}
34
+ />
35
+
36
+ ## API Signature
37
+
38
+ ### Parameters
39
+
40
+ <PropertiesTable
41
+ content={[
42
+ {
43
+ name: 'provider',
44
+ type: 'Experimental_BatchProvider',
45
+ isOptional: true,
46
+ description:
47
+ 'The provider used to access the batch. Defaults to the global provider, or the AI Gateway when no global provider is configured.',
48
+ },
49
+ {
50
+ name: 'batch',
51
+ type: 'Experimental_BatchReference',
52
+ description:
53
+ 'The serializable reference returned by experimental_startBatch.',
54
+ },
55
+ {
56
+ name: 'tools',
57
+ type: 'ToolSet',
58
+ isOptional: true,
59
+ description:
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
+ },
62
+ {
63
+ name: 'providerOptions',
64
+ type: 'ProviderOptions',
65
+ isOptional: true,
66
+ description: 'Additional provider-specific options for result retrieval.',
67
+ },
68
+ {
69
+ name: 'maxRetries',
70
+ type: 'number',
71
+ isOptional: true,
72
+ description:
73
+ 'Maximum number of retries for result retrieval. Set to 0 to disable retries. Default: 2.',
74
+ },
75
+ {
76
+ name: 'abortSignal',
77
+ type: 'AbortSignal',
78
+ isOptional: true,
79
+ description: 'An optional abort signal to cancel result retrieval.',
80
+ },
81
+ {
82
+ name: 'timeout',
83
+ type: 'number | { totalMs?: number }',
84
+ isOptional: true,
85
+ description: 'Maximum time allowed for result retrieval.',
86
+ },
87
+ {
88
+ name: 'headers',
89
+ type: 'Record<string, string | undefined>',
90
+ isOptional: true,
91
+ description: 'Additional HTTP headers for the request.',
92
+ },
93
+ ]}
94
+ />
95
+
96
+ ### Returns
97
+
98
+ An `AsyncIterableStream<Experimental_BatchItemResult>` of succeeded,
99
+ failed, cancelled, or expired request results. You can consume the stream as
100
+ either an async iterable or a `ReadableStream`.
101
+
102
+ Successful items contain `id`, `status: 'succeeded'`, `text`, normalized
103
+ `content` (including text, reasoning, sources, files, tool calls, and tool
104
+ results),
105
+ `finishReason`, `usage`, and optional response and provider metadata. `text` is
106
+ the concatenation of text parts and can be an empty string when a result
107
+ contains no text parts.
108
+ Failed, cancelled, and expired items contain the request `id`, their terminal
109
+ status, and optional error details.
@@ -53,6 +53,21 @@ AI SDK Core contains the following main functions:
53
53
  'Generate videos based on a given prompt using a video model.',
54
54
  href: '/docs/reference/ai-sdk-core/generate-video',
55
55
  },
56
+ {
57
+ title: 'experimental_startBatch()',
58
+ description: 'Start an asynchronous text-generation batch.',
59
+ href: '/docs/reference/ai-sdk-core/start-batch',
60
+ },
61
+ {
62
+ title: 'experimental_getBatchStatus()',
63
+ description: 'Retrieve the status of an asynchronous batch.',
64
+ href: '/docs/reference/ai-sdk-core/get-batch-status',
65
+ },
66
+ {
67
+ title: 'experimental_getBatchResults()',
68
+ description: 'Retrieve terminal results from an asynchronous batch.',
69
+ href: '/docs/reference/ai-sdk-core/get-batch-results',
70
+ },
56
71
  {
57
72
  title: 'transcribe()',
58
73
  description: 'Generate a transcript from an audio file.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.94",
3
+ "version": "7.0.95",
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",
@@ -47,13 +47,13 @@
47
47
  "@ai-sdk/provider-utils": "5.0.37"
48
48
  },
49
49
  "devDependencies": {
50
- "@ai-sdk/amazon-bedrock": "5.0.77",
50
+ "@ai-sdk/amazon-bedrock": "5.0.79",
51
51
  "@ai-sdk/deepseek": "3.0.40",
52
52
  "@ai-sdk/google": "4.0.65",
53
53
  "@ai-sdk/groq": "4.0.38",
54
54
  "@ai-sdk/huggingface": "2.0.45",
55
55
  "@ai-sdk/moonshotai": "3.0.46",
56
- "@ai-sdk/openai": "4.0.61",
56
+ "@ai-sdk/openai": "4.0.63",
57
57
  "@ai-sdk/test-server": "2.0.1",
58
58
  "@ai-sdk/xai": "4.0.55",
59
59
  "@edge-runtime/vm": "^5.0.0",
@@ -3,6 +3,7 @@ import {
3
3
  withUserAgentSuffix,
4
4
  type ProviderOptions,
5
5
  } from '@ai-sdk/provider-utils';
6
+ import { InvalidResponseDataError } from '../error';
6
7
  import { logWarnings } from '../logger/log-warnings';
7
8
  import { resolveEmbeddingModel } from '../model/resolve-model';
8
9
  import { createTelemetryDispatcher } from '../telemetry/create-telemetry-dispatcher';
@@ -221,6 +222,13 @@ export async function embed({
221
222
  callbacks: [telemetryDispatcher.onEmbedEnd],
222
223
  });
223
224
 
225
+ if (embedding == null) {
226
+ throw new InvalidResponseDataError({
227
+ data: modelResponse.embeddings,
228
+ message: 'No embedding generated.',
229
+ });
230
+ }
231
+
224
232
  return {
225
233
  embedding,
226
234
  usage,