@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "3.0.99",
3
+ "version": "3.0.101",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -279,6 +279,17 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
279
279
  isKnownModel,
280
280
  } = getModelCapabilities(this.modelId);
281
281
 
282
+ if (!isKnownModel && maxOutputTokens == null) {
283
+ warnings.push({
284
+ type: 'compatibility',
285
+ feature: 'maxOutputTokens',
286
+ details:
287
+ `The model "${this.modelId}" is unknown. ` +
288
+ `The max output tokens have been limited to ${maxOutputTokensForModel}. ` +
289
+ `Set maxOutputTokens explicitly to override this limit.`,
290
+ });
291
+ }
292
+
282
293
  if (rejectsSamplingParameters) {
283
294
  if (temperature != null) {
284
295
  warnings.push({
@@ -306,7 +317,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
306
317
  }
307
318
  }
308
319
 
309
- const isAnthropicModel = isKnownModel || this.modelId.startsWith('claude-');
320
+ const isAnthropicModel = isKnownModel || this.modelId.includes('claude-');
310
321
 
311
322
  const supportsStructuredOutput =
312
323
  (this.config.supportsNativeStructuredOutput ?? true) &&
@@ -2587,7 +2598,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
2587
2598
  * @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
2588
2599
  * @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
2589
2600
  */
2590
- function getModelCapabilities(modelId: string): {
2601
+ export function getModelCapabilities(modelId: string): {
2591
2602
  maxOutputTokens: number;
2592
2603
  supportsStructuredOutput: boolean;
2593
2604
  rejectsSamplingParameters: boolean;
@@ -2654,6 +2665,25 @@ function getModelCapabilities(modelId: string): {
2654
2665
  rejectsSamplingParameters: false,
2655
2666
  isKnownModel: true,
2656
2667
  };
2668
+ } else if (
2669
+ /claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)
2670
+ ) {
2671
+ return {
2672
+ maxOutputTokens: 4096,
2673
+ supportsStructuredOutput: false,
2674
+ rejectsSamplingParameters: false,
2675
+ isKnownModel: false,
2676
+ };
2677
+ } else if (modelId.includes('claude-')) {
2678
+ // Known and legacy Claude families are handled above, so any remaining
2679
+ // Claude ID is assumed to be newer than the known list. Keep it unknown so
2680
+ // callers still receive the maxOutputTokens compatibility warning.
2681
+ return {
2682
+ maxOutputTokens: 128000,
2683
+ supportsStructuredOutput: true,
2684
+ rejectsSamplingParameters: true,
2685
+ isKnownModel: false,
2686
+ };
2657
2687
  } else {
2658
2688
  return {
2659
2689
  maxOutputTokens: 4096,
@@ -1,4 +1,7 @@
1
- export { AnthropicMessagesLanguageModel } from '../anthropic-messages-language-model';
1
+ export {
2
+ AnthropicMessagesLanguageModel,
3
+ getModelCapabilities,
4
+ } from '../anthropic-messages-language-model';
2
5
  export { anthropicTools } from '../anthropic-tools';
3
6
  export type { AnthropicMessagesModelId } from '../anthropic-messages-options';
4
7
  export { prepareTools } from '../anthropic-prepare-tools';