@ai-sdk/provider 2.1.0-beta.3 → 2.1.0-beta.4
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 +7 -0
- package/dist/index.d.mts +92 -33
- package/dist/index.d.ts +92 -33
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# @ai-sdk/provider
|
2
2
|
|
3
|
+
## 2.1.0-beta.4
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 0adc679: feat(provider): shared spec v3
|
8
|
+
- 2b0caef: feat(provider): add preliminary provider executed tool results to language model specification
|
9
|
+
|
3
10
|
## 2.1.0-beta.3
|
4
11
|
|
5
12
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
2
2
|
export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
3
3
|
|
4
|
-
type
|
4
|
+
type SharedV3Headers = Record<string, string>;
|
5
5
|
|
6
6
|
/**
|
7
7
|
A JSON value can be a string, number, boolean, object, array, or null.
|
@@ -13,6 +13,54 @@ type JSONObject = {
|
|
13
13
|
};
|
14
14
|
type JSONArray = JSONValue[];
|
15
15
|
|
16
|
+
/**
|
17
|
+
* Additional provider-specific metadata.
|
18
|
+
* Metadata are additional outputs from the provider.
|
19
|
+
* They are passed through to the provider from the AI SDK
|
20
|
+
* and enable provider-specific functionality
|
21
|
+
* that can be fully encapsulated in the provider.
|
22
|
+
*
|
23
|
+
* This enables us to quickly ship provider-specific functionality
|
24
|
+
* without affecting the core AI SDK.
|
25
|
+
*
|
26
|
+
* The outer record is keyed by the provider name, and the inner
|
27
|
+
* record is keyed by the provider-specific metadata key.
|
28
|
+
*
|
29
|
+
* ```ts
|
30
|
+
* {
|
31
|
+
* "anthropic": {
|
32
|
+
* "cacheControl": { "type": "ephemeral" }
|
33
|
+
* }
|
34
|
+
* }
|
35
|
+
* ```
|
36
|
+
*/
|
37
|
+
type SharedV3ProviderMetadata = Record<string, Record<string, JSONValue>>;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Additional provider-specific options.
|
41
|
+
* Options are additional input to the provider.
|
42
|
+
* They are passed through to the provider from the AI SDK
|
43
|
+
* and enable provider-specific functionality
|
44
|
+
* that can be fully encapsulated in the provider.
|
45
|
+
*
|
46
|
+
* This enables us to quickly ship provider-specific functionality
|
47
|
+
* without affecting the core AI SDK.
|
48
|
+
*
|
49
|
+
* The outer record is keyed by the provider name, and the inner
|
50
|
+
* record is keyed by the provider-specific metadata key.
|
51
|
+
*
|
52
|
+
* ```ts
|
53
|
+
* {
|
54
|
+
* "anthropic": {
|
55
|
+
* "cacheControl": { "type": "ephemeral" }
|
56
|
+
* }
|
57
|
+
* }
|
58
|
+
* ```
|
59
|
+
*/
|
60
|
+
type SharedV3ProviderOptions = Record<string, Record<string, JSONValue>>;
|
61
|
+
|
62
|
+
type SharedV2Headers = Record<string, string>;
|
63
|
+
|
16
64
|
/**
|
17
65
|
* Additional provider-specific metadata.
|
18
66
|
* Metadata are additional outputs from the provider.
|
@@ -120,7 +168,7 @@ type EmbeddingModelV3<VALUE> = {
|
|
120
168
|
to the provider from the AI SDK and enable provider-specific
|
121
169
|
functionality that can be fully encapsulated in the provider.
|
122
170
|
*/
|
123
|
-
providerOptions?:
|
171
|
+
providerOptions?: SharedV3ProviderOptions;
|
124
172
|
/**
|
125
173
|
Additional HTTP headers to be sent with the request.
|
126
174
|
Only applicable for HTTP-based providers.
|
@@ -142,7 +190,7 @@ type EmbeddingModelV3<VALUE> = {
|
|
142
190
|
from the provider to the AI SDK and enable provider-specific
|
143
191
|
results that can be fully encapsulated in the provider.
|
144
192
|
*/
|
145
|
-
providerMetadata?:
|
193
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
146
194
|
/**
|
147
195
|
Optional response information for debugging purposes.
|
148
196
|
*/
|
@@ -150,7 +198,7 @@ type EmbeddingModelV3<VALUE> = {
|
|
150
198
|
/**
|
151
199
|
Response headers.
|
152
200
|
*/
|
153
|
-
headers?:
|
201
|
+
headers?: SharedV3Headers;
|
154
202
|
/**
|
155
203
|
The response body.
|
156
204
|
*/
|
@@ -525,7 +573,7 @@ type ImageModelV3CallOptions = {
|
|
525
573
|
}
|
526
574
|
```
|
527
575
|
*/
|
528
|
-
providerOptions:
|
576
|
+
providerOptions: SharedV3ProviderOptions;
|
529
577
|
/**
|
530
578
|
Abort signal for cancelling the operation.
|
531
579
|
*/
|
@@ -817,7 +865,7 @@ type LanguageModelV3FunctionTool = {
|
|
817
865
|
/**
|
818
866
|
The provider-specific options for the tool.
|
819
867
|
*/
|
820
|
-
providerOptions?:
|
868
|
+
providerOptions?: SharedV3ProviderOptions;
|
821
869
|
};
|
822
870
|
|
823
871
|
/**
|
@@ -853,7 +901,7 @@ type LanguageModelV3Message = ({
|
|
853
901
|
* to the provider from the AI SDK and enable provider-specific
|
854
902
|
* functionality that can be fully encapsulated in the provider.
|
855
903
|
*/
|
856
|
-
providerOptions?:
|
904
|
+
providerOptions?: SharedV3ProviderOptions;
|
857
905
|
};
|
858
906
|
/**
|
859
907
|
Text content part of a prompt. It contains a string of text.
|
@@ -869,7 +917,7 @@ interface LanguageModelV3TextPart {
|
|
869
917
|
* to the provider from the AI SDK and enable provider-specific
|
870
918
|
* functionality that can be fully encapsulated in the provider.
|
871
919
|
*/
|
872
|
-
providerOptions?:
|
920
|
+
providerOptions?: SharedV3ProviderOptions;
|
873
921
|
}
|
874
922
|
/**
|
875
923
|
Reasoning content part of a prompt. It contains a string of reasoning text.
|
@@ -885,7 +933,7 @@ interface LanguageModelV3ReasoningPart {
|
|
885
933
|
* to the provider from the AI SDK and enable provider-specific
|
886
934
|
* functionality that can be fully encapsulated in the provider.
|
887
935
|
*/
|
888
|
-
providerOptions?:
|
936
|
+
providerOptions?: SharedV3ProviderOptions;
|
889
937
|
}
|
890
938
|
/**
|
891
939
|
File content part of a prompt. It contains a file.
|
@@ -913,7 +961,7 @@ interface LanguageModelV3FilePart {
|
|
913
961
|
* to the provider from the AI SDK and enable provider-specific
|
914
962
|
* functionality that can be fully encapsulated in the provider.
|
915
963
|
*/
|
916
|
-
providerOptions?:
|
964
|
+
providerOptions?: SharedV3ProviderOptions;
|
917
965
|
}
|
918
966
|
/**
|
919
967
|
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
@@ -942,7 +990,7 @@ interface LanguageModelV3ToolCallPart {
|
|
942
990
|
* to the provider from the AI SDK and enable provider-specific
|
943
991
|
* functionality that can be fully encapsulated in the provider.
|
944
992
|
*/
|
945
|
-
providerOptions?:
|
993
|
+
providerOptions?: SharedV3ProviderOptions;
|
946
994
|
}
|
947
995
|
/**
|
948
996
|
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
@@ -966,7 +1014,7 @@ interface LanguageModelV3ToolResultPart {
|
|
966
1014
|
* to the provider from the AI SDK and enable provider-specific
|
967
1015
|
* functionality that can be fully encapsulated in the provider.
|
968
1016
|
*/
|
969
|
-
providerOptions?:
|
1017
|
+
providerOptions?: SharedV3ProviderOptions;
|
970
1018
|
}
|
971
1019
|
type LanguageModelV3ToolResultOutput = {
|
972
1020
|
type: 'text';
|
@@ -1133,7 +1181,7 @@ type LanguageModelV3CallOptions = {
|
|
1133
1181
|
* to the provider from the AI SDK and enable provider-specific
|
1134
1182
|
* functionality that can be fully encapsulated in the provider.
|
1135
1183
|
*/
|
1136
|
-
providerOptions?:
|
1184
|
+
providerOptions?: SharedV3ProviderOptions;
|
1137
1185
|
};
|
1138
1186
|
|
1139
1187
|
/**
|
@@ -1186,7 +1234,7 @@ type LanguageModelV3Reasoning = {
|
|
1186
1234
|
/**
|
1187
1235
|
* Optional provider-specific metadata for the reasoning part.
|
1188
1236
|
*/
|
1189
|
-
providerMetadata?:
|
1237
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1190
1238
|
};
|
1191
1239
|
|
1192
1240
|
/**
|
@@ -1213,7 +1261,7 @@ type LanguageModelV3Source = {
|
|
1213
1261
|
/**
|
1214
1262
|
* Additional provider metadata for the source.
|
1215
1263
|
*/
|
1216
|
-
providerMetadata?:
|
1264
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1217
1265
|
} | {
|
1218
1266
|
type: 'source';
|
1219
1267
|
/**
|
@@ -1239,7 +1287,7 @@ type LanguageModelV3Source = {
|
|
1239
1287
|
/**
|
1240
1288
|
* Additional provider metadata for the source.
|
1241
1289
|
*/
|
1242
|
-
providerMetadata?:
|
1290
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1243
1291
|
};
|
1244
1292
|
|
1245
1293
|
/**
|
@@ -1251,7 +1299,7 @@ type LanguageModelV3Text = {
|
|
1251
1299
|
The text content.
|
1252
1300
|
*/
|
1253
1301
|
text: string;
|
1254
|
-
providerMetadata?:
|
1302
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1255
1303
|
};
|
1256
1304
|
|
1257
1305
|
/**
|
@@ -1280,7 +1328,7 @@ type LanguageModelV3ToolCall = {
|
|
1280
1328
|
/**
|
1281
1329
|
* Additional provider-specific metadata for the tool call.
|
1282
1330
|
*/
|
1283
|
-
providerMetadata?:
|
1331
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1284
1332
|
};
|
1285
1333
|
|
1286
1334
|
/**
|
@@ -1306,14 +1354,25 @@ type LanguageModelV3ToolResult = {
|
|
1306
1354
|
isError?: boolean;
|
1307
1355
|
/**
|
1308
1356
|
* Whether the tool result was generated by the provider.
|
1357
|
+
*
|
1309
1358
|
* If this flag is set to true, the tool result was generated by the provider.
|
1310
1359
|
* If this flag is not set or is false, the tool result was generated by the client.
|
1311
1360
|
*/
|
1312
1361
|
providerExecuted?: boolean;
|
1362
|
+
/**
|
1363
|
+
* Whether the tool result is preliminary.
|
1364
|
+
*
|
1365
|
+
* Preliminary tool results replace each other, e.g. image previews.
|
1366
|
+
* There always has to be a final, non-preliminary tool result.
|
1367
|
+
*
|
1368
|
+
* If this flag is set to true, the tool result is preliminary.
|
1369
|
+
* If this flag is not set or is false, the tool result is not preliminary.
|
1370
|
+
*/
|
1371
|
+
preliminary?: boolean;
|
1313
1372
|
/**
|
1314
1373
|
* Additional provider-specific metadata for the tool result.
|
1315
1374
|
*/
|
1316
|
-
providerMetadata?:
|
1375
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1317
1376
|
};
|
1318
1377
|
|
1319
1378
|
type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
|
@@ -1380,45 +1439,45 @@ type LanguageModelV3Usage = {
|
|
1380
1439
|
|
1381
1440
|
type LanguageModelV3StreamPart = {
|
1382
1441
|
type: 'text-start';
|
1383
|
-
providerMetadata?:
|
1442
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1384
1443
|
id: string;
|
1385
1444
|
} | {
|
1386
1445
|
type: 'text-delta';
|
1387
1446
|
id: string;
|
1388
|
-
providerMetadata?:
|
1447
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1389
1448
|
delta: string;
|
1390
1449
|
} | {
|
1391
1450
|
type: 'text-end';
|
1392
|
-
providerMetadata?:
|
1451
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1393
1452
|
id: string;
|
1394
1453
|
} | {
|
1395
1454
|
type: 'reasoning-start';
|
1396
|
-
providerMetadata?:
|
1455
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1397
1456
|
id: string;
|
1398
1457
|
} | {
|
1399
1458
|
type: 'reasoning-delta';
|
1400
1459
|
id: string;
|
1401
|
-
providerMetadata?:
|
1460
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1402
1461
|
delta: string;
|
1403
1462
|
} | {
|
1404
1463
|
type: 'reasoning-end';
|
1405
1464
|
id: string;
|
1406
|
-
providerMetadata?:
|
1465
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1407
1466
|
} | {
|
1408
1467
|
type: 'tool-input-start';
|
1409
1468
|
id: string;
|
1410
1469
|
toolName: string;
|
1411
|
-
providerMetadata?:
|
1470
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1412
1471
|
providerExecuted?: boolean;
|
1413
1472
|
} | {
|
1414
1473
|
type: 'tool-input-delta';
|
1415
1474
|
id: string;
|
1416
1475
|
delta: string;
|
1417
|
-
providerMetadata?:
|
1476
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1418
1477
|
} | {
|
1419
1478
|
type: 'tool-input-end';
|
1420
1479
|
id: string;
|
1421
|
-
providerMetadata?:
|
1480
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1422
1481
|
} | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
|
1423
1482
|
type: 'stream-start';
|
1424
1483
|
warnings: Array<LanguageModelV3CallWarning>;
|
@@ -1428,7 +1487,7 @@ type LanguageModelV3StreamPart = {
|
|
1428
1487
|
type: 'finish';
|
1429
1488
|
usage: LanguageModelV3Usage;
|
1430
1489
|
finishReason: LanguageModelV3FinishReason;
|
1431
|
-
providerMetadata?:
|
1490
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1432
1491
|
} | {
|
1433
1492
|
type: 'raw';
|
1434
1493
|
rawValue: unknown;
|
@@ -1490,7 +1549,7 @@ type LanguageModelV3 = {
|
|
1490
1549
|
from the provider to the AI SDK and enable provider-specific
|
1491
1550
|
results that can be fully encapsulated in the provider.
|
1492
1551
|
*/
|
1493
|
-
providerMetadata?:
|
1552
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1494
1553
|
/**
|
1495
1554
|
Optional request information for telemetry and debugging purposes.
|
1496
1555
|
*/
|
@@ -1507,7 +1566,7 @@ type LanguageModelV3 = {
|
|
1507
1566
|
/**
|
1508
1567
|
Response headers.
|
1509
1568
|
*/
|
1510
|
-
headers?:
|
1569
|
+
headers?: SharedV3Headers;
|
1511
1570
|
/**
|
1512
1571
|
Response HTTP body.
|
1513
1572
|
*/
|
@@ -1544,7 +1603,7 @@ type LanguageModelV3 = {
|
|
1544
1603
|
/**
|
1545
1604
|
Response headers.
|
1546
1605
|
*/
|
1547
|
-
headers?:
|
1606
|
+
headers?: SharedV3Headers;
|
1548
1607
|
};
|
1549
1608
|
}>;
|
1550
1609
|
};
|
@@ -2867,4 +2926,4 @@ interface ProviderV2 {
|
|
2867
2926
|
speechModel?(modelId: string): SpeechModelV2;
|
2868
2927
|
}
|
2869
2928
|
|
2870
|
-
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3Embedding, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3CallWarning, type ImageModelV3ProviderMetadata, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3CallWarning, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderDefinedTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
2929
|
+
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3Embedding, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3CallWarning, type ImageModelV3ProviderMetadata, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3CallWarning, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderDefinedTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
2
2
|
export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
3
3
|
|
4
|
-
type
|
4
|
+
type SharedV3Headers = Record<string, string>;
|
5
5
|
|
6
6
|
/**
|
7
7
|
A JSON value can be a string, number, boolean, object, array, or null.
|
@@ -13,6 +13,54 @@ type JSONObject = {
|
|
13
13
|
};
|
14
14
|
type JSONArray = JSONValue[];
|
15
15
|
|
16
|
+
/**
|
17
|
+
* Additional provider-specific metadata.
|
18
|
+
* Metadata are additional outputs from the provider.
|
19
|
+
* They are passed through to the provider from the AI SDK
|
20
|
+
* and enable provider-specific functionality
|
21
|
+
* that can be fully encapsulated in the provider.
|
22
|
+
*
|
23
|
+
* This enables us to quickly ship provider-specific functionality
|
24
|
+
* without affecting the core AI SDK.
|
25
|
+
*
|
26
|
+
* The outer record is keyed by the provider name, and the inner
|
27
|
+
* record is keyed by the provider-specific metadata key.
|
28
|
+
*
|
29
|
+
* ```ts
|
30
|
+
* {
|
31
|
+
* "anthropic": {
|
32
|
+
* "cacheControl": { "type": "ephemeral" }
|
33
|
+
* }
|
34
|
+
* }
|
35
|
+
* ```
|
36
|
+
*/
|
37
|
+
type SharedV3ProviderMetadata = Record<string, Record<string, JSONValue>>;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Additional provider-specific options.
|
41
|
+
* Options are additional input to the provider.
|
42
|
+
* They are passed through to the provider from the AI SDK
|
43
|
+
* and enable provider-specific functionality
|
44
|
+
* that can be fully encapsulated in the provider.
|
45
|
+
*
|
46
|
+
* This enables us to quickly ship provider-specific functionality
|
47
|
+
* without affecting the core AI SDK.
|
48
|
+
*
|
49
|
+
* The outer record is keyed by the provider name, and the inner
|
50
|
+
* record is keyed by the provider-specific metadata key.
|
51
|
+
*
|
52
|
+
* ```ts
|
53
|
+
* {
|
54
|
+
* "anthropic": {
|
55
|
+
* "cacheControl": { "type": "ephemeral" }
|
56
|
+
* }
|
57
|
+
* }
|
58
|
+
* ```
|
59
|
+
*/
|
60
|
+
type SharedV3ProviderOptions = Record<string, Record<string, JSONValue>>;
|
61
|
+
|
62
|
+
type SharedV2Headers = Record<string, string>;
|
63
|
+
|
16
64
|
/**
|
17
65
|
* Additional provider-specific metadata.
|
18
66
|
* Metadata are additional outputs from the provider.
|
@@ -120,7 +168,7 @@ type EmbeddingModelV3<VALUE> = {
|
|
120
168
|
to the provider from the AI SDK and enable provider-specific
|
121
169
|
functionality that can be fully encapsulated in the provider.
|
122
170
|
*/
|
123
|
-
providerOptions?:
|
171
|
+
providerOptions?: SharedV3ProviderOptions;
|
124
172
|
/**
|
125
173
|
Additional HTTP headers to be sent with the request.
|
126
174
|
Only applicable for HTTP-based providers.
|
@@ -142,7 +190,7 @@ type EmbeddingModelV3<VALUE> = {
|
|
142
190
|
from the provider to the AI SDK and enable provider-specific
|
143
191
|
results that can be fully encapsulated in the provider.
|
144
192
|
*/
|
145
|
-
providerMetadata?:
|
193
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
146
194
|
/**
|
147
195
|
Optional response information for debugging purposes.
|
148
196
|
*/
|
@@ -150,7 +198,7 @@ type EmbeddingModelV3<VALUE> = {
|
|
150
198
|
/**
|
151
199
|
Response headers.
|
152
200
|
*/
|
153
|
-
headers?:
|
201
|
+
headers?: SharedV3Headers;
|
154
202
|
/**
|
155
203
|
The response body.
|
156
204
|
*/
|
@@ -525,7 +573,7 @@ type ImageModelV3CallOptions = {
|
|
525
573
|
}
|
526
574
|
```
|
527
575
|
*/
|
528
|
-
providerOptions:
|
576
|
+
providerOptions: SharedV3ProviderOptions;
|
529
577
|
/**
|
530
578
|
Abort signal for cancelling the operation.
|
531
579
|
*/
|
@@ -817,7 +865,7 @@ type LanguageModelV3FunctionTool = {
|
|
817
865
|
/**
|
818
866
|
The provider-specific options for the tool.
|
819
867
|
*/
|
820
|
-
providerOptions?:
|
868
|
+
providerOptions?: SharedV3ProviderOptions;
|
821
869
|
};
|
822
870
|
|
823
871
|
/**
|
@@ -853,7 +901,7 @@ type LanguageModelV3Message = ({
|
|
853
901
|
* to the provider from the AI SDK and enable provider-specific
|
854
902
|
* functionality that can be fully encapsulated in the provider.
|
855
903
|
*/
|
856
|
-
providerOptions?:
|
904
|
+
providerOptions?: SharedV3ProviderOptions;
|
857
905
|
};
|
858
906
|
/**
|
859
907
|
Text content part of a prompt. It contains a string of text.
|
@@ -869,7 +917,7 @@ interface LanguageModelV3TextPart {
|
|
869
917
|
* to the provider from the AI SDK and enable provider-specific
|
870
918
|
* functionality that can be fully encapsulated in the provider.
|
871
919
|
*/
|
872
|
-
providerOptions?:
|
920
|
+
providerOptions?: SharedV3ProviderOptions;
|
873
921
|
}
|
874
922
|
/**
|
875
923
|
Reasoning content part of a prompt. It contains a string of reasoning text.
|
@@ -885,7 +933,7 @@ interface LanguageModelV3ReasoningPart {
|
|
885
933
|
* to the provider from the AI SDK and enable provider-specific
|
886
934
|
* functionality that can be fully encapsulated in the provider.
|
887
935
|
*/
|
888
|
-
providerOptions?:
|
936
|
+
providerOptions?: SharedV3ProviderOptions;
|
889
937
|
}
|
890
938
|
/**
|
891
939
|
File content part of a prompt. It contains a file.
|
@@ -913,7 +961,7 @@ interface LanguageModelV3FilePart {
|
|
913
961
|
* to the provider from the AI SDK and enable provider-specific
|
914
962
|
* functionality that can be fully encapsulated in the provider.
|
915
963
|
*/
|
916
|
-
providerOptions?:
|
964
|
+
providerOptions?: SharedV3ProviderOptions;
|
917
965
|
}
|
918
966
|
/**
|
919
967
|
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
@@ -942,7 +990,7 @@ interface LanguageModelV3ToolCallPart {
|
|
942
990
|
* to the provider from the AI SDK and enable provider-specific
|
943
991
|
* functionality that can be fully encapsulated in the provider.
|
944
992
|
*/
|
945
|
-
providerOptions?:
|
993
|
+
providerOptions?: SharedV3ProviderOptions;
|
946
994
|
}
|
947
995
|
/**
|
948
996
|
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
@@ -966,7 +1014,7 @@ interface LanguageModelV3ToolResultPart {
|
|
966
1014
|
* to the provider from the AI SDK and enable provider-specific
|
967
1015
|
* functionality that can be fully encapsulated in the provider.
|
968
1016
|
*/
|
969
|
-
providerOptions?:
|
1017
|
+
providerOptions?: SharedV3ProviderOptions;
|
970
1018
|
}
|
971
1019
|
type LanguageModelV3ToolResultOutput = {
|
972
1020
|
type: 'text';
|
@@ -1133,7 +1181,7 @@ type LanguageModelV3CallOptions = {
|
|
1133
1181
|
* to the provider from the AI SDK and enable provider-specific
|
1134
1182
|
* functionality that can be fully encapsulated in the provider.
|
1135
1183
|
*/
|
1136
|
-
providerOptions?:
|
1184
|
+
providerOptions?: SharedV3ProviderOptions;
|
1137
1185
|
};
|
1138
1186
|
|
1139
1187
|
/**
|
@@ -1186,7 +1234,7 @@ type LanguageModelV3Reasoning = {
|
|
1186
1234
|
/**
|
1187
1235
|
* Optional provider-specific metadata for the reasoning part.
|
1188
1236
|
*/
|
1189
|
-
providerMetadata?:
|
1237
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1190
1238
|
};
|
1191
1239
|
|
1192
1240
|
/**
|
@@ -1213,7 +1261,7 @@ type LanguageModelV3Source = {
|
|
1213
1261
|
/**
|
1214
1262
|
* Additional provider metadata for the source.
|
1215
1263
|
*/
|
1216
|
-
providerMetadata?:
|
1264
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1217
1265
|
} | {
|
1218
1266
|
type: 'source';
|
1219
1267
|
/**
|
@@ -1239,7 +1287,7 @@ type LanguageModelV3Source = {
|
|
1239
1287
|
/**
|
1240
1288
|
* Additional provider metadata for the source.
|
1241
1289
|
*/
|
1242
|
-
providerMetadata?:
|
1290
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1243
1291
|
};
|
1244
1292
|
|
1245
1293
|
/**
|
@@ -1251,7 +1299,7 @@ type LanguageModelV3Text = {
|
|
1251
1299
|
The text content.
|
1252
1300
|
*/
|
1253
1301
|
text: string;
|
1254
|
-
providerMetadata?:
|
1302
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1255
1303
|
};
|
1256
1304
|
|
1257
1305
|
/**
|
@@ -1280,7 +1328,7 @@ type LanguageModelV3ToolCall = {
|
|
1280
1328
|
/**
|
1281
1329
|
* Additional provider-specific metadata for the tool call.
|
1282
1330
|
*/
|
1283
|
-
providerMetadata?:
|
1331
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1284
1332
|
};
|
1285
1333
|
|
1286
1334
|
/**
|
@@ -1306,14 +1354,25 @@ type LanguageModelV3ToolResult = {
|
|
1306
1354
|
isError?: boolean;
|
1307
1355
|
/**
|
1308
1356
|
* Whether the tool result was generated by the provider.
|
1357
|
+
*
|
1309
1358
|
* If this flag is set to true, the tool result was generated by the provider.
|
1310
1359
|
* If this flag is not set or is false, the tool result was generated by the client.
|
1311
1360
|
*/
|
1312
1361
|
providerExecuted?: boolean;
|
1362
|
+
/**
|
1363
|
+
* Whether the tool result is preliminary.
|
1364
|
+
*
|
1365
|
+
* Preliminary tool results replace each other, e.g. image previews.
|
1366
|
+
* There always has to be a final, non-preliminary tool result.
|
1367
|
+
*
|
1368
|
+
* If this flag is set to true, the tool result is preliminary.
|
1369
|
+
* If this flag is not set or is false, the tool result is not preliminary.
|
1370
|
+
*/
|
1371
|
+
preliminary?: boolean;
|
1313
1372
|
/**
|
1314
1373
|
* Additional provider-specific metadata for the tool result.
|
1315
1374
|
*/
|
1316
|
-
providerMetadata?:
|
1375
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1317
1376
|
};
|
1318
1377
|
|
1319
1378
|
type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
|
@@ -1380,45 +1439,45 @@ type LanguageModelV3Usage = {
|
|
1380
1439
|
|
1381
1440
|
type LanguageModelV3StreamPart = {
|
1382
1441
|
type: 'text-start';
|
1383
|
-
providerMetadata?:
|
1442
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1384
1443
|
id: string;
|
1385
1444
|
} | {
|
1386
1445
|
type: 'text-delta';
|
1387
1446
|
id: string;
|
1388
|
-
providerMetadata?:
|
1447
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1389
1448
|
delta: string;
|
1390
1449
|
} | {
|
1391
1450
|
type: 'text-end';
|
1392
|
-
providerMetadata?:
|
1451
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1393
1452
|
id: string;
|
1394
1453
|
} | {
|
1395
1454
|
type: 'reasoning-start';
|
1396
|
-
providerMetadata?:
|
1455
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1397
1456
|
id: string;
|
1398
1457
|
} | {
|
1399
1458
|
type: 'reasoning-delta';
|
1400
1459
|
id: string;
|
1401
|
-
providerMetadata?:
|
1460
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1402
1461
|
delta: string;
|
1403
1462
|
} | {
|
1404
1463
|
type: 'reasoning-end';
|
1405
1464
|
id: string;
|
1406
|
-
providerMetadata?:
|
1465
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1407
1466
|
} | {
|
1408
1467
|
type: 'tool-input-start';
|
1409
1468
|
id: string;
|
1410
1469
|
toolName: string;
|
1411
|
-
providerMetadata?:
|
1470
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1412
1471
|
providerExecuted?: boolean;
|
1413
1472
|
} | {
|
1414
1473
|
type: 'tool-input-delta';
|
1415
1474
|
id: string;
|
1416
1475
|
delta: string;
|
1417
|
-
providerMetadata?:
|
1476
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1418
1477
|
} | {
|
1419
1478
|
type: 'tool-input-end';
|
1420
1479
|
id: string;
|
1421
|
-
providerMetadata?:
|
1480
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1422
1481
|
} | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
|
1423
1482
|
type: 'stream-start';
|
1424
1483
|
warnings: Array<LanguageModelV3CallWarning>;
|
@@ -1428,7 +1487,7 @@ type LanguageModelV3StreamPart = {
|
|
1428
1487
|
type: 'finish';
|
1429
1488
|
usage: LanguageModelV3Usage;
|
1430
1489
|
finishReason: LanguageModelV3FinishReason;
|
1431
|
-
providerMetadata?:
|
1490
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1432
1491
|
} | {
|
1433
1492
|
type: 'raw';
|
1434
1493
|
rawValue: unknown;
|
@@ -1490,7 +1549,7 @@ type LanguageModelV3 = {
|
|
1490
1549
|
from the provider to the AI SDK and enable provider-specific
|
1491
1550
|
results that can be fully encapsulated in the provider.
|
1492
1551
|
*/
|
1493
|
-
providerMetadata?:
|
1552
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
1494
1553
|
/**
|
1495
1554
|
Optional request information for telemetry and debugging purposes.
|
1496
1555
|
*/
|
@@ -1507,7 +1566,7 @@ type LanguageModelV3 = {
|
|
1507
1566
|
/**
|
1508
1567
|
Response headers.
|
1509
1568
|
*/
|
1510
|
-
headers?:
|
1569
|
+
headers?: SharedV3Headers;
|
1511
1570
|
/**
|
1512
1571
|
Response HTTP body.
|
1513
1572
|
*/
|
@@ -1544,7 +1603,7 @@ type LanguageModelV3 = {
|
|
1544
1603
|
/**
|
1545
1604
|
Response headers.
|
1546
1605
|
*/
|
1547
|
-
headers?:
|
1606
|
+
headers?: SharedV3Headers;
|
1548
1607
|
};
|
1549
1608
|
}>;
|
1550
1609
|
};
|
@@ -2867,4 +2926,4 @@ interface ProviderV2 {
|
|
2867
2926
|
speechModel?(modelId: string): SpeechModelV2;
|
2868
2927
|
}
|
2869
2928
|
|
2870
|
-
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3Embedding, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3CallWarning, type ImageModelV3ProviderMetadata, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3CallWarning, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderDefinedTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
2929
|
+
export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3Embedding, EmptyResponseBodyError, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3CallWarning, type ImageModelV3ProviderMetadata, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3CallWarning, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderDefinedTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|