@openrouter/ai-sdk-provider 1.0.0-beta.5 → 1.0.0-beta.7

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.
@@ -1275,6 +1275,7 @@ var OpenRouterChatLanguageModel = class {
1275
1275
  tools,
1276
1276
  toolChoice
1277
1277
  }) {
1278
+ var _a15;
1278
1279
  const baseArgs = __spreadValues(__spreadValues({
1279
1280
  // model id:
1280
1281
  model: this.modelId,
@@ -1302,9 +1303,18 @@ var OpenRouterChatLanguageModel = class {
1302
1303
  reasoning: this.settings.reasoning,
1303
1304
  usage: this.settings.usage
1304
1305
  }, this.config.extraBody), this.settings.extraBody);
1305
- if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
1306
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
1306
1307
  return __spreadProps(__spreadValues({}, baseArgs), {
1307
- response_format: { type: "json_object" }
1308
+ response_format: {
1309
+ type: "json_schema",
1310
+ json_schema: __spreadValues({
1311
+ schema: responseFormat.schema,
1312
+ strict: true,
1313
+ name: (_a15 = responseFormat.name) != null ? _a15 : "response"
1314
+ }, responseFormat.description && {
1315
+ description: responseFormat.description
1316
+ })
1317
+ }
1308
1318
  });
1309
1319
  }
1310
1320
  if (tools && tools.length > 0) {
@@ -1550,21 +1560,6 @@ var OpenRouterChatLanguageModel = class {
1550
1560
  return;
1551
1561
  }
1552
1562
  const delta = choice.delta;
1553
- if (delta.content != null) {
1554
- if (!textStarted) {
1555
- textId = openrouterResponseId || generateId();
1556
- controller.enqueue({
1557
- type: "text-start",
1558
- id: textId
1559
- });
1560
- textStarted = true;
1561
- }
1562
- controller.enqueue({
1563
- type: "text-delta",
1564
- delta: delta.content,
1565
- id: textId || generateId()
1566
- });
1567
- }
1568
1563
  const emitReasoningChunk = (chunkText) => {
1569
1564
  if (!reasoningStarted) {
1570
1565
  reasoningId = openrouterResponseId || generateId();
@@ -1580,9 +1575,6 @@ var OpenRouterChatLanguageModel = class {
1580
1575
  id: reasoningId || generateId()
1581
1576
  });
1582
1577
  };
1583
- if (delta.reasoning != null) {
1584
- emitReasoningChunk(delta.reasoning);
1585
- }
1586
1578
  if (delta.reasoning_details && delta.reasoning_details.length > 0) {
1587
1579
  for (const detail of delta.reasoning_details) {
1588
1580
  switch (detail.type) {
@@ -1610,6 +1602,23 @@ var OpenRouterChatLanguageModel = class {
1610
1602
  }
1611
1603
  }
1612
1604
  }
1605
+ } else if (delta.reasoning != null) {
1606
+ emitReasoningChunk(delta.reasoning);
1607
+ }
1608
+ if (delta.content != null) {
1609
+ if (!textStarted) {
1610
+ textId = openrouterResponseId || generateId();
1611
+ controller.enqueue({
1612
+ type: "text-start",
1613
+ id: textId
1614
+ });
1615
+ textStarted = true;
1616
+ }
1617
+ controller.enqueue({
1618
+ type: "text-delta",
1619
+ delta: delta.content,
1620
+ id: textId || generateId()
1621
+ });
1613
1622
  }
1614
1623
  if (delta.tool_calls != null) {
1615
1624
  for (const toolCallDelta of delta.tool_calls) {
@@ -1709,7 +1718,7 @@ var OpenRouterChatLanguageModel = class {
1709
1718
  var _a16;
1710
1719
  if (finishReason === "tool-calls") {
1711
1720
  for (const toolCall of toolCalls) {
1712
- if (!toolCall.sent) {
1721
+ if (toolCall && !toolCall.sent) {
1713
1722
  controller.enqueue({
1714
1723
  type: "tool-call",
1715
1724
  toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),