@openrouter/ai-sdk-provider 1.4.0 → 1.4.1

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.
@@ -38,125 +38,6 @@ declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
38
38
  }, z.core.$strip>]>;
39
39
  type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
40
40
 
41
- type OpenRouterProviderOptions = {
42
- models?: string[];
43
- /**
44
- * https://openrouter.ai/docs/use-cases/reasoning-tokens
45
- * One of `max_tokens` or `effort` is required.
46
- * If `exclude` is true, reasoning will be removed from the response. Default is false.
47
- */
48
- reasoning?: {
49
- enabled?: boolean;
50
- exclude?: boolean;
51
- } & ({
52
- max_tokens: number;
53
- } | {
54
- effort: 'high' | 'medium' | 'low';
55
- });
56
- /**
57
- * A unique identifier representing your end-user, which can
58
- * help OpenRouter to monitor and detect abuse.
59
- */
60
- user?: string;
61
- };
62
- type OpenRouterSharedSettings = OpenRouterProviderOptions & {
63
- /**
64
- * @deprecated use `reasoning` instead
65
- */
66
- includeReasoning?: boolean;
67
- extraBody?: Record<string, unknown>;
68
- /**
69
- * Enable usage accounting to get detailed token usage information.
70
- * https://openrouter.ai/docs/use-cases/usage-accounting
71
- */
72
- usage?: {
73
- /**
74
- * When true, includes token usage information in the response.
75
- */
76
- include: boolean;
77
- };
78
- };
79
- /**
80
- * Usage accounting response
81
- * @see https://openrouter.ai/docs/use-cases/usage-accounting
82
- */
83
- type OpenRouterUsageAccounting = {
84
- promptTokens: number;
85
- promptTokensDetails?: {
86
- cachedTokens: number;
87
- };
88
- completionTokens: number;
89
- completionTokensDetails?: {
90
- reasoningTokens: number;
91
- };
92
- totalTokens: number;
93
- cost?: number;
94
- costDetails?: {
95
- upstreamInferenceCost: number;
96
- };
97
- };
98
-
99
- type OpenRouterCompletionModelId = string;
100
- type OpenRouterCompletionSettings = {
101
- /**
102
- Modify the likelihood of specified tokens appearing in the completion.
103
-
104
- Accepts a JSON object that maps tokens (specified by their token ID in
105
- the GPT tokenizer) to an associated bias value from -100 to 100. You
106
- can use this tokenizer tool to convert text to token IDs. Mathematically,
107
- the bias is added to the logits generated by the model prior to sampling.
108
- The exact effect will vary per model, but values between -1 and 1 should
109
- decrease or increase likelihood of selection; values like -100 or 100
110
- should result in a ban or exclusive selection of the relevant token.
111
-
112
- As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
113
- token from being generated.
114
- */
115
- logitBias?: Record<number, number>;
116
- /**
117
- Return the log probabilities of the tokens. Including logprobs will increase
118
- the response size and can slow down response times. However, it can
119
- be useful to better understand how the model is behaving.
120
-
121
- Setting to true will return the log probabilities of the tokens that
122
- were generated.
123
-
124
- Setting to a number will return the log probabilities of the top n
125
- tokens that were generated.
126
- */
127
- logprobs?: boolean | number;
128
- /**
129
- The suffix that comes after a completion of inserted text.
130
- */
131
- suffix?: string;
132
- } & OpenRouterSharedSettings;
133
-
134
- type OpenRouterCompletionConfig = {
135
- provider: string;
136
- compatibility: 'strict' | 'compatible';
137
- headers: () => Record<string, string | undefined>;
138
- url: (options: {
139
- modelId: string;
140
- path: string;
141
- }) => string;
142
- fetch?: typeof fetch;
143
- extraBody?: Record<string, unknown>;
144
- };
145
- declare class OpenRouterCompletionLanguageModel implements LanguageModelV2 {
146
- readonly specificationVersion: "v2";
147
- readonly provider = "openrouter";
148
- readonly modelId: OpenRouterCompletionModelId;
149
- readonly supportsImageUrls = true;
150
- readonly supportedUrls: Record<string, RegExp[]>;
151
- readonly defaultObjectGenerationMode: undefined;
152
- readonly settings: OpenRouterCompletionSettings;
153
- private readonly config;
154
- constructor(modelId: OpenRouterCompletionModelId, settings: OpenRouterCompletionSettings, config: OpenRouterCompletionConfig);
155
- private getArgs;
156
- doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
157
- doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
158
- }
159
-
160
41
  type OpenRouterChatModelId = string;
161
42
  type OpenRouterChatSettings = {
162
43
  /**
@@ -224,6 +105,14 @@ type OpenRouterChatSettings = {
224
105
  * Custom search prompt to guide the search query
225
106
  */
226
107
  search_prompt?: string;
108
+ /**
109
+ * Search engine to use for web search
110
+ * - "native": Use provider's built-in web search
111
+ * - "exa": Use Exa's search API
112
+ * - undefined: Native if supported, otherwise Exa
113
+ * @see https://openrouter.ai/docs/features/web-search
114
+ */
115
+ engine?: models.Engine;
227
116
  };
228
117
  /**
229
118
  * Debug options for troubleshooting API requests.
@@ -284,9 +173,185 @@ type OpenRouterChatSettings = {
284
173
  audio?: number | string;
285
174
  request?: number | string;
286
175
  };
176
+ /**
177
+ * Whether to restrict routing to only ZDR (Zero Data Retention) endpoints.
178
+ * When true, only endpoints that do not retain prompts will be used.
179
+ */
180
+ zdr?: boolean;
181
+ };
182
+ } & OpenRouterSharedSettings;
183
+
184
+ type OpenRouterCompletionModelId = string;
185
+ type OpenRouterCompletionSettings = {
186
+ /**
187
+ Modify the likelihood of specified tokens appearing in the completion.
188
+
189
+ Accepts a JSON object that maps tokens (specified by their token ID in
190
+ the GPT tokenizer) to an associated bias value from -100 to 100. You
191
+ can use this tokenizer tool to convert text to token IDs. Mathematically,
192
+ the bias is added to the logits generated by the model prior to sampling.
193
+ The exact effect will vary per model, but values between -1 and 1 should
194
+ decrease or increase likelihood of selection; values like -100 or 100
195
+ should result in a ban or exclusive selection of the relevant token.
196
+
197
+ As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
198
+ token from being generated.
199
+ */
200
+ logitBias?: Record<number, number>;
201
+ /**
202
+ Return the log probabilities of the tokens. Including logprobs will increase
203
+ the response size and can slow down response times. However, it can
204
+ be useful to better understand how the model is behaving.
205
+
206
+ Setting to true will return the log probabilities of the tokens that
207
+ were generated.
208
+
209
+ Setting to a number will return the log probabilities of the top n
210
+ tokens that were generated.
211
+ */
212
+ logprobs?: boolean | number;
213
+ /**
214
+ The suffix that comes after a completion of inserted text.
215
+ */
216
+ suffix?: string;
217
+ } & OpenRouterSharedSettings;
218
+
219
+ type OpenRouterCompletionConfig = {
220
+ provider: string;
221
+ compatibility: 'strict' | 'compatible';
222
+ headers: () => Record<string, string | undefined>;
223
+ url: (options: {
224
+ modelId: string;
225
+ path: string;
226
+ }) => string;
227
+ fetch?: typeof fetch;
228
+ extraBody?: Record<string, unknown>;
229
+ };
230
+ declare class OpenRouterCompletionLanguageModel implements LanguageModelV2 {
231
+ readonly specificationVersion: "v2";
232
+ readonly provider = "openrouter";
233
+ readonly modelId: OpenRouterCompletionModelId;
234
+ readonly supportsImageUrls = true;
235
+ readonly supportedUrls: Record<string, RegExp[]>;
236
+ readonly defaultObjectGenerationMode: undefined;
237
+ readonly settings: OpenRouterCompletionSettings;
238
+ private readonly config;
239
+ constructor(modelId: OpenRouterCompletionModelId, settings: OpenRouterCompletionSettings, config: OpenRouterCompletionConfig);
240
+ private getArgs;
241
+ doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
242
+ doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
243
+ }
244
+
245
+ type OpenRouterEmbeddingModelId = string;
246
+ type OpenRouterEmbeddingSettings = {
247
+ /**
248
+ * A unique identifier representing your end-user, which can help OpenRouter to
249
+ * monitor and detect abuse.
250
+ */
251
+ user?: string;
252
+ /**
253
+ * Provider routing preferences to control request routing behavior
254
+ */
255
+ provider?: {
256
+ /**
257
+ * List of provider slugs to try in order (e.g. ["openai", "voyageai"])
258
+ */
259
+ order?: string[];
260
+ /**
261
+ * Whether to allow backup providers when primary is unavailable (default: true)
262
+ */
263
+ allow_fallbacks?: boolean;
264
+ /**
265
+ * Only use providers that support all parameters in your request (default: false)
266
+ */
267
+ require_parameters?: boolean;
268
+ /**
269
+ * Control whether to use providers that may store data
270
+ */
271
+ data_collection?: 'allow' | 'deny';
272
+ /**
273
+ * List of provider slugs to allow for this request
274
+ */
275
+ only?: string[];
276
+ /**
277
+ * List of provider slugs to skip for this request
278
+ */
279
+ ignore?: string[];
280
+ /**
281
+ * Sort providers by price, throughput, or latency
282
+ */
283
+ sort?: 'price' | 'throughput' | 'latency';
284
+ /**
285
+ * Maximum pricing you want to pay for this request
286
+ */
287
+ max_price?: {
288
+ prompt?: number | string;
289
+ completion?: number | string;
290
+ image?: number | string;
291
+ audio?: number | string;
292
+ request?: number | string;
293
+ };
287
294
  };
288
295
  } & OpenRouterSharedSettings;
289
296
 
297
+ type OpenRouterProviderOptions = {
298
+ models?: string[];
299
+ /**
300
+ * https://openrouter.ai/docs/use-cases/reasoning-tokens
301
+ * One of `max_tokens` or `effort` is required.
302
+ * If `exclude` is true, reasoning will be removed from the response. Default is false.
303
+ */
304
+ reasoning?: {
305
+ enabled?: boolean;
306
+ exclude?: boolean;
307
+ } & ({
308
+ max_tokens: number;
309
+ } | {
310
+ effort: 'high' | 'medium' | 'low';
311
+ });
312
+ /**
313
+ * A unique identifier representing your end-user, which can
314
+ * help OpenRouter to monitor and detect abuse.
315
+ */
316
+ user?: string;
317
+ };
318
+ type OpenRouterSharedSettings = OpenRouterProviderOptions & {
319
+ /**
320
+ * @deprecated use `reasoning` instead
321
+ */
322
+ includeReasoning?: boolean;
323
+ extraBody?: Record<string, unknown>;
324
+ /**
325
+ * Enable usage accounting to get detailed token usage information.
326
+ * https://openrouter.ai/docs/use-cases/usage-accounting
327
+ */
328
+ usage?: {
329
+ /**
330
+ * When true, includes token usage information in the response.
331
+ */
332
+ include: boolean;
333
+ };
334
+ };
335
+ /**
336
+ * Usage accounting response
337
+ * @see https://openrouter.ai/docs/use-cases/usage-accounting
338
+ */
339
+ type OpenRouterUsageAccounting = {
340
+ promptTokens: number;
341
+ promptTokensDetails?: {
342
+ cachedTokens: number;
343
+ };
344
+ completionTokens: number;
345
+ completionTokensDetails?: {
346
+ reasoningTokens: number;
347
+ };
348
+ totalTokens: number;
349
+ cost?: number;
350
+ costDetails?: {
351
+ upstreamInferenceCost: number;
352
+ };
353
+ };
354
+
290
355
  type OpenRouterChatConfig = {
291
356
  provider: string;
292
357
  compatibility: 'strict' | 'compatible';
@@ -342,4 +407,4 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
342
407
  }>;
343
408
  }
344
409
 
345
- export { OpenRouterChatLanguageModel, type OpenRouterChatModelId, type OpenRouterChatSettings, OpenRouterCompletionLanguageModel, type OpenRouterCompletionModelId, type OpenRouterCompletionSettings, type OpenRouterProviderOptions, type OpenRouterSharedSettings, type OpenRouterUsageAccounting };
410
+ export { OpenRouterChatLanguageModel, type OpenRouterChatModelId, type OpenRouterChatSettings, OpenRouterCompletionLanguageModel, type OpenRouterCompletionModelId, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProviderOptions, type OpenRouterSharedSettings, type OpenRouterUsageAccounting };
@@ -38,125 +38,6 @@ declare const ReasoningDetailUnionSchema: z.ZodUnion<readonly [z.ZodObject<{
38
38
  }, z.core.$strip>]>;
39
39
  type ReasoningDetailUnion = z.infer<typeof ReasoningDetailUnionSchema>;
40
40
 
41
- type OpenRouterProviderOptions = {
42
- models?: string[];
43
- /**
44
- * https://openrouter.ai/docs/use-cases/reasoning-tokens
45
- * One of `max_tokens` or `effort` is required.
46
- * If `exclude` is true, reasoning will be removed from the response. Default is false.
47
- */
48
- reasoning?: {
49
- enabled?: boolean;
50
- exclude?: boolean;
51
- } & ({
52
- max_tokens: number;
53
- } | {
54
- effort: 'high' | 'medium' | 'low';
55
- });
56
- /**
57
- * A unique identifier representing your end-user, which can
58
- * help OpenRouter to monitor and detect abuse.
59
- */
60
- user?: string;
61
- };
62
- type OpenRouterSharedSettings = OpenRouterProviderOptions & {
63
- /**
64
- * @deprecated use `reasoning` instead
65
- */
66
- includeReasoning?: boolean;
67
- extraBody?: Record<string, unknown>;
68
- /**
69
- * Enable usage accounting to get detailed token usage information.
70
- * https://openrouter.ai/docs/use-cases/usage-accounting
71
- */
72
- usage?: {
73
- /**
74
- * When true, includes token usage information in the response.
75
- */
76
- include: boolean;
77
- };
78
- };
79
- /**
80
- * Usage accounting response
81
- * @see https://openrouter.ai/docs/use-cases/usage-accounting
82
- */
83
- type OpenRouterUsageAccounting = {
84
- promptTokens: number;
85
- promptTokensDetails?: {
86
- cachedTokens: number;
87
- };
88
- completionTokens: number;
89
- completionTokensDetails?: {
90
- reasoningTokens: number;
91
- };
92
- totalTokens: number;
93
- cost?: number;
94
- costDetails?: {
95
- upstreamInferenceCost: number;
96
- };
97
- };
98
-
99
- type OpenRouterCompletionModelId = string;
100
- type OpenRouterCompletionSettings = {
101
- /**
102
- Modify the likelihood of specified tokens appearing in the completion.
103
-
104
- Accepts a JSON object that maps tokens (specified by their token ID in
105
- the GPT tokenizer) to an associated bias value from -100 to 100. You
106
- can use this tokenizer tool to convert text to token IDs. Mathematically,
107
- the bias is added to the logits generated by the model prior to sampling.
108
- The exact effect will vary per model, but values between -1 and 1 should
109
- decrease or increase likelihood of selection; values like -100 or 100
110
- should result in a ban or exclusive selection of the relevant token.
111
-
112
- As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
113
- token from being generated.
114
- */
115
- logitBias?: Record<number, number>;
116
- /**
117
- Return the log probabilities of the tokens. Including logprobs will increase
118
- the response size and can slow down response times. However, it can
119
- be useful to better understand how the model is behaving.
120
-
121
- Setting to true will return the log probabilities of the tokens that
122
- were generated.
123
-
124
- Setting to a number will return the log probabilities of the top n
125
- tokens that were generated.
126
- */
127
- logprobs?: boolean | number;
128
- /**
129
- The suffix that comes after a completion of inserted text.
130
- */
131
- suffix?: string;
132
- } & OpenRouterSharedSettings;
133
-
134
- type OpenRouterCompletionConfig = {
135
- provider: string;
136
- compatibility: 'strict' | 'compatible';
137
- headers: () => Record<string, string | undefined>;
138
- url: (options: {
139
- modelId: string;
140
- path: string;
141
- }) => string;
142
- fetch?: typeof fetch;
143
- extraBody?: Record<string, unknown>;
144
- };
145
- declare class OpenRouterCompletionLanguageModel implements LanguageModelV2 {
146
- readonly specificationVersion: "v2";
147
- readonly provider = "openrouter";
148
- readonly modelId: OpenRouterCompletionModelId;
149
- readonly supportsImageUrls = true;
150
- readonly supportedUrls: Record<string, RegExp[]>;
151
- readonly defaultObjectGenerationMode: undefined;
152
- readonly settings: OpenRouterCompletionSettings;
153
- private readonly config;
154
- constructor(modelId: OpenRouterCompletionModelId, settings: OpenRouterCompletionSettings, config: OpenRouterCompletionConfig);
155
- private getArgs;
156
- doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
157
- doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
158
- }
159
-
160
41
  type OpenRouterChatModelId = string;
161
42
  type OpenRouterChatSettings = {
162
43
  /**
@@ -224,6 +105,14 @@ type OpenRouterChatSettings = {
224
105
  * Custom search prompt to guide the search query
225
106
  */
226
107
  search_prompt?: string;
108
+ /**
109
+ * Search engine to use for web search
110
+ * - "native": Use provider's built-in web search
111
+ * - "exa": Use Exa's search API
112
+ * - undefined: Native if supported, otherwise Exa
113
+ * @see https://openrouter.ai/docs/features/web-search
114
+ */
115
+ engine?: models.Engine;
227
116
  };
228
117
  /**
229
118
  * Debug options for troubleshooting API requests.
@@ -284,9 +173,185 @@ type OpenRouterChatSettings = {
284
173
  audio?: number | string;
285
174
  request?: number | string;
286
175
  };
176
+ /**
177
+ * Whether to restrict routing to only ZDR (Zero Data Retention) endpoints.
178
+ * When true, only endpoints that do not retain prompts will be used.
179
+ */
180
+ zdr?: boolean;
181
+ };
182
+ } & OpenRouterSharedSettings;
183
+
184
+ type OpenRouterCompletionModelId = string;
185
+ type OpenRouterCompletionSettings = {
186
+ /**
187
+ Modify the likelihood of specified tokens appearing in the completion.
188
+
189
+ Accepts a JSON object that maps tokens (specified by their token ID in
190
+ the GPT tokenizer) to an associated bias value from -100 to 100. You
191
+ can use this tokenizer tool to convert text to token IDs. Mathematically,
192
+ the bias is added to the logits generated by the model prior to sampling.
193
+ The exact effect will vary per model, but values between -1 and 1 should
194
+ decrease or increase likelihood of selection; values like -100 or 100
195
+ should result in a ban or exclusive selection of the relevant token.
196
+
197
+ As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
198
+ token from being generated.
199
+ */
200
+ logitBias?: Record<number, number>;
201
+ /**
202
+ Return the log probabilities of the tokens. Including logprobs will increase
203
+ the response size and can slow down response times. However, it can
204
+ be useful to better understand how the model is behaving.
205
+
206
+ Setting to true will return the log probabilities of the tokens that
207
+ were generated.
208
+
209
+ Setting to a number will return the log probabilities of the top n
210
+ tokens that were generated.
211
+ */
212
+ logprobs?: boolean | number;
213
+ /**
214
+ The suffix that comes after a completion of inserted text.
215
+ */
216
+ suffix?: string;
217
+ } & OpenRouterSharedSettings;
218
+
219
+ type OpenRouterCompletionConfig = {
220
+ provider: string;
221
+ compatibility: 'strict' | 'compatible';
222
+ headers: () => Record<string, string | undefined>;
223
+ url: (options: {
224
+ modelId: string;
225
+ path: string;
226
+ }) => string;
227
+ fetch?: typeof fetch;
228
+ extraBody?: Record<string, unknown>;
229
+ };
230
+ declare class OpenRouterCompletionLanguageModel implements LanguageModelV2 {
231
+ readonly specificationVersion: "v2";
232
+ readonly provider = "openrouter";
233
+ readonly modelId: OpenRouterCompletionModelId;
234
+ readonly supportsImageUrls = true;
235
+ readonly supportedUrls: Record<string, RegExp[]>;
236
+ readonly defaultObjectGenerationMode: undefined;
237
+ readonly settings: OpenRouterCompletionSettings;
238
+ private readonly config;
239
+ constructor(modelId: OpenRouterCompletionModelId, settings: OpenRouterCompletionSettings, config: OpenRouterCompletionConfig);
240
+ private getArgs;
241
+ doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
242
+ doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
243
+ }
244
+
245
+ type OpenRouterEmbeddingModelId = string;
246
+ type OpenRouterEmbeddingSettings = {
247
+ /**
248
+ * A unique identifier representing your end-user, which can help OpenRouter to
249
+ * monitor and detect abuse.
250
+ */
251
+ user?: string;
252
+ /**
253
+ * Provider routing preferences to control request routing behavior
254
+ */
255
+ provider?: {
256
+ /**
257
+ * List of provider slugs to try in order (e.g. ["openai", "voyageai"])
258
+ */
259
+ order?: string[];
260
+ /**
261
+ * Whether to allow backup providers when primary is unavailable (default: true)
262
+ */
263
+ allow_fallbacks?: boolean;
264
+ /**
265
+ * Only use providers that support all parameters in your request (default: false)
266
+ */
267
+ require_parameters?: boolean;
268
+ /**
269
+ * Control whether to use providers that may store data
270
+ */
271
+ data_collection?: 'allow' | 'deny';
272
+ /**
273
+ * List of provider slugs to allow for this request
274
+ */
275
+ only?: string[];
276
+ /**
277
+ * List of provider slugs to skip for this request
278
+ */
279
+ ignore?: string[];
280
+ /**
281
+ * Sort providers by price, throughput, or latency
282
+ */
283
+ sort?: 'price' | 'throughput' | 'latency';
284
+ /**
285
+ * Maximum pricing you want to pay for this request
286
+ */
287
+ max_price?: {
288
+ prompt?: number | string;
289
+ completion?: number | string;
290
+ image?: number | string;
291
+ audio?: number | string;
292
+ request?: number | string;
293
+ };
287
294
  };
288
295
  } & OpenRouterSharedSettings;
289
296
 
297
+ type OpenRouterProviderOptions = {
298
+ models?: string[];
299
+ /**
300
+ * https://openrouter.ai/docs/use-cases/reasoning-tokens
301
+ * One of `max_tokens` or `effort` is required.
302
+ * If `exclude` is true, reasoning will be removed from the response. Default is false.
303
+ */
304
+ reasoning?: {
305
+ enabled?: boolean;
306
+ exclude?: boolean;
307
+ } & ({
308
+ max_tokens: number;
309
+ } | {
310
+ effort: 'high' | 'medium' | 'low';
311
+ });
312
+ /**
313
+ * A unique identifier representing your end-user, which can
314
+ * help OpenRouter to monitor and detect abuse.
315
+ */
316
+ user?: string;
317
+ };
318
+ type OpenRouterSharedSettings = OpenRouterProviderOptions & {
319
+ /**
320
+ * @deprecated use `reasoning` instead
321
+ */
322
+ includeReasoning?: boolean;
323
+ extraBody?: Record<string, unknown>;
324
+ /**
325
+ * Enable usage accounting to get detailed token usage information.
326
+ * https://openrouter.ai/docs/use-cases/usage-accounting
327
+ */
328
+ usage?: {
329
+ /**
330
+ * When true, includes token usage information in the response.
331
+ */
332
+ include: boolean;
333
+ };
334
+ };
335
+ /**
336
+ * Usage accounting response
337
+ * @see https://openrouter.ai/docs/use-cases/usage-accounting
338
+ */
339
+ type OpenRouterUsageAccounting = {
340
+ promptTokens: number;
341
+ promptTokensDetails?: {
342
+ cachedTokens: number;
343
+ };
344
+ completionTokens: number;
345
+ completionTokensDetails?: {
346
+ reasoningTokens: number;
347
+ };
348
+ totalTokens: number;
349
+ cost?: number;
350
+ costDetails?: {
351
+ upstreamInferenceCost: number;
352
+ };
353
+ };
354
+
290
355
  type OpenRouterChatConfig = {
291
356
  provider: string;
292
357
  compatibility: 'strict' | 'compatible';
@@ -342,4 +407,4 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV2 {
342
407
  }>;
343
408
  }
344
409
 
345
- export { OpenRouterChatLanguageModel, type OpenRouterChatModelId, type OpenRouterChatSettings, OpenRouterCompletionLanguageModel, type OpenRouterCompletionModelId, type OpenRouterCompletionSettings, type OpenRouterProviderOptions, type OpenRouterSharedSettings, type OpenRouterUsageAccounting };
410
+ export { OpenRouterChatLanguageModel, type OpenRouterChatModelId, type OpenRouterChatSettings, OpenRouterCompletionLanguageModel, type OpenRouterCompletionModelId, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProviderOptions, type OpenRouterSharedSettings, type OpenRouterUsageAccounting };
@@ -1597,7 +1597,16 @@ var OpenRouterChatLanguageModel = class {
1597
1597
  presence_penalty: presencePenalty,
1598
1598
  seed,
1599
1599
  stop: stopSequences,
1600
- response_format: responseFormat,
1600
+ response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
1601
+ type: "json_schema",
1602
+ json_schema: __spreadValues({
1603
+ schema: responseFormat.schema,
1604
+ strict: true,
1605
+ name: (_a15 = responseFormat.name) != null ? _a15 : "response"
1606
+ }, responseFormat.description && {
1607
+ description: responseFormat.description
1608
+ })
1609
+ } : { type: "json_object" } : void 0,
1601
1610
  top_k: topK,
1602
1611
  // messages:
1603
1612
  messages: convertToOpenRouterChatMessages(prompt),
@@ -1613,20 +1622,6 @@ var OpenRouterChatLanguageModel = class {
1613
1622
  // Debug settings:
1614
1623
  debug: this.settings.debug
1615
1624
  }, this.config.extraBody), this.settings.extraBody);
1616
- if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
1617
- return __spreadProps(__spreadValues({}, baseArgs), {
1618
- response_format: {
1619
- type: "json_schema",
1620
- json_schema: __spreadValues({
1621
- schema: responseFormat.schema,
1622
- strict: true,
1623
- name: (_a15 = responseFormat.name) != null ? _a15 : "response"
1624
- }, responseFormat.description && {
1625
- description: responseFormat.description
1626
- })
1627
- }
1628
- });
1629
- }
1630
1625
  if (tools && tools.length > 0) {
1631
1626
  const mappedTools = tools.filter(
1632
1627
  (tool) => tool.type === "function"