@openrouter/ai-sdk-provider 1.2.0 → 1.2.2
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 +53 -13
- package/dist/index.d.ts +53 -13
- package/dist/index.js +386 -179
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +386 -179
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +51 -11
- package/dist/internal/index.d.ts +51 -11
- package/dist/internal/index.js +354 -172
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +354 -172
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +12 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
1
|
+
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart, ProviderV2 } from '@ai-sdk/provider';
|
|
2
2
|
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
|
+
import * as models from '@openrouter/sdk/models';
|
|
4
|
+
import { z } from 'zod/v4';
|
|
3
5
|
|
|
4
6
|
type OpenRouterChatModelId = string;
|
|
5
7
|
type OpenRouterChatSettings = {
|
|
@@ -40,18 +42,21 @@ type OpenRouterChatSettings = {
|
|
|
40
42
|
*/
|
|
41
43
|
user?: string;
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
45
|
+
* Plugin configurations for enabling various capabilities
|
|
44
46
|
*/
|
|
45
47
|
plugins?: Array<{
|
|
46
|
-
id:
|
|
47
|
-
/**
|
|
48
|
-
* Maximum number of search results to include (default: 5)
|
|
49
|
-
*/
|
|
48
|
+
id: models.IdWeb;
|
|
50
49
|
max_results?: number;
|
|
51
|
-
/**
|
|
52
|
-
* Custom search prompt to guide the search query
|
|
53
|
-
*/
|
|
54
50
|
search_prompt?: string;
|
|
51
|
+
engine?: models.Engine;
|
|
52
|
+
} | {
|
|
53
|
+
id: models.IdFileParser;
|
|
54
|
+
max_files?: number;
|
|
55
|
+
pdf?: {
|
|
56
|
+
engine?: models.PdfEngine;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
id: models.IdModeration;
|
|
55
60
|
}>;
|
|
56
61
|
/**
|
|
57
62
|
* Built-in web search options for models that support native web search
|
|
@@ -85,7 +90,7 @@ type OpenRouterChatSettings = {
|
|
|
85
90
|
/**
|
|
86
91
|
* Control whether to use providers that may store data
|
|
87
92
|
*/
|
|
88
|
-
data_collection?:
|
|
93
|
+
data_collection?: models.DataCollection;
|
|
89
94
|
/**
|
|
90
95
|
* List of provider slugs to allow for this request
|
|
91
96
|
*/
|
|
@@ -97,11 +102,11 @@ type OpenRouterChatSettings = {
|
|
|
97
102
|
/**
|
|
98
103
|
* List of quantization levels to filter by (e.g. ["int4", "int8"])
|
|
99
104
|
*/
|
|
100
|
-
quantizations?: Array<
|
|
105
|
+
quantizations?: Array<models.Quantization>;
|
|
101
106
|
/**
|
|
102
107
|
* Sort providers by price, throughput, or latency
|
|
103
108
|
*/
|
|
104
|
-
sort?:
|
|
109
|
+
sort?: models.Sort;
|
|
105
110
|
/**
|
|
106
111
|
* Maximum pricing you want to pay for this request
|
|
107
112
|
*/
|
|
@@ -208,6 +213,40 @@ type OpenRouterCompletionSettings = {
|
|
|
208
213
|
suffix?: string;
|
|
209
214
|
} & OpenRouterSharedSettings;
|
|
210
215
|
|
|
216
|
+
declare enum ReasoningFormat {
|
|
217
|
+
Unknown = "unknown",
|
|
218
|
+
OpenAIResponsesV1 = "openai-responses-v1",
|
|
219
|
+
XAIResponsesV1 = "xai-responses-v1",
|
|
220
|
+
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare enum ReasoningDetailType {
|
|
224
|
+
Summary = "reasoning.summary",
|
|
225
|
+
Encrypted = "reasoning.encrypted",
|
|
226
|
+
Text = "reasoning.text"
|
|
227
|
+
}
|
|
228
|
+
declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
229
|
+
type: z.ZodLiteral<ReasoningDetailType.Summary>;
|
|
230
|
+
summary: z.ZodString;
|
|
231
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
232
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
233
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
235
|
+
type: z.ZodLiteral<ReasoningDetailType.Encrypted>;
|
|
236
|
+
data: z.ZodString;
|
|
237
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
238
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
239
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
240
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
241
|
+
type: z.ZodLiteral<ReasoningDetailType.Text>;
|
|
242
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
243
|
+
signature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
244
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
245
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
246
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
247
|
+
}, z.core.$strip>]>;
|
|
248
|
+
type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
|
|
249
|
+
|
|
211
250
|
type OpenRouterChatConfig = {
|
|
212
251
|
provider: string;
|
|
213
252
|
compatibility: 'strict' | 'compatible';
|
|
@@ -237,6 +276,7 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
|
|
|
237
276
|
providerMetadata?: {
|
|
238
277
|
openrouter: {
|
|
239
278
|
provider: string;
|
|
279
|
+
reasoning_details?: ReasoningDetailUnion[];
|
|
240
280
|
usage: OpenRouterUsageAccounting;
|
|
241
281
|
};
|
|
242
282
|
};
|
|
@@ -286,7 +326,7 @@ declare class OpenRouterCompletionLanguageModel implements LanguageModelV2 {
|
|
|
286
326
|
doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
287
327
|
}
|
|
288
328
|
|
|
289
|
-
interface OpenRouterProvider extends
|
|
329
|
+
interface OpenRouterProvider extends ProviderV2 {
|
|
290
330
|
(modelId: OpenRouterChatModelId, settings?: OpenRouterCompletionSettings): OpenRouterCompletionLanguageModel;
|
|
291
331
|
(modelId: OpenRouterChatModelId, settings?: OpenRouterChatSettings): OpenRouterChatLanguageModel;
|
|
292
332
|
languageModel(modelId: OpenRouterChatModelId, settings?: OpenRouterCompletionSettings): OpenRouterCompletionLanguageModel;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
1
|
+
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart, ProviderV2 } from '@ai-sdk/provider';
|
|
2
2
|
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
|
+
import * as models from '@openrouter/sdk/models';
|
|
4
|
+
import { z } from 'zod/v4';
|
|
3
5
|
|
|
4
6
|
type OpenRouterChatModelId = string;
|
|
5
7
|
type OpenRouterChatSettings = {
|
|
@@ -40,18 +42,21 @@ type OpenRouterChatSettings = {
|
|
|
40
42
|
*/
|
|
41
43
|
user?: string;
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
45
|
+
* Plugin configurations for enabling various capabilities
|
|
44
46
|
*/
|
|
45
47
|
plugins?: Array<{
|
|
46
|
-
id:
|
|
47
|
-
/**
|
|
48
|
-
* Maximum number of search results to include (default: 5)
|
|
49
|
-
*/
|
|
48
|
+
id: models.IdWeb;
|
|
50
49
|
max_results?: number;
|
|
51
|
-
/**
|
|
52
|
-
* Custom search prompt to guide the search query
|
|
53
|
-
*/
|
|
54
50
|
search_prompt?: string;
|
|
51
|
+
engine?: models.Engine;
|
|
52
|
+
} | {
|
|
53
|
+
id: models.IdFileParser;
|
|
54
|
+
max_files?: number;
|
|
55
|
+
pdf?: {
|
|
56
|
+
engine?: models.PdfEngine;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
id: models.IdModeration;
|
|
55
60
|
}>;
|
|
56
61
|
/**
|
|
57
62
|
* Built-in web search options for models that support native web search
|
|
@@ -85,7 +90,7 @@ type OpenRouterChatSettings = {
|
|
|
85
90
|
/**
|
|
86
91
|
* Control whether to use providers that may store data
|
|
87
92
|
*/
|
|
88
|
-
data_collection?:
|
|
93
|
+
data_collection?: models.DataCollection;
|
|
89
94
|
/**
|
|
90
95
|
* List of provider slugs to allow for this request
|
|
91
96
|
*/
|
|
@@ -97,11 +102,11 @@ type OpenRouterChatSettings = {
|
|
|
97
102
|
/**
|
|
98
103
|
* List of quantization levels to filter by (e.g. ["int4", "int8"])
|
|
99
104
|
*/
|
|
100
|
-
quantizations?: Array<
|
|
105
|
+
quantizations?: Array<models.Quantization>;
|
|
101
106
|
/**
|
|
102
107
|
* Sort providers by price, throughput, or latency
|
|
103
108
|
*/
|
|
104
|
-
sort?:
|
|
109
|
+
sort?: models.Sort;
|
|
105
110
|
/**
|
|
106
111
|
* Maximum pricing you want to pay for this request
|
|
107
112
|
*/
|
|
@@ -208,6 +213,40 @@ type OpenRouterCompletionSettings = {
|
|
|
208
213
|
suffix?: string;
|
|
209
214
|
} & OpenRouterSharedSettings;
|
|
210
215
|
|
|
216
|
+
declare enum ReasoningFormat {
|
|
217
|
+
Unknown = "unknown",
|
|
218
|
+
OpenAIResponsesV1 = "openai-responses-v1",
|
|
219
|
+
XAIResponsesV1 = "xai-responses-v1",
|
|
220
|
+
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare enum ReasoningDetailType {
|
|
224
|
+
Summary = "reasoning.summary",
|
|
225
|
+
Encrypted = "reasoning.encrypted",
|
|
226
|
+
Text = "reasoning.text"
|
|
227
|
+
}
|
|
228
|
+
declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
229
|
+
type: z.ZodLiteral<ReasoningDetailType.Summary>;
|
|
230
|
+
summary: z.ZodString;
|
|
231
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
232
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
233
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
235
|
+
type: z.ZodLiteral<ReasoningDetailType.Encrypted>;
|
|
236
|
+
data: z.ZodString;
|
|
237
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
238
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
239
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
240
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
241
|
+
type: z.ZodLiteral<ReasoningDetailType.Text>;
|
|
242
|
+
text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
243
|
+
signature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
244
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
245
|
+
format: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof ReasoningFormat>>>;
|
|
246
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
247
|
+
}, z.core.$strip>]>;
|
|
248
|
+
type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
|
|
249
|
+
|
|
211
250
|
type OpenRouterChatConfig = {
|
|
212
251
|
provider: string;
|
|
213
252
|
compatibility: 'strict' | 'compatible';
|
|
@@ -237,6 +276,7 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
|
|
|
237
276
|
providerMetadata?: {
|
|
238
277
|
openrouter: {
|
|
239
278
|
provider: string;
|
|
279
|
+
reasoning_details?: ReasoningDetailUnion[];
|
|
240
280
|
usage: OpenRouterUsageAccounting;
|
|
241
281
|
};
|
|
242
282
|
};
|
|
@@ -286,7 +326,7 @@ declare class OpenRouterCompletionLanguageModel implements LanguageModelV2 {
|
|
|
286
326
|
doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
287
327
|
}
|
|
288
328
|
|
|
289
|
-
interface OpenRouterProvider extends
|
|
329
|
+
interface OpenRouterProvider extends ProviderV2 {
|
|
290
330
|
(modelId: OpenRouterChatModelId, settings?: OpenRouterCompletionSettings): OpenRouterCompletionLanguageModel;
|
|
291
331
|
(modelId: OpenRouterChatModelId, settings?: OpenRouterChatSettings): OpenRouterChatLanguageModel;
|
|
292
332
|
languageModel(modelId: OpenRouterChatModelId, settings?: OpenRouterCompletionSettings): OpenRouterCompletionLanguageModel;
|