@ai-sdk/anthropic 3.0.0-beta.31 → 3.0.0-beta.33
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 +12 -0
- package/dist/index.d.mts +41 -2
- package/dist/index.d.ts +41 -2
- package/dist/index.js +58 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +51 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +51 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.33
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0e38a79: support ANTHROPIC_BASE_URL
|
|
8
|
+
|
|
9
|
+
## 3.0.0-beta.32
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- f4db7b5: feat(provider/anthropic): expose container from response in provider metadata
|
|
14
|
+
|
|
3
15
|
## 3.0.0-beta.31
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,47 @@
|
|
|
1
|
+
import { JSONObject, ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
1
2
|
import { z } from 'zod/v4';
|
|
2
|
-
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
|
+
interface AnthropicMessageMetadata {
|
|
7
|
+
usage: JSONObject;
|
|
8
|
+
cacheCreationInputTokens: number | null;
|
|
9
|
+
stopSequence: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Information about the container used in this request.
|
|
12
|
+
*
|
|
13
|
+
* This will be non-null if a container tool (e.g., code execution) was used.
|
|
14
|
+
* Information about the container used in the request (for the code execution tool).
|
|
15
|
+
*/
|
|
16
|
+
container: {
|
|
17
|
+
/**
|
|
18
|
+
* The time at which the container will expire (RFC3339 timestamp).
|
|
19
|
+
*/
|
|
20
|
+
expiresAt: string;
|
|
21
|
+
/**
|
|
22
|
+
* Identifier for the container used in this request.
|
|
23
|
+
*/
|
|
24
|
+
id: string;
|
|
25
|
+
/**
|
|
26
|
+
* Skills loaded in the container.
|
|
27
|
+
*/
|
|
28
|
+
skills: Array<{
|
|
29
|
+
/**
|
|
30
|
+
* Type of skill: either 'anthropic' (built-in) or 'custom' (user-defined).
|
|
31
|
+
*/
|
|
32
|
+
type: 'anthropic' | 'custom';
|
|
33
|
+
/**
|
|
34
|
+
* Skill ID (1-64 characters).
|
|
35
|
+
*/
|
|
36
|
+
skillId: string;
|
|
37
|
+
/**
|
|
38
|
+
* Skill version or 'latest' for most recent version (1-64 characters).
|
|
39
|
+
*/
|
|
40
|
+
version: string;
|
|
41
|
+
}> | null;
|
|
42
|
+
} | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
6
45
|
type AnthropicMessagesModelId = 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-0' | 'claude-sonnet-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-haiku-20240307' | (string & {});
|
|
7
46
|
declare const anthropicProviderOptions: z.ZodObject<{
|
|
8
47
|
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -514,4 +553,4 @@ declare const anthropic: AnthropicProvider;
|
|
|
514
553
|
|
|
515
554
|
declare const VERSION: string;
|
|
516
555
|
|
|
517
|
-
export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };
|
|
556
|
+
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,47 @@
|
|
|
1
|
+
import { JSONObject, ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
1
2
|
import { z } from 'zod/v4';
|
|
2
|
-
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
|
+
interface AnthropicMessageMetadata {
|
|
7
|
+
usage: JSONObject;
|
|
8
|
+
cacheCreationInputTokens: number | null;
|
|
9
|
+
stopSequence: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Information about the container used in this request.
|
|
12
|
+
*
|
|
13
|
+
* This will be non-null if a container tool (e.g., code execution) was used.
|
|
14
|
+
* Information about the container used in the request (for the code execution tool).
|
|
15
|
+
*/
|
|
16
|
+
container: {
|
|
17
|
+
/**
|
|
18
|
+
* The time at which the container will expire (RFC3339 timestamp).
|
|
19
|
+
*/
|
|
20
|
+
expiresAt: string;
|
|
21
|
+
/**
|
|
22
|
+
* Identifier for the container used in this request.
|
|
23
|
+
*/
|
|
24
|
+
id: string;
|
|
25
|
+
/**
|
|
26
|
+
* Skills loaded in the container.
|
|
27
|
+
*/
|
|
28
|
+
skills: Array<{
|
|
29
|
+
/**
|
|
30
|
+
* Type of skill: either 'anthropic' (built-in) or 'custom' (user-defined).
|
|
31
|
+
*/
|
|
32
|
+
type: 'anthropic' | 'custom';
|
|
33
|
+
/**
|
|
34
|
+
* Skill ID (1-64 characters).
|
|
35
|
+
*/
|
|
36
|
+
skillId: string;
|
|
37
|
+
/**
|
|
38
|
+
* Skill version or 'latest' for most recent version (1-64 characters).
|
|
39
|
+
*/
|
|
40
|
+
version: string;
|
|
41
|
+
}> | null;
|
|
42
|
+
} | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
6
45
|
type AnthropicMessagesModelId = 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-0' | 'claude-sonnet-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-haiku-20240307' | (string & {});
|
|
7
46
|
declare const anthropicProviderOptions: z.ZodObject<{
|
|
8
47
|
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -514,4 +553,4 @@ declare const anthropic: AnthropicProvider;
|
|
|
514
553
|
|
|
515
554
|
declare const VERSION: string;
|
|
516
555
|
|
|
517
|
-
export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };
|
|
556
|
+
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
31
31
|
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
33
|
// src/version.ts
|
|
34
|
-
var VERSION = true ? "3.0.0-beta.
|
|
34
|
+
var VERSION = true ? "3.0.0-beta.33" : "0.0.0-test";
|
|
35
35
|
|
|
36
36
|
// src/anthropic-messages-language-model.ts
|
|
37
37
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -263,7 +263,18 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
263
263
|
output_tokens: import_v42.z.number(),
|
|
264
264
|
cache_creation_input_tokens: import_v42.z.number().nullish(),
|
|
265
265
|
cache_read_input_tokens: import_v42.z.number().nullish()
|
|
266
|
-
})
|
|
266
|
+
}),
|
|
267
|
+
container: import_v42.z.object({
|
|
268
|
+
expires_at: import_v42.z.string(),
|
|
269
|
+
id: import_v42.z.string(),
|
|
270
|
+
skills: import_v42.z.array(
|
|
271
|
+
import_v42.z.object({
|
|
272
|
+
type: import_v42.z.union([import_v42.z.literal("anthropic"), import_v42.z.literal("custom")]),
|
|
273
|
+
skill_id: import_v42.z.string(),
|
|
274
|
+
version: import_v42.z.string()
|
|
275
|
+
})
|
|
276
|
+
).nullish()
|
|
277
|
+
}).nullish()
|
|
267
278
|
})
|
|
268
279
|
)
|
|
269
280
|
);
|
|
@@ -511,7 +522,21 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
511
522
|
type: import_v42.z.literal("message_delta"),
|
|
512
523
|
delta: import_v42.z.object({
|
|
513
524
|
stop_reason: import_v42.z.string().nullish(),
|
|
514
|
-
stop_sequence: import_v42.z.string().nullish()
|
|
525
|
+
stop_sequence: import_v42.z.string().nullish(),
|
|
526
|
+
container: import_v42.z.object({
|
|
527
|
+
expires_at: import_v42.z.string(),
|
|
528
|
+
id: import_v42.z.string(),
|
|
529
|
+
skills: import_v42.z.array(
|
|
530
|
+
import_v42.z.object({
|
|
531
|
+
type: import_v42.z.union([
|
|
532
|
+
import_v42.z.literal("anthropic"),
|
|
533
|
+
import_v42.z.literal("custom")
|
|
534
|
+
]),
|
|
535
|
+
skill_id: import_v42.z.string(),
|
|
536
|
+
version: import_v42.z.string()
|
|
537
|
+
})
|
|
538
|
+
).nullish()
|
|
539
|
+
}).nullish()
|
|
515
540
|
}),
|
|
516
541
|
usage: import_v42.z.looseObject({
|
|
517
542
|
output_tokens: import_v42.z.number(),
|
|
@@ -2067,7 +2092,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2067
2092
|
});
|
|
2068
2093
|
}
|
|
2069
2094
|
async doGenerate(options) {
|
|
2070
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2095
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2071
2096
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
2072
2097
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2073
2098
|
const {
|
|
@@ -2350,7 +2375,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2350
2375
|
anthropic: {
|
|
2351
2376
|
usage: response.usage,
|
|
2352
2377
|
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
|
|
2353
|
-
stopSequence: (_f = response.stop_sequence) != null ? _f : null
|
|
2378
|
+
stopSequence: (_f = response.stop_sequence) != null ? _f : null,
|
|
2379
|
+
container: response.container ? {
|
|
2380
|
+
expiresAt: response.container.expires_at,
|
|
2381
|
+
id: response.container.id,
|
|
2382
|
+
skills: (_h = (_g = response.container.skills) == null ? void 0 : _g.map((skill) => ({
|
|
2383
|
+
type: skill.type,
|
|
2384
|
+
skillId: skill.skill_id,
|
|
2385
|
+
version: skill.version
|
|
2386
|
+
}))) != null ? _h : null
|
|
2387
|
+
} : null
|
|
2354
2388
|
}
|
|
2355
2389
|
}
|
|
2356
2390
|
};
|
|
@@ -2381,6 +2415,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2381
2415
|
let rawUsage = void 0;
|
|
2382
2416
|
let cacheCreationInputTokens = null;
|
|
2383
2417
|
let stopSequence = null;
|
|
2418
|
+
let container = null;
|
|
2384
2419
|
let blockType = void 0;
|
|
2385
2420
|
const generateId3 = this.generateId;
|
|
2386
2421
|
return {
|
|
@@ -2390,7 +2425,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2390
2425
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2391
2426
|
},
|
|
2392
2427
|
transform(chunk, controller) {
|
|
2393
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2428
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2394
2429
|
if (options.includeRawChunks) {
|
|
2395
2430
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2396
2431
|
}
|
|
@@ -2799,6 +2834,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2799
2834
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
2800
2835
|
});
|
|
2801
2836
|
stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
|
|
2837
|
+
container = value.delta.container != null ? {
|
|
2838
|
+
expiresAt: value.delta.container.expires_at,
|
|
2839
|
+
id: value.delta.container.id,
|
|
2840
|
+
skills: (_j = (_i = value.delta.container.skills) == null ? void 0 : _i.map((skill) => ({
|
|
2841
|
+
type: skill.type,
|
|
2842
|
+
skillId: skill.skill_id,
|
|
2843
|
+
version: skill.version
|
|
2844
|
+
}))) != null ? _j : null
|
|
2845
|
+
} : null;
|
|
2802
2846
|
rawUsage = {
|
|
2803
2847
|
...rawUsage,
|
|
2804
2848
|
...value.usage
|
|
@@ -2814,7 +2858,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2814
2858
|
anthropic: {
|
|
2815
2859
|
usage: rawUsage != null ? rawUsage : null,
|
|
2816
2860
|
cacheCreationInputTokens,
|
|
2817
|
-
stopSequence
|
|
2861
|
+
stopSequence,
|
|
2862
|
+
container
|
|
2818
2863
|
}
|
|
2819
2864
|
}
|
|
2820
2865
|
});
|
|
@@ -3218,7 +3263,12 @@ var anthropicTools = {
|
|
|
3218
3263
|
// src/anthropic-provider.ts
|
|
3219
3264
|
function createAnthropic(options = {}) {
|
|
3220
3265
|
var _a;
|
|
3221
|
-
const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(
|
|
3266
|
+
const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(
|
|
3267
|
+
(0, import_provider_utils20.loadOptionalSetting)({
|
|
3268
|
+
settingValue: options.baseURL,
|
|
3269
|
+
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
3270
|
+
})
|
|
3271
|
+
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
3222
3272
|
const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
|
|
3223
3273
|
{
|
|
3224
3274
|
"anthropic-version": "2023-06-01",
|