@ai-sdk/anthropic 3.0.0-beta.68 → 3.0.0-beta.70

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/dist/index.mjs CHANGED
@@ -11,18 +11,18 @@ import {
11
11
  } from "@ai-sdk/provider-utils";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = true ? "3.0.0-beta.68" : "0.0.0-test";
14
+ var VERSION = true ? "3.0.0-beta.70" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
18
- UnsupportedFunctionalityError as UnsupportedFunctionalityError3,
19
- APICallError
18
+ APICallError,
19
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError3
20
20
  } from "@ai-sdk/provider";
21
21
  import {
22
22
  combineHeaders,
23
23
  createEventSourceResponseHandler,
24
24
  createJsonResponseHandler,
25
- DelayedPromise,
25
+ createToolNameMapping,
26
26
  generateId,
27
27
  parseProviderOptions as parseProviderOptions2,
28
28
  postJsonToApi,
@@ -1258,7 +1258,8 @@ async function convertToAnthropicMessagesPrompt({
1258
1258
  prompt,
1259
1259
  sendReasoning,
1260
1260
  warnings,
1261
- cacheControlValidator
1261
+ cacheControlValidator,
1262
+ toolNameMapping
1262
1263
  }) {
1263
1264
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1264
1265
  const betas = /* @__PURE__ */ new Set();
@@ -1596,6 +1597,9 @@ async function convertToAnthropicMessagesPrompt({
1596
1597
  }
1597
1598
  case "tool-call": {
1598
1599
  if (part.providerExecuted) {
1600
+ const providerToolName = toolNameMapping.toProviderToolName(
1601
+ part.toolName
1602
+ );
1599
1603
  const isMcpToolUse = ((_h = (_g = part.providerOptions) == null ? void 0 : _g.anthropic) == null ? void 0 : _h.type) === "mcp-tool-use";
1600
1604
  if (isMcpToolUse) {
1601
1605
  mcpToolUseIds.add(part.toolCallId);
@@ -1617,7 +1621,7 @@ async function convertToAnthropicMessagesPrompt({
1617
1621
  });
1618
1622
  } else if (
1619
1623
  // code execution 20250825:
1620
- part.toolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")
1624
+ providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")
1621
1625
  ) {
1622
1626
  anthropicContent.push({
1623
1627
  type: "server_tool_use",
@@ -1627,20 +1631,22 @@ async function convertToAnthropicMessagesPrompt({
1627
1631
  input: part.input,
1628
1632
  cache_control: cacheControl
1629
1633
  });
1630
- } else if (part.toolName === "code_execution" || // code execution 20250522
1631
- part.toolName === "web_fetch" || part.toolName === "web_search") {
1632
- anthropicContent.push({
1633
- type: "server_tool_use",
1634
- id: part.toolCallId,
1635
- name: part.toolName,
1636
- input: part.input,
1637
- cache_control: cacheControl
1638
- });
1639
1634
  } else {
1640
- warnings.push({
1641
- type: "other",
1642
- message: `provider executed tool call for tool ${part.toolName} is not supported`
1643
- });
1635
+ if (providerToolName === "code_execution" || // code execution 20250522
1636
+ providerToolName === "web_fetch" || providerToolName === "web_search") {
1637
+ anthropicContent.push({
1638
+ type: "server_tool_use",
1639
+ id: part.toolCallId,
1640
+ name: providerToolName,
1641
+ input: part.input,
1642
+ cache_control: cacheControl
1643
+ });
1644
+ } else {
1645
+ warnings.push({
1646
+ type: "other",
1647
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
1648
+ });
1649
+ }
1644
1650
  }
1645
1651
  break;
1646
1652
  }
@@ -1654,6 +1660,9 @@ async function convertToAnthropicMessagesPrompt({
1654
1660
  break;
1655
1661
  }
1656
1662
  case "tool-result": {
1663
+ const providerToolName = toolNameMapping.toProviderToolName(
1664
+ part.toolName
1665
+ );
1657
1666
  if (mcpToolUseIds.has(part.toolCallId)) {
1658
1667
  const output = part.output;
1659
1668
  if (output.type !== "json" && output.type !== "error-json") {
@@ -1670,7 +1679,7 @@ async function convertToAnthropicMessagesPrompt({
1670
1679
  content: output.value,
1671
1680
  cache_control: cacheControl
1672
1681
  });
1673
- } else if (part.toolName === "code_execution") {
1682
+ } else if (providerToolName === "code_execution") {
1674
1683
  const output = part.output;
1675
1684
  if (output.type !== "json") {
1676
1685
  warnings.push({
@@ -1723,7 +1732,7 @@ async function convertToAnthropicMessagesPrompt({
1723
1732
  }
1724
1733
  break;
1725
1734
  }
1726
- if (part.toolName === "web_fetch") {
1735
+ if (providerToolName === "web_fetch") {
1727
1736
  const output = part.output;
1728
1737
  if (output.type !== "json") {
1729
1738
  warnings.push({
@@ -1758,7 +1767,7 @@ async function convertToAnthropicMessagesPrompt({
1758
1767
  });
1759
1768
  break;
1760
1769
  }
1761
- if (part.toolName === "web_search") {
1770
+ if (providerToolName === "web_search") {
1762
1771
  const output = part.output;
1763
1772
  if (output.type !== "json") {
1764
1773
  warnings.push({
@@ -1995,11 +2004,30 @@ var AnthropicMessagesLanguageModel = class {
1995
2004
  inputSchema: responseFormat.schema
1996
2005
  } : void 0;
1997
2006
  const cacheControlValidator = new CacheControlValidator();
2007
+ const toolNameMapping = createToolNameMapping({
2008
+ tools,
2009
+ providerToolNames: {
2010
+ "anthropic.code_execution_20250522": "code_execution",
2011
+ "anthropic.code_execution_20250825": "code_execution",
2012
+ "anthropic.computer_20241022": "computer",
2013
+ "anthropic.computer_20250124": "computer",
2014
+ "anthropic.text_editor_20241022": "str_replace_editor",
2015
+ "anthropic.text_editor_20250124": "str_replace_editor",
2016
+ "anthropic.text_editor_20250429": "str_replace_based_edit_tool",
2017
+ "anthropic.text_editor_20250728": "str_replace_based_edit_tool",
2018
+ "anthropic.bash_20241022": "bash",
2019
+ "anthropic.bash_20250124": "bash",
2020
+ "anthropic.memory_20250818": "memory",
2021
+ "anthropic.web_search_20250305": "web_search",
2022
+ "anthropic.web_fetch_20250910": "web_fetch"
2023
+ }
2024
+ });
1998
2025
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
1999
2026
  prompt,
2000
2027
  sendReasoning: (_b = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _b : true,
2001
2028
  warnings,
2002
- cacheControlValidator
2029
+ cacheControlValidator,
2030
+ toolNameMapping
2003
2031
  });
2004
2032
  const isThinking = ((_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type) === "enabled";
2005
2033
  const thinkingBudget = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens;
@@ -2151,7 +2179,8 @@ var AnthropicMessagesLanguageModel = class {
2151
2179
  },
2152
2180
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
2153
2181
  betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
2154
- usesJsonResponseTool: jsonResponseTool != null
2182
+ usesJsonResponseTool: jsonResponseTool != null,
2183
+ toolNameMapping
2155
2184
  };
2156
2185
  }
2157
2186
  async getHeaders({
@@ -2209,7 +2238,7 @@ var AnthropicMessagesLanguageModel = class {
2209
2238
  }
2210
2239
  async doGenerate(options) {
2211
2240
  var _a, _b, _c, _d, _e, _f, _g, _h;
2212
- const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
2241
+ const { args, warnings, betas, usesJsonResponseTool, toolNameMapping } = await this.getArgs({
2213
2242
  ...options,
2214
2243
  stream: false,
2215
2244
  userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
@@ -2300,7 +2329,7 @@ var AnthropicMessagesLanguageModel = class {
2300
2329
  content.push({
2301
2330
  type: "tool-call",
2302
2331
  toolCallId: part.id,
2303
- toolName: "code_execution",
2332
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
2304
2333
  input: JSON.stringify({ type: part.name, ...part.input }),
2305
2334
  providerExecuted: true
2306
2335
  });
@@ -2308,7 +2337,7 @@ var AnthropicMessagesLanguageModel = class {
2308
2337
  content.push({
2309
2338
  type: "tool-call",
2310
2339
  toolCallId: part.id,
2311
- toolName: part.name,
2340
+ toolName: toolNameMapping.toCustomToolName(part.name),
2312
2341
  input: JSON.stringify(part.input),
2313
2342
  providerExecuted: true
2314
2343
  });
@@ -2350,7 +2379,7 @@ var AnthropicMessagesLanguageModel = class {
2350
2379
  content.push({
2351
2380
  type: "tool-result",
2352
2381
  toolCallId: part.tool_use_id,
2353
- toolName: "web_fetch",
2382
+ toolName: toolNameMapping.toCustomToolName("web_fetch"),
2354
2383
  result: {
2355
2384
  type: "web_fetch_result",
2356
2385
  url: part.content.url,
@@ -2371,7 +2400,7 @@ var AnthropicMessagesLanguageModel = class {
2371
2400
  content.push({
2372
2401
  type: "tool-result",
2373
2402
  toolCallId: part.tool_use_id,
2374
- toolName: "web_fetch",
2403
+ toolName: toolNameMapping.toCustomToolName("web_fetch"),
2375
2404
  isError: true,
2376
2405
  result: {
2377
2406
  type: "web_fetch_tool_result_error",
@@ -2386,7 +2415,7 @@ var AnthropicMessagesLanguageModel = class {
2386
2415
  content.push({
2387
2416
  type: "tool-result",
2388
2417
  toolCallId: part.tool_use_id,
2389
- toolName: "web_search",
2418
+ toolName: toolNameMapping.toCustomToolName("web_search"),
2390
2419
  result: part.content.map((result) => {
2391
2420
  var _a2;
2392
2421
  return {
@@ -2416,7 +2445,7 @@ var AnthropicMessagesLanguageModel = class {
2416
2445
  content.push({
2417
2446
  type: "tool-result",
2418
2447
  toolCallId: part.tool_use_id,
2419
- toolName: "web_search",
2448
+ toolName: toolNameMapping.toCustomToolName("web_search"),
2420
2449
  isError: true,
2421
2450
  result: {
2422
2451
  type: "web_search_tool_result_error",
@@ -2432,7 +2461,7 @@ var AnthropicMessagesLanguageModel = class {
2432
2461
  content.push({
2433
2462
  type: "tool-result",
2434
2463
  toolCallId: part.tool_use_id,
2435
- toolName: "code_execution",
2464
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
2436
2465
  result: {
2437
2466
  type: part.content.type,
2438
2467
  stdout: part.content.stdout,
@@ -2444,7 +2473,7 @@ var AnthropicMessagesLanguageModel = class {
2444
2473
  content.push({
2445
2474
  type: "tool-result",
2446
2475
  toolCallId: part.tool_use_id,
2447
- toolName: "code_execution",
2476
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
2448
2477
  isError: true,
2449
2478
  result: {
2450
2479
  type: "code_execution_tool_result_error",
@@ -2460,7 +2489,7 @@ var AnthropicMessagesLanguageModel = class {
2460
2489
  content.push({
2461
2490
  type: "tool-result",
2462
2491
  toolCallId: part.tool_use_id,
2463
- toolName: "code_execution",
2492
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
2464
2493
  result: part.content
2465
2494
  });
2466
2495
  break;
@@ -2506,11 +2535,13 @@ var AnthropicMessagesLanguageModel = class {
2506
2535
  };
2507
2536
  }
2508
2537
  async doStream(options) {
2538
+ var _a, _b;
2509
2539
  const {
2510
2540
  args: body,
2511
2541
  warnings,
2512
2542
  betas,
2513
- usesJsonResponseTool
2543
+ usesJsonResponseTool,
2544
+ toolNameMapping
2514
2545
  } = await this.getArgs({
2515
2546
  ...options,
2516
2547
  stream: true,
@@ -2544,25 +2575,13 @@ var AnthropicMessagesLanguageModel = class {
2544
2575
  let isJsonResponseFromTool = false;
2545
2576
  let blockType = void 0;
2546
2577
  const generateId3 = this.generateId;
2547
- let isFirstChunk = true;
2548
- let stream = void 0;
2549
- const returnPromise = new DelayedPromise();
2550
2578
  const transformedStream = response.pipeThrough(
2551
2579
  new TransformStream({
2552
2580
  start(controller) {
2553
2581
  controller.enqueue({ type: "stream-start", warnings });
2554
2582
  },
2555
- async flush() {
2556
- if (returnPromise.isPending()) {
2557
- returnPromise.resolve({
2558
- stream,
2559
- request: { body },
2560
- response: { headers: responseHeaders }
2561
- });
2562
- }
2563
- },
2564
2583
  transform(chunk, controller) {
2565
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2584
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
2566
2585
  if (options.includeRawChunks) {
2567
2586
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2568
2587
  }
@@ -2570,29 +2589,6 @@ var AnthropicMessagesLanguageModel = class {
2570
2589
  controller.enqueue({ type: "error", error: chunk.error });
2571
2590
  return;
2572
2591
  }
2573
- if (isFirstChunk) {
2574
- if (chunk.value.type === "error") {
2575
- returnPromise.reject(
2576
- new APICallError({
2577
- message: chunk.value.error.message,
2578
- url,
2579
- requestBodyValues: body,
2580
- statusCode: chunk.value.error.type === "overloaded_error" ? 529 : 500,
2581
- responseHeaders,
2582
- responseBody: JSON.stringify(chunk.value.error),
2583
- isRetryable: chunk.value.error.type === "overloaded_error"
2584
- })
2585
- );
2586
- controller.terminate();
2587
- return;
2588
- }
2589
- isFirstChunk = false;
2590
- returnPromise.resolve({
2591
- stream,
2592
- request: { body },
2593
- response: { headers: responseHeaders }
2594
- });
2595
- }
2596
2592
  const value = chunk.value;
2597
2593
  switch (value.type) {
2598
2594
  case "ping": {
@@ -2671,19 +2667,21 @@ var AnthropicMessagesLanguageModel = class {
2671
2667
  // code execution 20250825 bash:
2672
2668
  "bash_code_execution"
2673
2669
  ].includes(part.name)) {
2670
+ const providerToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
2671
+ const customToolName = toolNameMapping.toCustomToolName(providerToolName);
2674
2672
  contentBlocks[value.index] = {
2675
2673
  type: "tool-call",
2676
2674
  toolCallId: part.id,
2677
- toolName: part.name,
2675
+ toolName: customToolName,
2678
2676
  input: "",
2679
2677
  providerExecuted: true,
2680
- firstDelta: true
2678
+ firstDelta: true,
2679
+ providerToolName: part.name
2681
2680
  };
2682
- const mappedToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
2683
2681
  controller.enqueue({
2684
2682
  type: "tool-input-start",
2685
2683
  id: part.id,
2686
- toolName: mappedToolName,
2684
+ toolName: customToolName,
2687
2685
  providerExecuted: true
2688
2686
  });
2689
2687
  }
@@ -2694,7 +2692,7 @@ var AnthropicMessagesLanguageModel = class {
2694
2692
  controller.enqueue({
2695
2693
  type: "tool-result",
2696
2694
  toolCallId: part.tool_use_id,
2697
- toolName: "web_fetch",
2695
+ toolName: toolNameMapping.toCustomToolName("web_fetch"),
2698
2696
  result: {
2699
2697
  type: "web_fetch_result",
2700
2698
  url: part.content.url,
@@ -2715,7 +2713,7 @@ var AnthropicMessagesLanguageModel = class {
2715
2713
  controller.enqueue({
2716
2714
  type: "tool-result",
2717
2715
  toolCallId: part.tool_use_id,
2718
- toolName: "web_fetch",
2716
+ toolName: toolNameMapping.toCustomToolName("web_fetch"),
2719
2717
  isError: true,
2720
2718
  result: {
2721
2719
  type: "web_fetch_tool_result_error",
@@ -2730,13 +2728,13 @@ var AnthropicMessagesLanguageModel = class {
2730
2728
  controller.enqueue({
2731
2729
  type: "tool-result",
2732
2730
  toolCallId: part.tool_use_id,
2733
- toolName: "web_search",
2731
+ toolName: toolNameMapping.toCustomToolName("web_search"),
2734
2732
  result: part.content.map((result) => {
2735
- var _a2;
2733
+ var _a3;
2736
2734
  return {
2737
2735
  url: result.url,
2738
2736
  title: result.title,
2739
- pageAge: (_a2 = result.page_age) != null ? _a2 : null,
2737
+ pageAge: (_a3 = result.page_age) != null ? _a3 : null,
2740
2738
  encryptedContent: result.encrypted_content,
2741
2739
  type: result.type
2742
2740
  };
@@ -2751,7 +2749,7 @@ var AnthropicMessagesLanguageModel = class {
2751
2749
  title: result.title,
2752
2750
  providerMetadata: {
2753
2751
  anthropic: {
2754
- pageAge: (_a = result.page_age) != null ? _a : null
2752
+ pageAge: (_a2 = result.page_age) != null ? _a2 : null
2755
2753
  }
2756
2754
  }
2757
2755
  });
@@ -2760,7 +2758,7 @@ var AnthropicMessagesLanguageModel = class {
2760
2758
  controller.enqueue({
2761
2759
  type: "tool-result",
2762
2760
  toolCallId: part.tool_use_id,
2763
- toolName: "web_search",
2761
+ toolName: toolNameMapping.toCustomToolName("web_search"),
2764
2762
  isError: true,
2765
2763
  result: {
2766
2764
  type: "web_search_tool_result_error",
@@ -2776,7 +2774,7 @@ var AnthropicMessagesLanguageModel = class {
2776
2774
  controller.enqueue({
2777
2775
  type: "tool-result",
2778
2776
  toolCallId: part.tool_use_id,
2779
- toolName: "code_execution",
2777
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
2780
2778
  result: {
2781
2779
  type: part.content.type,
2782
2780
  stdout: part.content.stdout,
@@ -2788,7 +2786,7 @@ var AnthropicMessagesLanguageModel = class {
2788
2786
  controller.enqueue({
2789
2787
  type: "tool-result",
2790
2788
  toolCallId: part.tool_use_id,
2791
- toolName: "code_execution",
2789
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
2792
2790
  isError: true,
2793
2791
  result: {
2794
2792
  type: "code_execution_tool_result_error",
@@ -2804,7 +2802,7 @@ var AnthropicMessagesLanguageModel = class {
2804
2802
  controller.enqueue({
2805
2803
  type: "tool-result",
2806
2804
  toolCallId: part.tool_use_id,
2807
- toolName: "code_execution",
2805
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
2808
2806
  result: part.content
2809
2807
  });
2810
2808
  return;
@@ -2872,11 +2870,10 @@ var AnthropicMessagesLanguageModel = class {
2872
2870
  type: "tool-input-end",
2873
2871
  id: contentBlock.toolCallId
2874
2872
  });
2875
- const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
2876
2873
  controller.enqueue({
2877
2874
  type: "tool-call",
2878
2875
  toolCallId: contentBlock.toolCallId,
2879
- toolName,
2876
+ toolName: contentBlock.toolName,
2880
2877
  input: contentBlock.input === "" ? "{}" : contentBlock.input,
2881
2878
  providerExecuted: contentBlock.providerExecuted
2882
2879
  });
@@ -2944,8 +2941,8 @@ var AnthropicMessagesLanguageModel = class {
2944
2941
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
2945
2942
  return;
2946
2943
  }
2947
- if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
2948
- delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
2944
+ if (contentBlock.firstDelta && (contentBlock.providerToolName === "bash_code_execution" || contentBlock.providerToolName === "text_editor_code_execution")) {
2945
+ delta = `{"type": "${contentBlock.providerToolName}",${delta.substring(1)}`;
2949
2946
  }
2950
2947
  controller.enqueue({
2951
2948
  type: "tool-input-delta",
@@ -2979,7 +2976,7 @@ var AnthropicMessagesLanguageModel = class {
2979
2976
  }
2980
2977
  case "message_start": {
2981
2978
  usage.inputTokens = value.message.usage.input_tokens;
2982
- usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
2979
+ usage.cachedInputTokens = (_b2 = value.message.usage.cache_read_input_tokens) != null ? _b2 : void 0;
2983
2980
  rawUsage = {
2984
2981
  ...value.message.usage
2985
2982
  };
@@ -3043,22 +3040,35 @@ var AnthropicMessagesLanguageModel = class {
3043
3040
  })
3044
3041
  );
3045
3042
  const [streamForFirstChunk, streamForConsumer] = transformedStream.tee();
3046
- stream = streamForConsumer;
3047
3043
  const firstChunkReader = streamForFirstChunk.getReader();
3048
3044
  try {
3049
- const { done } = await firstChunkReader.read();
3050
- if (!done) {
3051
- firstChunkReader.cancel();
3045
+ await firstChunkReader.read();
3046
+ let result = await firstChunkReader.read();
3047
+ if (((_a = result.value) == null ? void 0 : _a.type) === "raw") {
3048
+ result = await firstChunkReader.read();
3052
3049
  }
3053
- } catch (error) {
3054
- try {
3055
- firstChunkReader.cancel();
3056
- } catch (e) {
3050
+ if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
3051
+ const error = result.value.error;
3052
+ throw new APICallError({
3053
+ message: error.message,
3054
+ url,
3055
+ requestBodyValues: body,
3056
+ statusCode: error.type === "overloaded_error" ? 529 : 500,
3057
+ responseHeaders,
3058
+ responseBody: JSON.stringify(error),
3059
+ isRetryable: error.type === "overloaded_error"
3060
+ });
3057
3061
  }
3058
3062
  } finally {
3063
+ firstChunkReader.cancel().catch(() => {
3064
+ });
3059
3065
  firstChunkReader.releaseLock();
3060
3066
  }
3061
- return returnPromise.promise;
3067
+ return {
3068
+ stream: streamForConsumer,
3069
+ request: { body },
3070
+ response: { headers: responseHeaders }
3071
+ };
3062
3072
  }
3063
3073
  };
3064
3074
  function getModelCapabilities(modelId) {