@openrouter/ai-sdk-provider 2.3.2 → 2.3.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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +32 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +31 -8
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +31 -8
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -431,6 +431,7 @@ type OpenRouterCompletionSettings = {
|
|
|
431
431
|
declare enum ReasoningFormat {
|
|
432
432
|
Unknown = "unknown",
|
|
433
433
|
OpenAIResponsesV1 = "openai-responses-v1",
|
|
434
|
+
AzureOpenAIResponsesV1 = "azure-openai-responses-v1",
|
|
434
435
|
XAIResponsesV1 = "xai-responses-v1",
|
|
435
436
|
AnthropicClaudeV1 = "anthropic-claude-v1",
|
|
436
437
|
GoogleGeminiV1 = "google-gemini-v1"
|
package/dist/index.d.ts
CHANGED
|
@@ -431,6 +431,7 @@ type OpenRouterCompletionSettings = {
|
|
|
431
431
|
declare enum ReasoningFormat {
|
|
432
432
|
Unknown = "unknown",
|
|
433
433
|
OpenAIResponsesV1 = "openai-responses-v1",
|
|
434
|
+
AzureOpenAIResponsesV1 = "azure-openai-responses-v1",
|
|
434
435
|
XAIResponsesV1 = "xai-responses-v1",
|
|
435
436
|
AnthropicClaudeV1 = "anthropic-claude-v1",
|
|
436
437
|
GoogleGeminiV1 = "google-gemini-v1"
|
package/dist/index.js
CHANGED
|
@@ -2216,11 +2216,13 @@ function isDefinedOrNotNull(value) {
|
|
|
2216
2216
|
var ReasoningFormat = /* @__PURE__ */ ((ReasoningFormat2) => {
|
|
2217
2217
|
ReasoningFormat2["Unknown"] = "unknown";
|
|
2218
2218
|
ReasoningFormat2["OpenAIResponsesV1"] = "openai-responses-v1";
|
|
2219
|
+
ReasoningFormat2["AzureOpenAIResponsesV1"] = "azure-openai-responses-v1";
|
|
2219
2220
|
ReasoningFormat2["XAIResponsesV1"] = "xai-responses-v1";
|
|
2220
2221
|
ReasoningFormat2["AnthropicClaudeV1"] = "anthropic-claude-v1";
|
|
2221
2222
|
ReasoningFormat2["GoogleGeminiV1"] = "google-gemini-v1";
|
|
2222
2223
|
return ReasoningFormat2;
|
|
2223
2224
|
})(ReasoningFormat || {});
|
|
2225
|
+
var DEFAULT_REASONING_FORMAT = "anthropic-claude-v1" /* AnthropicClaudeV1 */;
|
|
2224
2226
|
|
|
2225
2227
|
// src/schemas/reasoning-details.ts
|
|
2226
2228
|
var CommonReasoningDetailSchema = import_v4.z.object({
|
|
@@ -2373,7 +2375,11 @@ var OpenRouterProviderMetadataSchema = import_v43.z.object({
|
|
|
2373
2375
|
}).catchall(import_v43.z.any());
|
|
2374
2376
|
var OpenRouterProviderOptionsSchema = import_v43.z.object({
|
|
2375
2377
|
openrouter: import_v43.z.object({
|
|
2376
|
-
|
|
2378
|
+
// Use ReasoningDetailArraySchema (with unknown fallback) instead of
|
|
2379
|
+
// z.array(ReasoningDetailUnionSchema) so that a single malformed entry
|
|
2380
|
+
// (e.g., a future format not yet in the enum) is individually dropped
|
|
2381
|
+
// rather than causing the entire array to fail parsing.
|
|
2382
|
+
reasoning_details: ReasoningDetailArraySchema.optional(),
|
|
2377
2383
|
annotations: import_v43.z.array(FileAnnotationSchema).optional()
|
|
2378
2384
|
}).optional()
|
|
2379
2385
|
}).optional();
|
|
@@ -2785,8 +2791,24 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
2785
2791
|
const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : findFirstReasoningDetails(content);
|
|
2786
2792
|
let finalReasoningDetails;
|
|
2787
2793
|
if (candidateReasoningDetails && candidateReasoningDetails.length > 0) {
|
|
2794
|
+
const validDetails = candidateReasoningDetails.filter((detail) => {
|
|
2795
|
+
var _a17;
|
|
2796
|
+
if (detail.type !== "reasoning.text" /* Text */) {
|
|
2797
|
+
return true;
|
|
2798
|
+
}
|
|
2799
|
+
const format = (_a17 = detail.format) != null ? _a17 : DEFAULT_REASONING_FORMAT;
|
|
2800
|
+
if (format !== "anthropic-claude-v1" /* AnthropicClaudeV1 */) {
|
|
2801
|
+
return true;
|
|
2802
|
+
}
|
|
2803
|
+
return !!detail.signature;
|
|
2804
|
+
});
|
|
2805
|
+
if (validDetails.length < candidateReasoningDetails.length) {
|
|
2806
|
+
console.warn(
|
|
2807
|
+
"[openrouter] Some reasoning_details entries were removed because they were missing signatures. See https://github.com/OpenRouterTeam/ai-sdk-provider/issues/423 for more details."
|
|
2808
|
+
);
|
|
2809
|
+
}
|
|
2788
2810
|
const uniqueDetails = [];
|
|
2789
|
-
for (const detail of
|
|
2811
|
+
for (const detail of validDetails) {
|
|
2790
2812
|
if (reasoningDetailsTracker.upsert(detail)) {
|
|
2791
2813
|
uniqueDetails.push(detail);
|
|
2792
2814
|
}
|
|
@@ -2956,13 +2978,14 @@ function filenameFromUrl(url) {
|
|
|
2956
2978
|
}
|
|
2957
2979
|
}
|
|
2958
2980
|
function findFirstReasoningDetails(content) {
|
|
2959
|
-
var _a16, _b16, _c;
|
|
2981
|
+
var _a16, _b16, _c, _d;
|
|
2960
2982
|
for (const part of content) {
|
|
2961
2983
|
if (part.type === "tool-call") {
|
|
2962
|
-
const
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2984
|
+
const parsed = OpenRouterProviderOptionsSchema.safeParse(
|
|
2985
|
+
part.providerOptions
|
|
2986
|
+
);
|
|
2987
|
+
if (parsed.success && ((_b16 = (_a16 = parsed.data) == null ? void 0 : _a16.openrouter) == null ? void 0 : _b16.reasoning_details) && parsed.data.openrouter.reasoning_details.length > 0) {
|
|
2988
|
+
return parsed.data.openrouter.reasoning_details;
|
|
2966
2989
|
}
|
|
2967
2990
|
}
|
|
2968
2991
|
}
|
|
@@ -2971,7 +2994,7 @@ function findFirstReasoningDetails(content) {
|
|
|
2971
2994
|
const parsed = OpenRouterProviderOptionsSchema.safeParse(
|
|
2972
2995
|
part.providerOptions
|
|
2973
2996
|
);
|
|
2974
|
-
if (parsed.success && ((
|
|
2997
|
+
if (parsed.success && ((_d = (_c = parsed.data) == null ? void 0 : _c.openrouter) == null ? void 0 : _d.reasoning_details) && parsed.data.openrouter.reasoning_details.length > 0) {
|
|
2975
2998
|
return parsed.data.openrouter.reasoning_details;
|
|
2976
2999
|
}
|
|
2977
3000
|
}
|
|
@@ -4724,7 +4747,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
4724
4747
|
}
|
|
4725
4748
|
|
|
4726
4749
|
// src/version.ts
|
|
4727
|
-
var VERSION2 = false ? "0.0.0-test" : "2.3.
|
|
4750
|
+
var VERSION2 = false ? "0.0.0-test" : "2.3.3";
|
|
4728
4751
|
|
|
4729
4752
|
// src/provider.ts
|
|
4730
4753
|
function createOpenRouter(options = {}) {
|