@ai-sdk/anthropic 3.0.63 → 3.0.65

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/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "@ai-sdk/provider-utils";
13
13
 
14
14
  // src/version.ts
15
- var VERSION = true ? "3.0.63" : "0.0.0-test";
15
+ var VERSION = true ? "3.0.65" : "0.0.0-test";
16
16
 
17
17
  // src/anthropic-messages-language-model.ts
18
18
  import {
@@ -864,6 +864,20 @@ var anthropicLanguageModelOptions = z3.object({
864
864
  type: z3.literal("ephemeral"),
865
865
  ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
866
866
  }).optional(),
867
+ /**
868
+ * Metadata to include with the request.
869
+ *
870
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
871
+ */
872
+ metadata: z3.object({
873
+ /**
874
+ * An external identifier for the user associated with the request.
875
+ *
876
+ * Should be a UUID, hash value, or other opaque identifier.
877
+ * Must not contain PII (name, email, phone number, etc.).
878
+ */
879
+ userId: z3.string().optional()
880
+ }).optional(),
867
881
  /**
868
882
  * MCP servers to be utilized in this request.
869
883
  */
@@ -2915,7 +2929,7 @@ var AnthropicMessagesLanguageModel = class {
2915
2929
  providerOptions,
2916
2930
  stream
2917
2931
  }) {
2918
- var _a, _b, _c, _d, _e, _f, _g, _h;
2932
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2919
2933
  const warnings = [];
2920
2934
  if (frequencyPenalty != null) {
2921
2935
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2972,6 +2986,7 @@ var AnthropicMessagesLanguageModel = class {
2972
2986
  supportsStructuredOutput: modelSupportsStructuredOutput,
2973
2987
  isKnownModel
2974
2988
  } = getModelCapabilities(this.modelId);
2989
+ const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2975
2990
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2976
2991
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2977
2992
  const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
@@ -3053,6 +3068,9 @@ var AnthropicMessagesLanguageModel = class {
3053
3068
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3054
3069
  cache_control: anthropicOptions.cacheControl
3055
3070
  },
3071
+ ...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
3072
+ metadata: { user_id: anthropicOptions.metadata.userId }
3073
+ },
3056
3074
  // mcp servers:
3057
3075
  ...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
3058
3076
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
@@ -3176,7 +3194,7 @@ var AnthropicMessagesLanguageModel = class {
3176
3194
  }
3177
3195
  baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
3178
3196
  } else {
3179
- if (topP != null && temperature != null) {
3197
+ if (isAnthropicModel && topP != null && temperature != null) {
3180
3198
  warnings.push({
3181
3199
  type: "unsupported",
3182
3200
  feature: "topP",
@@ -3223,7 +3241,7 @@ var AnthropicMessagesLanguageModel = class {
3223
3241
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3224
3242
  betas.add("fast-mode-2026-02-01");
3225
3243
  }
3226
- if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3244
+ if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
3227
3245
  betas.add("fine-grained-tool-streaming-2025-05-14");
3228
3246
  }
3229
3247
  const {
@@ -3262,7 +3280,7 @@ var AnthropicMessagesLanguageModel = class {
3262
3280
  ...betas,
3263
3281
  ...toolsBetas,
3264
3282
  ...userSuppliedBetas,
3265
- ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3283
+ ...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
3266
3284
  ]),
3267
3285
  usesJsonResponseTool: jsonResponseTool != null,
3268
3286
  toolNameMapping,