@ai-sdk/anthropic 3.0.38 → 3.0.40

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.40
4
+
5
+ ### Patch Changes
6
+
7
+ - 8c2b1e1: fix(provider/anthropic): include actual raw usage data for `response.usage.raw` when streaming
8
+
9
+ ## 3.0.39
10
+
11
+ ### Patch Changes
12
+
13
+ - 0a0d29c: feat(anthropic): add support for Opus 4.6 fast mode
14
+
3
15
  ## 3.0.38
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -140,6 +140,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
140
140
  high: "high";
141
141
  max: "max";
142
142
  }>>;
143
+ speed: z.ZodOptional<z.ZodLiteral<"fast">>;
143
144
  contextManagement: z.ZodOptional<z.ZodObject<{
144
145
  edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
145
146
  type: z.ZodLiteral<"clear_tool_uses_20250919">;
package/dist/index.d.ts CHANGED
@@ -140,6 +140,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
140
140
  high: "high";
141
141
  max: "max";
142
142
  }>>;
143
+ speed: z.ZodOptional<z.ZodLiteral<"fast">>;
143
144
  contextManagement: z.ZodOptional<z.ZodObject<{
144
145
  edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
145
146
  type: z.ZodLiteral<"clear_tool_uses_20250919">;
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils23 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.38" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.40" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -826,6 +826,11 @@ var anthropicProviderOptions = import_v43.z.object({
826
826
  * @default 'high'
827
827
  */
828
828
  effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
829
+ /**
830
+ * Enable fast mode for faster inference (2.5x faster output token speeds).
831
+ * Only supported with claude-opus-4-6.
832
+ */
833
+ speed: import_v43.z.literal("fast").optional(),
829
834
  contextManagement: import_v43.z.object({
830
835
  edits: import_v43.z.array(
831
836
  import_v43.z.discriminatedUnion("type", [
@@ -1345,7 +1350,10 @@ async function prepareTools({
1345
1350
  }
1346
1351
 
1347
1352
  // src/convert-anthropic-messages-usage.ts
1348
- function convertAnthropicMessagesUsage(usage) {
1353
+ function convertAnthropicMessagesUsage({
1354
+ usage,
1355
+ rawUsage
1356
+ }) {
1349
1357
  var _a, _b;
1350
1358
  const inputTokens = usage.input_tokens;
1351
1359
  const outputTokens = usage.output_tokens;
@@ -1363,7 +1371,7 @@ function convertAnthropicMessagesUsage(usage) {
1363
1371
  text: void 0,
1364
1372
  reasoning: void 0
1365
1373
  },
1366
- raw: usage
1374
+ raw: rawUsage != null ? rawUsage : usage
1367
1375
  };
1368
1376
  }
1369
1377
 
@@ -2571,6 +2579,9 @@ var AnthropicMessagesLanguageModel = class {
2571
2579
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
2572
2580
  output_config: { effort: anthropicOptions.effort }
2573
2581
  },
2582
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
2583
+ speed: anthropicOptions.speed
2584
+ },
2574
2585
  // structured output:
2575
2586
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2576
2587
  output_format: {
@@ -2729,6 +2740,9 @@ var AnthropicMessagesLanguageModel = class {
2729
2740
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
2730
2741
  betas.add("effort-2025-11-24");
2731
2742
  }
2743
+ if (anthropicOptions == null ? void 0 : anthropicOptions.speed) {
2744
+ betas.add("fast-mode-2026-02-01");
2745
+ }
2732
2746
  if (stream && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _f : true)) {
2733
2747
  betas.add("fine-grained-tool-streaming-2025-05-14");
2734
2748
  }
@@ -3175,7 +3189,7 @@ var AnthropicMessagesLanguageModel = class {
3175
3189
  }),
3176
3190
  raw: (_d = response.stop_reason) != null ? _d : void 0
3177
3191
  },
3178
- usage: convertAnthropicMessagesUsage(response.usage),
3192
+ usage: convertAnthropicMessagesUsage({ usage: response.usage }),
3179
3193
  request: { body: args },
3180
3194
  response: {
3181
3195
  id: (_e = response.id) != null ? _e : void 0,
@@ -3886,7 +3900,7 @@ var AnthropicMessagesLanguageModel = class {
3886
3900
  controller.enqueue({
3887
3901
  type: "finish",
3888
3902
  finishReason,
3889
- usage: convertAnthropicMessagesUsage(usage),
3903
+ usage: convertAnthropicMessagesUsage({ usage, rawUsage }),
3890
3904
  providerMetadata
3891
3905
  });
3892
3906
  return;