@openrouter/ai-sdk-provider 1.2.3 → 1.2.4
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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +59 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +58 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +58 -9
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -217,7 +217,8 @@ declare enum ReasoningFormat {
|
|
|
217
217
|
Unknown = "unknown",
|
|
218
218
|
OpenAIResponsesV1 = "openai-responses-v1",
|
|
219
219
|
XAIResponsesV1 = "xai-responses-v1",
|
|
220
|
-
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
220
|
+
AnthropicClaudeV1 = "anthropic-claude-v1",
|
|
221
|
+
GoogleGeminiV1 = "google-gemini-v1"
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
declare enum ReasoningDetailType {
|
package/dist/index.d.ts
CHANGED
|
@@ -217,7 +217,8 @@ declare enum ReasoningFormat {
|
|
|
217
217
|
Unknown = "unknown",
|
|
218
218
|
OpenAIResponsesV1 = "openai-responses-v1",
|
|
219
219
|
XAIResponsesV1 = "xai-responses-v1",
|
|
220
|
-
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
220
|
+
AnthropicClaudeV1 = "anthropic-claude-v1",
|
|
221
|
+
GoogleGeminiV1 = "google-gemini-v1"
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
declare enum ReasoningDetailType {
|
package/dist/index.js
CHANGED
|
@@ -943,6 +943,7 @@ var ReasoningFormat = /* @__PURE__ */ ((ReasoningFormat2) => {
|
|
|
943
943
|
ReasoningFormat2["OpenAIResponsesV1"] = "openai-responses-v1";
|
|
944
944
|
ReasoningFormat2["XAIResponsesV1"] = "xai-responses-v1";
|
|
945
945
|
ReasoningFormat2["AnthropicClaudeV1"] = "anthropic-claude-v1";
|
|
946
|
+
ReasoningFormat2["GoogleGeminiV1"] = "google-gemini-v1";
|
|
946
947
|
return ReasoningFormat2;
|
|
947
948
|
})(ReasoningFormat || {});
|
|
948
949
|
|
|
@@ -1590,7 +1591,9 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1590
1591
|
});
|
|
1591
1592
|
}
|
|
1592
1593
|
if (tools && tools.length > 0) {
|
|
1593
|
-
const mappedTools = tools.filter(
|
|
1594
|
+
const mappedTools = tools.filter(
|
|
1595
|
+
(tool) => tool.type === "function"
|
|
1596
|
+
).map((tool) => ({
|
|
1594
1597
|
type: "function",
|
|
1595
1598
|
function: {
|
|
1596
1599
|
name: tool.name,
|
|
@@ -1665,7 +1668,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1665
1668
|
if (detail.text) {
|
|
1666
1669
|
return {
|
|
1667
1670
|
type: "reasoning",
|
|
1668
|
-
text: detail.text
|
|
1671
|
+
text: detail.text,
|
|
1672
|
+
providerMetadata: {
|
|
1673
|
+
openrouter: {
|
|
1674
|
+
reasoning_details: [detail]
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1669
1677
|
};
|
|
1670
1678
|
}
|
|
1671
1679
|
break;
|
|
@@ -1674,7 +1682,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1674
1682
|
if (detail.summary) {
|
|
1675
1683
|
return {
|
|
1676
1684
|
type: "reasoning",
|
|
1677
|
-
text: detail.summary
|
|
1685
|
+
text: detail.summary,
|
|
1686
|
+
providerMetadata: {
|
|
1687
|
+
openrouter: {
|
|
1688
|
+
reasoning_details: [detail]
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1678
1691
|
};
|
|
1679
1692
|
}
|
|
1680
1693
|
break;
|
|
@@ -1683,7 +1696,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1683
1696
|
if (detail.data) {
|
|
1684
1697
|
return {
|
|
1685
1698
|
type: "reasoning",
|
|
1686
|
-
text: "[REDACTED]"
|
|
1699
|
+
text: "[REDACTED]",
|
|
1700
|
+
providerMetadata: {
|
|
1701
|
+
openrouter: {
|
|
1702
|
+
reasoning_details: [detail]
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1687
1705
|
};
|
|
1688
1706
|
}
|
|
1689
1707
|
break;
|
|
@@ -1713,7 +1731,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1713
1731
|
type: "tool-call",
|
|
1714
1732
|
toolCallId: (_j = toolCall.id) != null ? _j : generateId(),
|
|
1715
1733
|
toolName: toolCall.function.name,
|
|
1716
|
-
input: toolCall.function.arguments
|
|
1734
|
+
input: toolCall.function.arguments,
|
|
1735
|
+
providerMetadata: {
|
|
1736
|
+
openrouter: {
|
|
1737
|
+
reasoning_details: reasoningDetails
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1717
1740
|
});
|
|
1718
1741
|
}
|
|
1719
1742
|
}
|
|
@@ -1899,7 +1922,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1899
1922
|
});
|
|
1900
1923
|
};
|
|
1901
1924
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
1902
|
-
|
|
1925
|
+
for (const detail of delta.reasoning_details) {
|
|
1926
|
+
if (detail.type === "reasoning.text" /* Text */) {
|
|
1927
|
+
const lastDetail = accumulatedReasoningDetails[accumulatedReasoningDetails.length - 1];
|
|
1928
|
+
if ((lastDetail == null ? void 0 : lastDetail.type) === "reasoning.text" /* Text */) {
|
|
1929
|
+
lastDetail.text = (lastDetail.text || "") + (detail.text || "");
|
|
1930
|
+
} else {
|
|
1931
|
+
accumulatedReasoningDetails.push(__spreadValues({}, detail));
|
|
1932
|
+
}
|
|
1933
|
+
} else {
|
|
1934
|
+
accumulatedReasoningDetails.push(detail);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1903
1937
|
for (const detail of delta.reasoning_details) {
|
|
1904
1938
|
switch (detail.type) {
|
|
1905
1939
|
case "reasoning.text" /* Text */: {
|
|
@@ -2028,7 +2062,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2028
2062
|
type: "tool-call",
|
|
2029
2063
|
toolCallId: toolCall2.id,
|
|
2030
2064
|
toolName: toolCall2.function.name,
|
|
2031
|
-
input: toolCall2.function.arguments
|
|
2065
|
+
input: toolCall2.function.arguments,
|
|
2066
|
+
providerMetadata: {
|
|
2067
|
+
openrouter: {
|
|
2068
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2032
2071
|
});
|
|
2033
2072
|
toolCall2.sent = true;
|
|
2034
2073
|
}
|
|
@@ -2066,7 +2105,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2066
2105
|
type: "tool-call",
|
|
2067
2106
|
toolCallId: (_n = toolCall.id) != null ? _n : generateId(),
|
|
2068
2107
|
toolName: toolCall.function.name,
|
|
2069
|
-
input: toolCall.function.arguments
|
|
2108
|
+
input: toolCall.function.arguments,
|
|
2109
|
+
providerMetadata: {
|
|
2110
|
+
openrouter: {
|
|
2111
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2070
2114
|
});
|
|
2071
2115
|
toolCall.sent = true;
|
|
2072
2116
|
}
|
|
@@ -2092,7 +2136,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2092
2136
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|
|
2093
2137
|
toolName: toolCall.function.name,
|
|
2094
2138
|
// Coerce invalid arguments to an empty JSON object
|
|
2095
|
-
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}"
|
|
2139
|
+
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
|
|
2140
|
+
providerMetadata: {
|
|
2141
|
+
openrouter: {
|
|
2142
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2096
2145
|
});
|
|
2097
2146
|
toolCall.sent = true;
|
|
2098
2147
|
}
|
|
@@ -2572,7 +2621,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
2572
2621
|
}
|
|
2573
2622
|
|
|
2574
2623
|
// src/version.ts
|
|
2575
|
-
var VERSION = false ? "0.0.0-test" : "1.2.
|
|
2624
|
+
var VERSION = false ? "0.0.0-test" : "1.2.4";
|
|
2576
2625
|
|
|
2577
2626
|
// src/provider.ts
|
|
2578
2627
|
function createOpenRouter(options = {}) {
|