@ai-sdk/anthropic 2.0.88 → 2.0.90

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.
@@ -707,4 +707,13 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
707
707
  betas: Set<string>;
708
708
  }>;
709
709
 
710
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
710
+ /**
711
+ * Removes JSON Schema keywords that Anthropic rejects in
712
+ * `output_config.format.schema`.
713
+ *
714
+ * The full original schema is still used by AI SDK result validation. This
715
+ * only relaxes the schema sent to Anthropic's constrained decoder.
716
+ */
717
+ declare function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7;
718
+
719
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools, sanitizeJsonSchema };
@@ -707,4 +707,13 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
707
707
  betas: Set<string>;
708
708
  }>;
709
709
 
710
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
710
+ /**
711
+ * Removes JSON Schema keywords that Anthropic rejects in
712
+ * `output_config.format.schema`.
713
+ *
714
+ * The full original schema is still used by AI SDK result validation. This
715
+ * only relaxes the schema sent to Anthropic's constrained decoder.
716
+ */
717
+ declare function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7;
718
+
719
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools, sanitizeJsonSchema };
@@ -22,7 +22,8 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AnthropicMessagesLanguageModel: () => AnthropicMessagesLanguageModel,
24
24
  anthropicTools: () => anthropicTools,
25
- prepareTools: () => prepareTools
25
+ prepareTools: () => prepareTools,
26
+ sanitizeJsonSchema: () => sanitizeJsonSchema
26
27
  });
27
28
  module.exports = __toCommonJS(index_exports);
28
29
 
@@ -2262,6 +2263,12 @@ var AnthropicMessagesLanguageModel = class {
2262
2263
  rejectsSamplingParameters,
2263
2264
  isKnownModel
2264
2265
  } = getModelCapabilities(this.modelId);
2266
+ if (!isKnownModel && maxOutputTokens == null) {
2267
+ warnings.push({
2268
+ type: "other",
2269
+ message: `The model "${this.modelId}" is unknown. The max output tokens have been limited to ${maxOutputTokensForModel}. Set maxOutputTokens explicitly to override this limit.`
2270
+ });
2271
+ }
2265
2272
  if (rejectsSamplingParameters) {
2266
2273
  if (temperature != null) {
2267
2274
  warnings.push({
@@ -2288,7 +2295,7 @@ var AnthropicMessagesLanguageModel = class {
2288
2295
  topP = void 0;
2289
2296
  }
2290
2297
  }
2291
- const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
2298
+ const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
2292
2299
  const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "jsonTool";
2293
2300
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2294
2301
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
@@ -3621,6 +3628,20 @@ function getModelCapabilities(modelId) {
3621
3628
  rejectsSamplingParameters: false,
3622
3629
  isKnownModel: true
3623
3630
  };
3631
+ } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
3632
+ return {
3633
+ maxOutputTokens: 4096,
3634
+ supportsStructuredOutput: false,
3635
+ rejectsSamplingParameters: false,
3636
+ isKnownModel: false
3637
+ };
3638
+ } else if (modelId.includes("claude-")) {
3639
+ return {
3640
+ maxOutputTokens: 128e3,
3641
+ supportsStructuredOutput: true,
3642
+ rejectsSamplingParameters: true,
3643
+ isKnownModel: false
3644
+ };
3624
3645
  } else {
3625
3646
  return {
3626
3647
  maxOutputTokens: 4096,
@@ -4129,6 +4150,7 @@ var anthropicTools = {
4129
4150
  0 && (module.exports = {
4130
4151
  AnthropicMessagesLanguageModel,
4131
4152
  anthropicTools,
4132
- prepareTools
4153
+ prepareTools,
4154
+ sanitizeJsonSchema
4133
4155
  });
4134
4156
  //# sourceMappingURL=index.js.map