@ai-sdk/anthropic 3.0.99 → 3.0.101

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.
@@ -46,6 +46,18 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
46
46
  doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
47
47
  doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
48
48
  }
49
+ /**
50
+ * Returns the capabilities of a Claude model that are used for defaults and feature selection.
51
+ *
52
+ * @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
53
+ * @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
54
+ */
55
+ declare function getModelCapabilities(modelId: string): {
56
+ maxOutputTokens: number;
57
+ supportsStructuredOutput: boolean;
58
+ rejectsSamplingParameters: boolean;
59
+ isKnownModel: boolean;
60
+ };
49
61
 
50
62
  declare const anthropicTools: {
51
63
  /**
@@ -1043,4 +1055,4 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
1043
1055
  */
1044
1056
  declare function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7;
1045
1057
 
1046
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools, sanitizeJsonSchema };
1058
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools, sanitizeJsonSchema };
@@ -46,6 +46,18 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
46
46
  doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
47
47
  doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
48
48
  }
49
+ /**
50
+ * Returns the capabilities of a Claude model that are used for defaults and feature selection.
51
+ *
52
+ * @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
53
+ * @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
54
+ */
55
+ declare function getModelCapabilities(modelId: string): {
56
+ maxOutputTokens: number;
57
+ supportsStructuredOutput: boolean;
58
+ rejectsSamplingParameters: boolean;
59
+ isKnownModel: boolean;
60
+ };
49
61
 
50
62
  declare const anthropicTools: {
51
63
  /**
@@ -1043,4 +1055,4 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
1043
1055
  */
1044
1056
  declare function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7;
1045
1057
 
1046
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools, sanitizeJsonSchema };
1058
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools, sanitizeJsonSchema };
@@ -22,6 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AnthropicMessagesLanguageModel: () => AnthropicMessagesLanguageModel,
24
24
  anthropicTools: () => anthropicTools,
25
+ getModelCapabilities: () => getModelCapabilities,
25
26
  prepareTools: () => prepareTools,
26
27
  sanitizeJsonSchema: () => sanitizeJsonSchema
27
28
  });
@@ -3389,6 +3390,13 @@ var AnthropicMessagesLanguageModel = class {
3389
3390
  rejectsSamplingParameters,
3390
3391
  isKnownModel
3391
3392
  } = getModelCapabilities(this.modelId);
3393
+ if (!isKnownModel && maxOutputTokens == null) {
3394
+ warnings.push({
3395
+ type: "compatibility",
3396
+ feature: "maxOutputTokens",
3397
+ details: `The model "${this.modelId}" is unknown. The max output tokens have been limited to ${maxOutputTokensForModel}. Set maxOutputTokens explicitly to override this limit.`
3398
+ });
3399
+ }
3392
3400
  if (rejectsSamplingParameters) {
3393
3401
  if (temperature != null) {
3394
3402
  warnings.push({
@@ -3415,7 +3423,7 @@ var AnthropicMessagesLanguageModel = class {
3415
3423
  topP = void 0;
3416
3424
  }
3417
3425
  }
3418
- const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
3426
+ const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
3419
3427
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
3420
3428
  const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
3421
3429
  const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
@@ -5233,6 +5241,20 @@ function getModelCapabilities(modelId) {
5233
5241
  rejectsSamplingParameters: false,
5234
5242
  isKnownModel: true
5235
5243
  };
5244
+ } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
5245
+ return {
5246
+ maxOutputTokens: 4096,
5247
+ supportsStructuredOutput: false,
5248
+ rejectsSamplingParameters: false,
5249
+ isKnownModel: false
5250
+ };
5251
+ } else if (modelId.includes("claude-")) {
5252
+ return {
5253
+ maxOutputTokens: 128e3,
5254
+ supportsStructuredOutput: true,
5255
+ rejectsSamplingParameters: true,
5256
+ isKnownModel: false
5257
+ };
5236
5258
  } else {
5237
5259
  return {
5238
5260
  maxOutputTokens: 4096,
@@ -5823,6 +5845,7 @@ var anthropicTools = {
5823
5845
  0 && (module.exports = {
5824
5846
  AnthropicMessagesLanguageModel,
5825
5847
  anthropicTools,
5848
+ getModelCapabilities,
5826
5849
  prepareTools,
5827
5850
  sanitizeJsonSchema
5828
5851
  });