@ai-sdk/anthropic 4.0.96 → 4.0.98
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 +35 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +332 -65
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +287 -11
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +326 -66
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +292 -1
- package/package.json +3 -3
- package/src/anthropic-api.ts +24 -6
- package/src/anthropic-batch.ts +8 -0
- package/src/anthropic-error.ts +7 -0
- package/src/anthropic-language-model-options.ts +57 -7
- package/src/anthropic-language-model.ts +143 -15
- package/src/anthropic-message-metadata.ts +3 -0
- package/src/anthropic-model-catalog.ts +6 -0
- package/src/anthropic-prepare-tools.ts +24 -10
- package/src/anthropic-provider.ts +2 -1
- package/src/convert-to-anthropic-prompt.ts +141 -3
- package/src/files/anthropic-files-api.ts +26 -0
- package/src/files/anthropic-files.ts +217 -0
- package/src/get-cache-control.ts +6 -1
- package/src/internal/index.ts +7 -1
- package/src/anthropic-files.ts +0 -104
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.98
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 067dd77: Refactor Amazon Bedrock model ID logic into a model catalog that declares capabilities and provider options, and generate provider capability documentation from it. Export the Anthropic catalog capability helper under its compatibility name for Bedrock to reuse. Request behavior is unchanged.
|
|
8
|
+
- 25240d9: Refactor Anthropic AWS model ID logic into a model catalog that declares capabilities and provider options, and generate provider capability documentation from it. Export Anthropic catalog metadata internally for Anthropic AWS to reuse. Request behavior is unchanged.
|
|
9
|
+
- 457dc40: feat(anthropic): support adding tools by value in mid-conversation `toolChanges` (`inline-tools-2026-09-15`)
|
|
10
|
+
- 6b101ac: Add support for creating and continuing Anthropic message threads, including automatic beta headers and thread error details for application-managed recovery.
|
|
11
|
+
|
|
12
|
+
## 4.0.97
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- fd7e8a7: Preserve the order of text and complete function calls in streamed Google responses, including standalone thought signatures on empty text or reasoning parts.
|
|
17
|
+
|
|
18
|
+
Keep provider metadata on empty text parts when converting results to response messages so it can be passed back in subsequent requests.
|
|
19
|
+
|
|
20
|
+
Omit foreign-provider empty signature text when replaying history through Anthropic or Bedrock, preserving Bedrock’s existing native reasoning-history handling.
|
|
21
|
+
|
|
22
|
+
- 8291ccf: Add MiniMax `serviceTier` support for `standard` and `priority` admission. Omit tiers belonging to another known provider with an unsupported-setting warning instead of forwarding incompatible values. Expose the applied `serviceTier`, when returned, in Anthropic-compatible generation, stream and batch metadata without changing existing metadata construction types.
|
|
23
|
+
- 9754014: Add typed streaming heartbeat parts. Anthropic emits them only with `includePings: true` (disabled by default), without requiring raw chunks. Core forwards pings through stream retries without storing them as generated content or sending them to UI message streams. Consumers with exhaustive stream-part switches must handle the new `ping` union variant when upgrading, even when the opt-in is disabled. Typed pings do not flush partial words during stream smoothing.
|
|
24
|
+
- 4b8f00e: Add a `supportsNativeStructuredOutput` opt-in to the Vertex Anthropic provider so `auto` can use native structured output for Claude 4.5 and newer when enabled by Google Cloud policy. Keep tool emulation as the default and avoid adding the structured-output beta header for providers without strict tool support.
|
|
25
|
+
- 8b11ff6: Support deleting files, retrieving metadata, and streaming downloads of generated files through the Anthropic Files API. Metadata reads and uploads expose consistent media type, size, creation time, expiration, and provider metadata when available. Downloads preserve Anthropic’s restriction to files generated by tools or skills.
|
|
26
|
+
- Updated dependencies [36802d4]
|
|
27
|
+
- Updated dependencies [e0143b0]
|
|
28
|
+
- Updated dependencies [934100c]
|
|
29
|
+
- Updated dependencies [892af4d]
|
|
30
|
+
- Updated dependencies [89aff56]
|
|
31
|
+
- Updated dependencies [41465fd]
|
|
32
|
+
- Updated dependencies [9754014]
|
|
33
|
+
- Updated dependencies [4bb73b0]
|
|
34
|
+
- Updated dependencies [2e44144]
|
|
35
|
+
- @ai-sdk/provider@4.0.36
|
|
36
|
+
- @ai-sdk/provider-utils@5.0.75
|
|
37
|
+
|
|
3
38
|
## 4.0.96
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -280,6 +280,7 @@ declare const anthropicResponseSchema: import("@ai-sdk/provider-utils").LazySche
|
|
|
280
280
|
[x: string]: unknown;
|
|
281
281
|
input_tokens: number;
|
|
282
282
|
output_tokens: number;
|
|
283
|
+
service_tier?: string | null | undefined;
|
|
283
284
|
output_tokens_details?: {
|
|
284
285
|
thinking_tokens?: number | null | undefined;
|
|
285
286
|
} | null | undefined;
|
|
@@ -298,6 +299,7 @@ declare const anthropicResponseSchema: import("@ai-sdk/provider-utils").LazySche
|
|
|
298
299
|
model?: string | null | undefined;
|
|
299
300
|
stop_reason?: string | null | undefined;
|
|
300
301
|
stop_sequence?: string | null | undefined;
|
|
302
|
+
service_tier?: string | null | undefined;
|
|
301
303
|
stop_details?: {
|
|
302
304
|
type: string;
|
|
303
305
|
category?: string | null | undefined;
|
|
@@ -391,6 +393,8 @@ type AnthropicUsageIteration = {
|
|
|
391
393
|
interface AnthropicMessageMetadata {
|
|
392
394
|
usage: JSONObject;
|
|
393
395
|
stopSequence: string | null;
|
|
396
|
+
/** The tier used by the provider, when returned in the response. */
|
|
397
|
+
serviceTier?: string | null;
|
|
394
398
|
/**
|
|
395
399
|
* Input blocks that Anthropic transformed before inference. This is
|
|
396
400
|
* populated when thinking binding controls drop a mismatched thinking block.
|
|
@@ -577,6 +581,20 @@ declare const anthropicSystemMessageProviderOptions: import("@ai-sdk/provider-ut
|
|
|
577
581
|
toolChanges?: ({
|
|
578
582
|
type: "tool_addition";
|
|
579
583
|
toolName: string;
|
|
584
|
+
} | {
|
|
585
|
+
type: "tool_addition";
|
|
586
|
+
tool: {
|
|
587
|
+
[x: string]: unknown;
|
|
588
|
+
type: "function";
|
|
589
|
+
name: string;
|
|
590
|
+
inputSchema: Record<string, unknown>;
|
|
591
|
+
} | {
|
|
592
|
+
[x: string]: unknown;
|
|
593
|
+
type: "provider";
|
|
594
|
+
id: string;
|
|
595
|
+
name: string;
|
|
596
|
+
args: Record<string, unknown>;
|
|
597
|
+
};
|
|
580
598
|
} | {
|
|
581
599
|
type: "tool_removal";
|
|
582
600
|
toolName: string;
|
|
@@ -584,8 +602,15 @@ declare const anthropicSystemMessageProviderOptions: import("@ai-sdk/provider-ut
|
|
|
584
602
|
}>;
|
|
585
603
|
type AnthropicSystemMessageProviderOptions = InferSchema<typeof anthropicSystemMessageProviderOptions>;
|
|
586
604
|
declare const anthropicLanguageModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
605
|
+
thread?: {
|
|
606
|
+
type: "create";
|
|
607
|
+
} | {
|
|
608
|
+
type: "continue";
|
|
609
|
+
previousMessageId: string;
|
|
610
|
+
} | undefined;
|
|
587
611
|
sendReasoning?: boolean | undefined;
|
|
588
612
|
structuredOutputMode?: "outputFormat" | "jsonTool" | "auto" | undefined;
|
|
613
|
+
includePings?: boolean | undefined;
|
|
589
614
|
thinking?: {
|
|
590
615
|
type: "adaptive";
|
|
591
616
|
display?: "omitted" | "summarized" | "updates" | undefined;
|
|
@@ -643,7 +668,7 @@ declare const anthropicLanguageModelOptions: import("@ai-sdk/provider-utils").La
|
|
|
643
668
|
remaining?: number | undefined;
|
|
644
669
|
} | undefined;
|
|
645
670
|
speed?: "fast" | "standard" | undefined;
|
|
646
|
-
serviceTier?: "auto" | "standard_only" | undefined;
|
|
671
|
+
serviceTier?: "auto" | "standard" | "standard_only" | "priority" | undefined;
|
|
647
672
|
inferenceGeo?: "us" | "global" | undefined;
|
|
648
673
|
fallbacks?: "default" | {
|
|
649
674
|
model: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member","DecisionModelV4","BatchV4"],"sources":["../src/anthropic-api.ts","../src/anthropic-message-metadata.ts","../src/anthropic-provider-metadata.ts","../src/anthropic-language-model-options.ts","../src/anthropic-prepare-tools.ts","../src/tool/computer-toolset_20260801.ts","../src/tool/bash_20241022.ts","../src/tool/bash_20250124.ts","../src/anthropic-tools.ts","../src/anthropic-provider.ts","../src/forward-anthropic-container-id-from-last-step.ts","../src/version.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member","DecisionModelV4","BatchV4"],"sources":["../src/anthropic-api.ts","../src/anthropic-message-metadata.ts","../src/anthropic-provider-metadata.ts","../src/anthropic-language-model-options.ts","../src/anthropic-prepare-tools.ts","../src/tool/computer-toolset_20260801.ts","../src/tool/bash_20241022.ts","../src/tool/bash_20250124.ts","../src/anthropic-tools.ts","../src/anthropic-provider.ts","../src/forward-anthropic-container-id-from-last-step.ts","../src/version.ts"],"mappings":";;;;cAgtBM,sCAA8B,EAAA;;;;;;;;;;GAgBhC,EAAA,KAAA;KAEQ,2BAA2B,EAAE,MACvC,kBAAkB;cA2FP,0DAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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