@openrouter/ai-sdk-provider 1.0.0-beta.2 → 1.0.0-beta.3

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
@@ -1480,6 +1480,9 @@ var OpenRouterChatLanguageModel = class {
1480
1480
  const openrouterUsage = {};
1481
1481
  let textStarted = false;
1482
1482
  let reasoningStarted = false;
1483
+ let textId;
1484
+ let reasoningId;
1485
+ let openrouterResponseId;
1483
1486
  return {
1484
1487
  stream: response.pipeThrough(
1485
1488
  new TransformStream({
@@ -1497,6 +1500,7 @@ var OpenRouterChatLanguageModel = class {
1497
1500
  return;
1498
1501
  }
1499
1502
  if (value.id) {
1503
+ openrouterResponseId = value.id;
1500
1504
  controller.enqueue({
1501
1505
  type: "response-metadata",
1502
1506
  id: value.id
@@ -1541,30 +1545,32 @@ var OpenRouterChatLanguageModel = class {
1541
1545
  const delta = choice.delta;
1542
1546
  if (delta.content != null) {
1543
1547
  if (!textStarted) {
1548
+ textId = openrouterResponseId || generateId();
1544
1549
  controller.enqueue({
1545
1550
  type: "text-start",
1546
- id: generateId()
1551
+ id: textId
1547
1552
  });
1548
1553
  textStarted = true;
1549
1554
  }
1550
1555
  controller.enqueue({
1551
1556
  type: "text-delta",
1552
1557
  delta: delta.content,
1553
- id: generateId()
1558
+ id: textId || generateId()
1554
1559
  });
1555
1560
  }
1556
1561
  const emitReasoningChunk = (chunkText) => {
1557
1562
  if (!reasoningStarted) {
1563
+ reasoningId = openrouterResponseId || generateId();
1558
1564
  controller.enqueue({
1559
1565
  type: "reasoning-start",
1560
- id: generateId()
1566
+ id: reasoningId
1561
1567
  });
1562
1568
  reasoningStarted = true;
1563
1569
  }
1564
1570
  controller.enqueue({
1565
1571
  type: "reasoning-delta",
1566
1572
  delta: chunkText,
1567
- id: generateId()
1573
+ id: reasoningId || generateId()
1568
1574
  });
1569
1575
  };
1570
1576
  if (delta.reasoning != null) {
@@ -1706,10 +1712,10 @@ var OpenRouterChatLanguageModel = class {
1706
1712
  }
1707
1713
  }
1708
1714
  if (textStarted) {
1709
- controller.enqueue({ type: "text-end", id: generateId() });
1715
+ controller.enqueue({ type: "text-end", id: textId || generateId() });
1710
1716
  }
1711
1717
  if (reasoningStarted) {
1712
- controller.enqueue({ type: "reasoning-end", id: generateId() });
1718
+ controller.enqueue({ type: "reasoning-end", id: reasoningId || generateId() });
1713
1719
  }
1714
1720
  controller.enqueue({
1715
1721
  type: "finish",