@ai-sdk/anthropic 2.0.0-canary.1 → 2.0.0-canary.10

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 CHANGED
@@ -1,5 +1,103 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.0-canary.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e86be6f]
8
+ - @ai-sdk/provider@2.0.0-canary.9
9
+ - @ai-sdk/provider-utils@3.0.0-canary.10
10
+
11
+ ## 2.0.0-canary.9
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [95857aa]
16
+ - Updated dependencies [7ea4132]
17
+ - @ai-sdk/provider@2.0.0-canary.8
18
+ - @ai-sdk/provider-utils@3.0.0-canary.9
19
+
20
+ ## 2.0.0-canary.8
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [5d142ab]
25
+ - Updated dependencies [b6b43c7]
26
+ - Updated dependencies [8aa9e20]
27
+ - Updated dependencies [3795467]
28
+ - @ai-sdk/provider-utils@3.0.0-canary.8
29
+ - @ai-sdk/provider@2.0.0-canary.7
30
+
31
+ ## 2.0.0-canary.7
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [26735b5]
36
+ - Updated dependencies [443d8ec]
37
+ - Updated dependencies [14c9410]
38
+ - Updated dependencies [d9c98f4]
39
+ - Updated dependencies [c4a2fec]
40
+ - Updated dependencies [0054544]
41
+ - Updated dependencies [9e9c809]
42
+ - Updated dependencies [32831c6]
43
+ - Updated dependencies [d0f9495]
44
+ - Updated dependencies [fd65bc6]
45
+ - Updated dependencies [393138b]
46
+ - Updated dependencies [7182d14]
47
+ - @ai-sdk/provider@2.0.0-canary.6
48
+ - @ai-sdk/provider-utils@3.0.0-canary.7
49
+
50
+ ## 2.0.0-canary.6
51
+
52
+ ### Patch Changes
53
+
54
+ - f10304b: feat(tool-calling): don't require the user to have to pass parameters
55
+ - Updated dependencies [411e483]
56
+ - Updated dependencies [79457bd]
57
+ - Updated dependencies [ad80501]
58
+ - Updated dependencies [1766ede]
59
+ - Updated dependencies [f10304b]
60
+ - @ai-sdk/provider@2.0.0-canary.5
61
+ - @ai-sdk/provider-utils@3.0.0-canary.6
62
+
63
+ ## 2.0.0-canary.5
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [6f6bb89]
68
+ - @ai-sdk/provider@2.0.0-canary.4
69
+ - @ai-sdk/provider-utils@3.0.0-canary.5
70
+
71
+ ## 2.0.0-canary.4
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [d1a1aa1]
76
+ - @ai-sdk/provider@2.0.0-canary.3
77
+ - @ai-sdk/provider-utils@3.0.0-canary.4
78
+
79
+ ## 2.0.0-canary.3
80
+
81
+ ### Patch Changes
82
+
83
+ - 61ab528: Add support for URL-based PDF documents in the Anthropic provider
84
+ - Updated dependencies [a166433]
85
+ - Updated dependencies [abf9a79]
86
+ - Updated dependencies [9f95b35]
87
+ - Updated dependencies [0a87932]
88
+ - Updated dependencies [6dc848c]
89
+ - @ai-sdk/provider-utils@3.0.0-canary.3
90
+ - @ai-sdk/provider@2.0.0-canary.2
91
+
92
+ ## 2.0.0-canary.2
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [c57e248]
97
+ - Updated dependencies [33f4a6a]
98
+ - @ai-sdk/provider@2.0.0-canary.1
99
+ - @ai-sdk/provider-utils@3.0.0-canary.2
100
+
3
101
  ## 2.0.0-canary.1
4
102
 
5
103
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -54,7 +54,7 @@ type ToolResultContent = Array<{
54
54
  } | {
55
55
  type: 'image';
56
56
  data: string;
57
- mimeType?: string;
57
+ mediaType?: string;
58
58
  }>;
59
59
  declare const Bash20241022Parameters: z.ZodObject<{
60
60
  command: z.ZodString;
package/dist/index.d.ts CHANGED
@@ -54,7 +54,7 @@ type ToolResultContent = Array<{
54
54
  } | {
55
55
  type: 'image';
56
56
  data: string;
57
- mimeType?: string;
57
+ mediaType?: string;
58
58
  }>;
59
59
  declare const Bash20241022Parameters: z.ZodObject<{
60
60
  command: z.ZodString;
package/dist/index.js CHANGED
@@ -51,13 +51,15 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
51
51
 
52
52
  // src/anthropic-prepare-tools.ts
53
53
  var import_provider = require("@ai-sdk/provider");
54
- function prepareTools(mode) {
55
- var _a;
56
- const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
54
+ function prepareTools({
55
+ tools,
56
+ toolChoice
57
+ }) {
58
+ tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
57
59
  const toolWarnings = [];
58
60
  const betas = /* @__PURE__ */ new Set();
59
61
  if (tools == null) {
60
- return { tools: void 0, tool_choice: void 0, toolWarnings, betas };
62
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
61
63
  }
62
64
  const anthropicTools2 = [];
63
65
  for (const tool of tools) {
@@ -129,11 +131,10 @@ function prepareTools(mode) {
129
131
  break;
130
132
  }
131
133
  }
132
- const toolChoice = mode.toolChoice;
133
134
  if (toolChoice == null) {
134
135
  return {
135
136
  tools: anthropicTools2,
136
- tool_choice: void 0,
137
+ toolChoice: void 0,
137
138
  toolWarnings,
138
139
  betas
139
140
  };
@@ -143,30 +144,30 @@ function prepareTools(mode) {
143
144
  case "auto":
144
145
  return {
145
146
  tools: anthropicTools2,
146
- tool_choice: { type: "auto" },
147
+ toolChoice: { type: "auto" },
147
148
  toolWarnings,
148
149
  betas
149
150
  };
150
151
  case "required":
151
152
  return {
152
153
  tools: anthropicTools2,
153
- tool_choice: { type: "any" },
154
+ toolChoice: { type: "any" },
154
155
  toolWarnings,
155
156
  betas
156
157
  };
157
158
  case "none":
158
- return { tools: void 0, tool_choice: void 0, toolWarnings, betas };
159
+ return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
159
160
  case "tool":
160
161
  return {
161
162
  tools: anthropicTools2,
162
- tool_choice: { type: "tool", name: toolChoice.toolName },
163
+ toolChoice: { type: "tool", name: toolChoice.toolName },
163
164
  toolWarnings,
164
165
  betas
165
166
  };
166
167
  default: {
167
168
  const _exhaustiveCheck = type;
168
169
  throw new import_provider.UnsupportedFunctionalityError({
169
- functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
170
+ functionality: `tool choice type: ${_exhaustiveCheck}`
170
171
  });
171
172
  }
172
173
  }
@@ -180,7 +181,7 @@ function convertToAnthropicMessagesPrompt({
180
181
  sendReasoning,
181
182
  warnings
182
183
  }) {
183
- var _a, _b, _c, _d;
184
+ var _a, _b, _c;
184
185
  const betas = /* @__PURE__ */ new Set();
185
186
  const blocks = groupIntoBlocks(prompt);
186
187
  let system = void 0;
@@ -202,10 +203,10 @@ function convertToAnthropicMessagesPrompt({
202
203
  functionality: "Multiple system messages that are separated by user/assistant messages"
203
204
  });
204
205
  }
205
- system = block.messages.map(({ content, providerMetadata }) => ({
206
+ system = block.messages.map(({ content, providerOptions }) => ({
206
207
  type: "text",
207
208
  text: content,
208
- cache_control: getCacheControl(providerMetadata)
209
+ cache_control: getCacheControl(providerOptions)
209
210
  }));
210
211
  break;
211
212
  }
@@ -218,7 +219,7 @@ function convertToAnthropicMessagesPrompt({
218
219
  for (let j = 0; j < content.length; j++) {
219
220
  const part = content[j];
220
221
  const isLastPart = j === content.length - 1;
221
- const cacheControl = (_a = getCacheControl(part.providerMetadata)) != null ? _a : isLastPart ? getCacheControl(message.providerMetadata) : void 0;
222
+ const cacheControl = (_a = getCacheControl(part.providerOptions)) != null ? _a : isLastPart ? getCacheControl(message.providerOptions) : void 0;
222
223
  switch (part.type) {
223
224
  case "text": {
224
225
  anthropicContent.push({
@@ -228,42 +229,39 @@ function convertToAnthropicMessagesPrompt({
228
229
  });
229
230
  break;
230
231
  }
231
- case "image": {
232
- anthropicContent.push({
233
- type: "image",
234
- source: part.image instanceof URL ? {
235
- type: "url",
236
- url: part.image.toString()
237
- } : {
238
- type: "base64",
239
- media_type: (_b = part.mimeType) != null ? _b : "image/jpeg",
240
- data: (0, import_provider_utils2.convertUint8ArrayToBase64)(part.image)
241
- },
242
- cache_control: cacheControl
243
- });
244
- break;
245
- }
246
232
  case "file": {
247
- if (part.data instanceof URL) {
248
- throw new import_provider2.UnsupportedFunctionalityError({
249
- functionality: "Image URLs in user messages"
233
+ if (part.mediaType.startsWith("image/")) {
234
+ anthropicContent.push({
235
+ type: "image",
236
+ source: part.data instanceof URL ? {
237
+ type: "url",
238
+ url: part.data.toString()
239
+ } : {
240
+ type: "base64",
241
+ media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
242
+ data: (0, import_provider_utils2.convertToBase64)(part.data)
243
+ },
244
+ cache_control: cacheControl
250
245
  });
251
- }
252
- if (part.mimeType !== "application/pdf") {
246
+ } else if (part.mediaType === "application/pdf") {
247
+ betas.add("pdfs-2024-09-25");
248
+ anthropicContent.push({
249
+ type: "document",
250
+ source: part.data instanceof URL ? {
251
+ type: "url",
252
+ url: part.data.toString()
253
+ } : {
254
+ type: "base64",
255
+ media_type: "application/pdf",
256
+ data: (0, import_provider_utils2.convertToBase64)(part.data)
257
+ },
258
+ cache_control: cacheControl
259
+ });
260
+ } else {
253
261
  throw new import_provider2.UnsupportedFunctionalityError({
254
- functionality: "Non-PDF files in user messages"
262
+ functionality: `media type: ${part.mediaType}`
255
263
  });
256
264
  }
257
- betas.add("pdfs-2024-09-25");
258
- anthropicContent.push({
259
- type: "document",
260
- source: {
261
- type: "base64",
262
- media_type: "application/pdf",
263
- data: part.data
264
- },
265
- cache_control: cacheControl
266
- });
267
265
  break;
268
266
  }
269
267
  }
@@ -274,7 +272,7 @@ function convertToAnthropicMessagesPrompt({
274
272
  for (let i2 = 0; i2 < content.length; i2++) {
275
273
  const part = content[i2];
276
274
  const isLastPart = i2 === content.length - 1;
277
- const cacheControl = (_c = getCacheControl(part.providerMetadata)) != null ? _c : isLastPart ? getCacheControl(message.providerMetadata) : void 0;
275
+ const cacheControl = (_b = getCacheControl(part.providerOptions)) != null ? _b : isLastPart ? getCacheControl(message.providerOptions) : void 0;
278
276
  const toolResultContent = part.content != null ? part.content.map((part2) => {
279
277
  var _a2;
280
278
  switch (part2.type) {
@@ -289,7 +287,7 @@ function convertToAnthropicMessagesPrompt({
289
287
  type: "image",
290
288
  source: {
291
289
  type: "base64",
292
- media_type: (_a2 = part2.mimeType) != null ? _a2 : "image/jpeg",
290
+ media_type: (_a2 = part2.mediaType) != null ? _a2 : "image/jpeg",
293
291
  data: part2.data
294
292
  },
295
293
  cache_control: void 0
@@ -324,7 +322,7 @@ function convertToAnthropicMessagesPrompt({
324
322
  for (let k = 0; k < content.length; k++) {
325
323
  const part = content[k];
326
324
  const isLastContentPart = k === content.length - 1;
327
- const cacheControl = (_d = getCacheControl(part.providerMetadata)) != null ? _d : isLastContentPart ? getCacheControl(message.providerMetadata) : void 0;
325
+ const cacheControl = (_c = getCacheControl(part.providerOptions)) != null ? _c : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
328
326
  switch (part.type) {
329
327
  case "text": {
330
328
  anthropicContent.push({
@@ -381,7 +379,7 @@ function convertToAnthropicMessagesPrompt({
381
379
  }
382
380
  default: {
383
381
  const _exhaustiveCheck = type;
384
- throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
382
+ throw new Error(`content type: ${_exhaustiveCheck}`);
385
383
  }
386
384
  }
387
385
  }
@@ -456,21 +454,23 @@ function mapAnthropicStopReason(finishReason) {
456
454
  var AnthropicMessagesLanguageModel = class {
457
455
  constructor(modelId, settings, config) {
458
456
  this.specificationVersion = "v2";
459
- this.defaultObjectGenerationMode = "tool";
460
457
  this.modelId = modelId;
461
458
  this.settings = settings;
462
459
  this.config = config;
463
460
  }
461
+ supportsUrl(url) {
462
+ return url.protocol === "https:";
463
+ }
464
464
  get provider() {
465
465
  return this.config.provider;
466
466
  }
467
- get supportsImageUrls() {
468
- return this.config.supportsImageUrls;
467
+ async getSupportedUrls() {
468
+ var _a, _b, _c;
469
+ return (_c = (_b = (_a = this.config).getSupportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
469
470
  }
470
471
  async getArgs({
471
- mode,
472
472
  prompt,
473
- maxTokens = 4096,
473
+ maxOutputTokens = 4096,
474
474
  // 4096: max model output tokens TODO update default in v5
475
475
  temperature,
476
476
  topP,
@@ -480,10 +480,11 @@ var AnthropicMessagesLanguageModel = class {
480
480
  stopSequences,
481
481
  responseFormat,
482
482
  seed,
483
- providerMetadata: providerOptions
483
+ tools,
484
+ toolChoice,
485
+ providerOptions
484
486
  }) {
485
487
  var _a, _b, _c;
486
- const type = mode.type;
487
488
  const warnings = [];
488
489
  if (frequencyPenalty != null) {
489
490
  warnings.push({
@@ -526,7 +527,7 @@ var AnthropicMessagesLanguageModel = class {
526
527
  // model id:
527
528
  model: this.modelId,
528
529
  // standardized settings:
529
- max_tokens: maxTokens,
530
+ max_tokens: maxOutputTokens,
530
531
  temperature,
531
532
  top_k: topK,
532
533
  top_p: topP,
@@ -569,44 +570,23 @@ var AnthropicMessagesLanguageModel = class {
569
570
  details: "topP is not supported when thinking is enabled"
570
571
  });
571
572
  }
572
- baseArgs.max_tokens = maxTokens + thinkingBudget;
573
- }
574
- switch (type) {
575
- case "regular": {
576
- const {
577
- tools,
578
- tool_choice,
579
- toolWarnings,
580
- betas: toolsBetas
581
- } = prepareTools(mode);
582
- return {
583
- args: { ...baseArgs, tools, tool_choice },
584
- warnings: [...warnings, ...toolWarnings],
585
- betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas])
586
- };
587
- }
588
- case "object-json": {
589
- throw new import_provider3.UnsupportedFunctionalityError({
590
- functionality: "json-mode object generation"
591
- });
592
- }
593
- case "object-tool": {
594
- const { name, description, parameters } = mode.tool;
595
- return {
596
- args: {
597
- ...baseArgs,
598
- tools: [{ name, description, input_schema: parameters }],
599
- tool_choice: { type: "tool", name }
600
- },
601
- warnings,
602
- betas: messagesBetas
603
- };
604
- }
605
- default: {
606
- const _exhaustiveCheck = type;
607
- throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
608
- }
573
+ baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
609
574
  }
575
+ const {
576
+ tools: anthropicTools2,
577
+ toolChoice: anthropicToolChoice,
578
+ toolWarnings,
579
+ betas: toolsBetas
580
+ } = prepareTools({ tools, toolChoice });
581
+ return {
582
+ args: {
583
+ ...baseArgs,
584
+ tools: anthropicTools2,
585
+ tool_choice: anthropicToolChoice
586
+ },
587
+ warnings: [...warnings, ...toolWarnings],
588
+ betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas])
589
+ };
610
590
  }
611
591
  async getHeaders({
612
592
  betas,
@@ -644,56 +624,59 @@ var AnthropicMessagesLanguageModel = class {
644
624
  abortSignal: options.abortSignal,
645
625
  fetch: this.config.fetch
646
626
  });
647
- const { messages: rawPrompt, ...rawSettings } = args;
648
- let text = "";
649
- for (const content of response.content) {
650
- if (content.type === "text") {
651
- text += content.text;
652
- }
653
- }
654
- let toolCalls = void 0;
655
- if (response.content.some((content) => content.type === "tool_use")) {
656
- toolCalls = [];
657
- for (const content of response.content) {
658
- if (content.type === "tool_use") {
659
- toolCalls.push({
627
+ const content = [];
628
+ for (const part of response.content) {
629
+ switch (part.type) {
630
+ case "text": {
631
+ content.push({ type: "text", text: part.text });
632
+ break;
633
+ }
634
+ case "thinking": {
635
+ content.push({
636
+ type: "reasoning",
637
+ reasoningType: "text",
638
+ text: part.thinking
639
+ });
640
+ content.push({
641
+ type: "reasoning",
642
+ reasoningType: "signature",
643
+ signature: part.signature
644
+ });
645
+ break;
646
+ }
647
+ case "redacted_thinking": {
648
+ content.push({
649
+ type: "reasoning",
650
+ reasoningType: "redacted",
651
+ data: part.data
652
+ });
653
+ break;
654
+ }
655
+ case "tool_use": {
656
+ content.push({
657
+ type: "tool-call",
660
658
  toolCallType: "function",
661
- toolCallId: content.id,
662
- toolName: content.name,
663
- args: JSON.stringify(content.input)
659
+ toolCallId: part.id,
660
+ toolName: part.name,
661
+ args: JSON.stringify(part.input)
664
662
  });
663
+ break;
665
664
  }
666
665
  }
667
666
  }
668
- const reasoning = response.content.filter(
669
- (content) => content.type === "redacted_thinking" || content.type === "thinking"
670
- ).map(
671
- (content) => content.type === "thinking" ? {
672
- type: "text",
673
- text: content.thinking,
674
- signature: content.signature
675
- } : {
676
- type: "redacted",
677
- data: content.data
678
- }
679
- );
680
667
  return {
681
- text,
682
- reasoning: reasoning.length > 0 ? reasoning : void 0,
683
- toolCalls,
668
+ content,
684
669
  finishReason: mapAnthropicStopReason(response.stop_reason),
685
670
  usage: {
686
- promptTokens: response.usage.input_tokens,
687
- completionTokens: response.usage.output_tokens
688
- },
689
- rawCall: { rawPrompt, rawSettings },
690
- rawResponse: {
691
- headers: responseHeaders,
692
- body: rawResponse
671
+ inputTokens: response.usage.input_tokens,
672
+ outputTokens: response.usage.output_tokens
693
673
  },
674
+ request: { body: args },
694
675
  response: {
695
676
  id: (_a = response.id) != null ? _a : void 0,
696
- modelId: (_b = response.model) != null ? _b : void 0
677
+ modelId: (_b = response.model) != null ? _b : void 0,
678
+ headers: responseHeaders,
679
+ body: rawResponse
697
680
  },
698
681
  warnings,
699
682
  providerMetadata: {
@@ -701,8 +684,7 @@ var AnthropicMessagesLanguageModel = class {
701
684
  cacheCreationInputTokens: (_c = response.usage.cache_creation_input_tokens) != null ? _c : null,
702
685
  cacheReadInputTokens: (_d = response.usage.cache_read_input_tokens) != null ? _d : null
703
686
  }
704
- },
705
- request: { body: JSON.stringify(args) }
687
+ }
706
688
  };
707
689
  }
708
690
  async doStream(options) {
@@ -719,11 +701,10 @@ var AnthropicMessagesLanguageModel = class {
719
701
  abortSignal: options.abortSignal,
720
702
  fetch: this.config.fetch
721
703
  });
722
- const { messages: rawPrompt, ...rawSettings } = args;
723
704
  let finishReason = "unknown";
724
705
  const usage = {
725
- promptTokens: Number.NaN,
726
- completionTokens: Number.NaN
706
+ inputTokens: void 0,
707
+ outputTokens: void 0
727
708
  };
728
709
  const toolCallContentBlocks = {};
729
710
  let providerMetadata = void 0;
@@ -731,6 +712,9 @@ var AnthropicMessagesLanguageModel = class {
731
712
  return {
732
713
  stream: response.pipeThrough(
733
714
  new TransformStream({
715
+ start(controller) {
716
+ controller.enqueue({ type: "stream-start", warnings });
717
+ },
734
718
  transform(chunk, controller) {
735
719
  var _a, _b, _c, _d;
736
720
  if (!chunk.success) {
@@ -752,7 +736,8 @@ var AnthropicMessagesLanguageModel = class {
752
736
  }
753
737
  case "redacted_thinking": {
754
738
  controller.enqueue({
755
- type: "redacted-reasoning",
739
+ type: "reasoning",
740
+ reasoningType: "redacted",
756
741
  data: value.content_block.data
757
742
  });
758
743
  return;
@@ -793,22 +778,24 @@ var AnthropicMessagesLanguageModel = class {
793
778
  switch (deltaType) {
794
779
  case "text_delta": {
795
780
  controller.enqueue({
796
- type: "text-delta",
797
- textDelta: value.delta.text
781
+ type: "text",
782
+ text: value.delta.text
798
783
  });
799
784
  return;
800
785
  }
801
786
  case "thinking_delta": {
802
787
  controller.enqueue({
803
788
  type: "reasoning",
804
- textDelta: value.delta.thinking
789
+ reasoningType: "text",
790
+ text: value.delta.thinking
805
791
  });
806
792
  return;
807
793
  }
808
794
  case "signature_delta": {
809
795
  if (blockType === "thinking") {
810
796
  controller.enqueue({
811
- type: "reasoning-signature",
797
+ type: "reasoning",
798
+ reasoningType: "signature",
812
799
  signature: value.delta.signature
813
800
  });
814
801
  }
@@ -835,8 +822,8 @@ var AnthropicMessagesLanguageModel = class {
835
822
  }
836
823
  }
837
824
  case "message_start": {
838
- usage.promptTokens = value.message.usage.input_tokens;
839
- usage.completionTokens = value.message.usage.output_tokens;
825
+ usage.inputTokens = value.message.usage.input_tokens;
826
+ usage.outputTokens = value.message.usage.output_tokens;
840
827
  providerMetadata = {
841
828
  anthropic: {
842
829
  cacheCreationInputTokens: (_a = value.message.usage.cache_creation_input_tokens) != null ? _a : null,
@@ -851,7 +838,7 @@ var AnthropicMessagesLanguageModel = class {
851
838
  return;
852
839
  }
853
840
  case "message_delta": {
854
- usage.completionTokens = value.usage.output_tokens;
841
+ usage.outputTokens = value.usage.output_tokens;
855
842
  finishReason = mapAnthropicStopReason(value.delta.stop_reason);
856
843
  return;
857
844
  }
@@ -876,10 +863,8 @@ var AnthropicMessagesLanguageModel = class {
876
863
  }
877
864
  })
878
865
  ),
879
- rawCall: { rawPrompt, rawSettings },
880
- rawResponse: { headers: responseHeaders },
881
- warnings,
882
- request: { body: JSON.stringify(body) }
866
+ request: { body },
867
+ response: { headers: responseHeaders }
883
868
  };
884
869
  }
885
870
  };
@@ -1172,7 +1157,9 @@ function createAnthropic(options = {}) {
1172
1157
  baseURL,
1173
1158
  headers: getHeaders,
1174
1159
  fetch: options.fetch,
1175
- supportsImageUrls: true
1160
+ getSupportedUrls: async () => ({
1161
+ "image/*": [/^https?:\/\/.*$/]
1162
+ })
1176
1163
  });
1177
1164
  const provider = function(modelId, settings) {
1178
1165
  if (new.target) {