@ai-sdk/anthropic 4.0.72 → 4.0.74

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.
@@ -33,6 +33,15 @@ const anthropic = createAnthropic({
33
33
 
34
34
  You can use the following optional settings to customize the Anthropic provider instance:
35
35
 
36
+ - **batchResultDownloads** _object_
37
+
38
+ Settings for downloading JSON Lines batch results.
39
+ - **maxLineBytes** _number_
40
+
41
+ Maximum UTF-8 bytes per row, excluding the LF delimiter. Defaults to 64 MiB
42
+ (67,108,864 bytes). Must be a positive safe integer. Oversized rows throw a
43
+ `DownloadError` and cancel the download.
44
+
36
45
  - **baseURL** _string_
37
46
 
38
47
  Use a different URL prefix for API calls, e.g. to use proxy servers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "4.0.72",
3
+ "version": "4.0.74",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,15 +35,15 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.22",
39
- "@ai-sdk/provider-utils": "5.0.54"
38
+ "@ai-sdk/provider": "4.0.24",
39
+ "@ai-sdk/provider-utils": "5.0.56"
40
40
  },
41
41
  "devDependencies": {
42
- "@ai-sdk/test-server": "2.0.3",
42
+ "@ai-sdk/test-server": "2.0.4",
43
43
  "@types/node": "22.19.19",
44
44
  "@vercel/ai-tsconfig": "0.0.0",
45
45
  "tsdown": "^0.23.0",
46
- "typescript": "5.8.3",
46
+ "typescript": "6.0.3",
47
47
  "zod": "3.25.76"
48
48
  },
49
49
  "peerDependencies": {
@@ -189,6 +189,7 @@ export class AnthropicBatch implements BatchV4<{
189
189
  provider: string;
190
190
  config: AnthropicLanguageModelConfig;
191
191
  supportedUrls: Record<string, RegExp[]>;
192
+ maxLineBytes?: number;
192
193
  },
193
194
  ) {
194
195
  this.provider = options.provider;
@@ -409,6 +410,7 @@ export class AnthropicBatch implements BatchV4<{
409
410
  failedResponseHandler: anthropicFailedResponseHandler,
410
411
  successfulResponseHandler: createJsonLinesResponseHandler(
411
412
  anthropicBatchResultLineSchema,
413
+ { maxLineBytes: this.options.maxLineBytes },
412
414
  ),
413
415
  abortSignal: options.abortSignal,
414
416
  fetch: this.options.config.fetch,
@@ -54,7 +54,9 @@ export class AnthropicFiles implements FilesV4 {
54
54
  }: FilesV4UploadFileCallOptions): Promise<FilesV4UploadFileResult> {
55
55
  const fileBytes = convertInlineFileDataToUint8Array(data);
56
56
 
57
- const blob = new Blob([fileBytes], { type: mediaType });
57
+ const blob = new Blob([fileBytes as Uint8Array<ArrayBuffer>], {
58
+ type: mediaType,
59
+ });
58
60
 
59
61
  const formData = new FormData();
60
62
  if (filename != null) {
@@ -3496,6 +3496,7 @@ function resolveAnthropicReasoningConfig({
3496
3496
  medium: 'medium' as const,
3497
3497
  high: 'high' as const,
3498
3498
  xhigh: supportsXhighEffort ? ('xhigh' as const) : ('max' as const),
3499
+ max: 'max' as const,
3499
3500
  },
3500
3501
  warnings,
3501
3502
  });
@@ -82,6 +82,12 @@ export interface AnthropicProvider extends ProviderV4 {
82
82
  }
83
83
 
84
84
  export interface AnthropicProviderSettings {
85
+ /** Settings for downloading JSON Lines batch results. */
86
+ batchResultDownloads?: {
87
+ /** Maximum UTF-8 bytes per row, excluding LF. Defaults to 64 MiB. */
88
+ maxLineBytes?: number;
89
+ };
90
+
85
91
  /**
86
92
  * Use a different URL prefix for API calls, e.g. to use proxy servers.
87
93
  * The default prefix is `https://api.anthropic.com/v1`.
@@ -187,6 +193,7 @@ export function createAnthropic(
187
193
  const createBatch = () =>
188
194
  new AnthropicBatch({
189
195
  provider: `${providerName.replace(/\.messages$/, '')}.batch`,
196
+ maxLineBytes: options.batchResultDownloads?.maxLineBytes,
190
197
  config: languageModelConfig,
191
198
  supportedUrls,
192
199
  });
@@ -89,7 +89,11 @@ export class AnthropicSkills implements SkillsV4 {
89
89
 
90
90
  for (const file of params.files) {
91
91
  const content = convertInlineFileDataToUint8Array(file.data);
92
- formData.append('files[]', new Blob([content]), file.path);
92
+ formData.append(
93
+ 'files[]',
94
+ new Blob([content as Uint8Array<ArrayBuffer>]),
95
+ file.path,
96
+ );
93
97
  }
94
98
 
95
99
  const headers = await this.getHeaders();