@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/CHANGELOG.md +18 -4
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +22 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -4
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +6 -0
- package/package.json +1 -3
- package/src/anthropic-messages-language-model.ts +9 -2
- package/src/anthropic-messages-options.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 3.0.65
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 94aed06: fix(anthropic): allow both temperature and topP for non-Anthropic models using the Anthropic-compatible API
|
|
8
|
+
|
|
9
|
+
The temperature/topP mutual exclusivity check now only applies to known Anthropic models (model IDs starting with `claude-`). Non-Anthropic models using the Anthropic-compatible API (e.g. Minimax) can now send both parameters as required by their APIs.
|
|
10
|
+
|
|
11
|
+
## 3.0.64
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 05b8ca2: feat (provider/anthropic): support passing metadata.user_id
|
|
16
|
+
|
|
3
17
|
## 3.0.63
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -448,13 +462,13 @@
|
|
|
448
462
|
Before
|
|
449
463
|
|
|
450
464
|
```ts
|
|
451
|
-
model.textEmbeddingModel(
|
|
465
|
+
model.textEmbeddingModel("my-model-id");
|
|
452
466
|
```
|
|
453
467
|
|
|
454
468
|
After
|
|
455
469
|
|
|
456
470
|
```ts
|
|
457
|
-
model.embeddingModel(
|
|
471
|
+
model.embeddingModel("my-model-id");
|
|
458
472
|
```
|
|
459
473
|
|
|
460
474
|
- f33a018: chore: add model ID for Haiku 4.5
|
|
@@ -794,13 +808,13 @@
|
|
|
794
808
|
Before
|
|
795
809
|
|
|
796
810
|
```ts
|
|
797
|
-
model.textEmbeddingModel(
|
|
811
|
+
model.textEmbeddingModel("my-model-id");
|
|
798
812
|
```
|
|
799
813
|
|
|
800
814
|
After
|
|
801
815
|
|
|
802
816
|
```ts
|
|
803
|
-
model.embeddingModel(
|
|
817
|
+
model.embeddingModel("my-model-id");
|
|
804
818
|
```
|
|
805
819
|
|
|
806
820
|
- 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.
|
|
35
|
+
var VERSION = true ? "3.0.65" : "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" });
|
|
@@ -2935,6 +2949,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2935
2949
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
2936
2950
|
isKnownModel
|
|
2937
2951
|
} = getModelCapabilities(this.modelId);
|
|
2952
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2938
2953
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2939
2954
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2940
2955
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
@@ -3016,6 +3031,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3016
3031
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3017
3032
|
cache_control: anthropicOptions.cacheControl
|
|
3018
3033
|
},
|
|
3034
|
+
...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
|
|
3035
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3036
|
+
},
|
|
3019
3037
|
// mcp servers:
|
|
3020
3038
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3021
3039
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3139,7 +3157,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3139
3157
|
}
|
|
3140
3158
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3141
3159
|
} else {
|
|
3142
|
-
if (topP != null && temperature != null) {
|
|
3160
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3143
3161
|
warnings.push({
|
|
3144
3162
|
type: "unsupported",
|
|
3145
3163
|
feature: "topP",
|
|
@@ -3186,7 +3204,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3186
3204
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3187
3205
|
betas.add("fast-mode-2026-02-01");
|
|
3188
3206
|
}
|
|
3189
|
-
if (stream && ((
|
|
3207
|
+
if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
|
|
3190
3208
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3191
3209
|
}
|
|
3192
3210
|
const {
|
|
@@ -3225,7 +3243,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3225
3243
|
...betas,
|
|
3226
3244
|
...toolsBetas,
|
|
3227
3245
|
...userSuppliedBetas,
|
|
3228
|
-
...(
|
|
3246
|
+
...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
|
|
3229
3247
|
]),
|
|
3230
3248
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3231
3249
|
toolNameMapping,
|