@ai-sdk/anthropic 3.0.63 → 3.0.64

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,11 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.64
4
+
5
+ ### Patch Changes
6
+
7
+ - 05b8ca2: feat (provider/anthropic): support passing metadata.user_id
8
+
3
9
  ## 3.0.63
4
10
 
5
11
  ### Patch Changes
@@ -448,13 +454,13 @@
448
454
  Before
449
455
 
450
456
  ```ts
451
- model.textEmbeddingModel('my-model-id');
457
+ model.textEmbeddingModel("my-model-id");
452
458
  ```
453
459
 
454
460
  After
455
461
 
456
462
  ```ts
457
- model.embeddingModel('my-model-id');
463
+ model.embeddingModel("my-model-id");
458
464
  ```
459
465
 
460
466
  - f33a018: chore: add model ID for Haiku 4.5
@@ -794,13 +800,13 @@
794
800
  Before
795
801
 
796
802
  ```ts
797
- model.textEmbeddingModel('my-model-id');
803
+ model.textEmbeddingModel("my-model-id");
798
804
  ```
799
805
 
800
806
  After
801
807
 
802
808
  ```ts
803
- model.embeddingModel('my-model-id');
809
+ model.embeddingModel("my-model-id");
804
810
  ```
805
811
 
806
812
  - Updated dependencies [8d9e8ad]
package/dist/index.d.mts CHANGED
@@ -149,6 +149,9 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
149
149
  type: z.ZodLiteral<"ephemeral">;
150
150
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
151
151
  }, z.core.$strip>>;
152
+ metadata: z.ZodOptional<z.ZodObject<{
153
+ userId: z.ZodOptional<z.ZodString>;
154
+ }, z.core.$strip>>;
152
155
  mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
153
156
  type: z.ZodLiteral<"url">;
154
157
  name: z.ZodString;
package/dist/index.d.ts CHANGED
@@ -149,6 +149,9 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
149
149
  type: z.ZodLiteral<"ephemeral">;
150
150
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
151
151
  }, z.core.$strip>>;
152
+ metadata: z.ZodOptional<z.ZodObject<{
153
+ userId: z.ZodOptional<z.ZodString>;
154
+ }, z.core.$strip>>;
152
155
  mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
153
156
  type: z.ZodLiteral<"url">;
154
157
  name: z.ZodString;
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.63" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.64" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -869,6 +869,20 @@ var anthropicLanguageModelOptions = import_v43.z.object({
869
869
  type: import_v43.z.literal("ephemeral"),
870
870
  ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
871
871
  }).optional(),
872
+ /**
873
+ * Metadata to include with the request.
874
+ *
875
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
876
+ */
877
+ metadata: import_v43.z.object({
878
+ /**
879
+ * An external identifier for the user associated with the request.
880
+ *
881
+ * Should be a UUID, hash value, or other opaque identifier.
882
+ * Must not contain PII (name, email, phone number, etc.).
883
+ */
884
+ userId: import_v43.z.string().optional()
885
+ }).optional(),
872
886
  /**
873
887
  * MCP servers to be utilized in this request.
874
888
  */
@@ -2878,7 +2892,7 @@ var AnthropicMessagesLanguageModel = class {
2878
2892
  providerOptions,
2879
2893
  stream
2880
2894
  }) {
2881
- var _a, _b, _c, _d, _e, _f, _g, _h;
2895
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2882
2896
  const warnings = [];
2883
2897
  if (frequencyPenalty != null) {
2884
2898
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -3016,6 +3030,9 @@ var AnthropicMessagesLanguageModel = class {
3016
3030
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3017
3031
  cache_control: anthropicOptions.cacheControl
3018
3032
  },
3033
+ ...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
3034
+ metadata: { user_id: anthropicOptions.metadata.userId }
3035
+ },
3019
3036
  // mcp servers:
3020
3037
  ...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
3021
3038
  mcp_servers: anthropicOptions.mcpServers.map((server) => ({
@@ -3186,7 +3203,7 @@ var AnthropicMessagesLanguageModel = class {
3186
3203
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3187
3204
  betas.add("fast-mode-2026-02-01");
3188
3205
  }
3189
- if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3206
+ if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
3190
3207
  betas.add("fine-grained-tool-streaming-2025-05-14");
3191
3208
  }
3192
3209
  const {
@@ -3225,7 +3242,7 @@ var AnthropicMessagesLanguageModel = class {
3225
3242
  ...betas,
3226
3243
  ...toolsBetas,
3227
3244
  ...userSuppliedBetas,
3228
- ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3245
+ ...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
3229
3246
  ]),
3230
3247
  usesJsonResponseTool: jsonResponseTool != null,
3231
3248
  toolNameMapping,