@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.
@@ -805,6 +805,11 @@ var anthropicProviderOptions = z3.object({
805
805
  * @default 'high'
806
806
  */
807
807
  effort: z3.enum(["low", "medium", "high", "max"]).optional(),
808
+ /**
809
+ * Enable fast mode for faster inference (2.5x faster output token speeds).
810
+ * Only supported with claude-opus-4-6.
811
+ */
812
+ speed: z3.literal("fast").optional(),
808
813
  contextManagement: z3.object({
809
814
  edits: z3.array(
810
815
  z3.discriminatedUnion("type", [
@@ -1334,7 +1339,10 @@ async function prepareTools({
1334
1339
  }
1335
1340
 
1336
1341
  // src/convert-anthropic-messages-usage.ts
1337
- function convertAnthropicMessagesUsage(usage) {
1342
+ function convertAnthropicMessagesUsage({
1343
+ usage,
1344
+ rawUsage
1345
+ }) {
1338
1346
  var _a, _b;
1339
1347
  const inputTokens = usage.input_tokens;
1340
1348
  const outputTokens = usage.output_tokens;
@@ -1352,7 +1360,7 @@ function convertAnthropicMessagesUsage(usage) {
1352
1360
  text: void 0,
1353
1361
  reasoning: void 0
1354
1362
  },
1355
- raw: usage
1363
+ raw: rawUsage != null ? rawUsage : usage
1356
1364
  };
1357
1365
  }
1358
1366
 
@@ -2579,6 +2587,9 @@ var AnthropicMessagesLanguageModel = class {
2579
2587
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
2580
2588
  output_config: { effort: anthropicOptions.effort }
2581
2589
  },
2590
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
2591
+ speed: anthropicOptions.speed
2592
+ },
2582
2593
  // structured output:
2583
2594
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2584
2595
  output_format: {
@@ -2737,6 +2748,9 @@ var AnthropicMessagesLanguageModel = class {
2737
2748
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
2738
2749
  betas.add("effort-2025-11-24");
2739
2750
  }
2751
+ if (anthropicOptions == null ? void 0 : anthropicOptions.speed) {
2752
+ betas.add("fast-mode-2026-02-01");
2753
+ }
2740
2754
  if (stream && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _f : true)) {
2741
2755
  betas.add("fine-grained-tool-streaming-2025-05-14");
2742
2756
  }
@@ -3183,7 +3197,7 @@ var AnthropicMessagesLanguageModel = class {
3183
3197
  }),
3184
3198
  raw: (_d = response.stop_reason) != null ? _d : void 0
3185
3199
  },
3186
- usage: convertAnthropicMessagesUsage(response.usage),
3200
+ usage: convertAnthropicMessagesUsage({ usage: response.usage }),
3187
3201
  request: { body: args },
3188
3202
  response: {
3189
3203
  id: (_e = response.id) != null ? _e : void 0,
@@ -3894,7 +3908,7 @@ var AnthropicMessagesLanguageModel = class {
3894
3908
  controller.enqueue({
3895
3909
  type: "finish",
3896
3910
  finishReason,
3897
- usage: convertAnthropicMessagesUsage(usage),
3911
+ usage: convertAnthropicMessagesUsage({ usage, rawUsage }),
3898
3912
  providerMetadata
3899
3913
  });
3900
3914
  return;