@openrouter/sdk 0.0.1-beta.12 → 0.0.1-beta.16
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/FUNCTIONS.md +15 -16
- package/REACT_QUERY.md +15 -16
- package/README.md +138 -110
- package/esm/funcs/betaResponsesSend.d.ts +2 -2
- package/esm/funcs/betaResponsesSend.js +3 -3
- package/esm/funcs/chatSend.d.ts +1 -1
- package/esm/funcs/modelsList.d.ts +2 -1
- package/esm/funcs/modelsList.js +3 -6
- package/esm/funcs/oAuthCreateAuthCode.d.ts +18 -0
- package/esm/funcs/oAuthCreateAuthCode.js +82 -0
- package/esm/funcs/oAuthCreateAuthorizationUrl.d.ts +2 -2
- package/esm/funcs/oAuthExchangeAuthCodeForAPIKey.d.ts +18 -0
- package/esm/funcs/oAuthExchangeAuthCodeForAPIKey.js +82 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/lib/event-streams.d.ts +1 -1
- package/esm/models/chatgenerationtokenusage.d.ts +2 -2
- package/esm/models/chatgenerationtokenusage.js +2 -4
- package/esm/models/operations/createauthkeyscode.d.ts +145 -0
- package/esm/models/operations/createauthkeyscode.js +146 -0
- package/esm/models/operations/createresponses.d.ts +58 -0
- package/esm/models/operations/createresponses.js +80 -0
- package/esm/models/operations/exchangeauthcodeforapikey.d.ts +104 -0
- package/esm/models/operations/exchangeauthcodeforapikey.js +111 -0
- package/esm/models/operations/getmodels.d.ts +0 -26
- package/esm/models/operations/getmodels.js +0 -30
- package/esm/models/operations/index.d.ts +3 -1
- package/esm/models/operations/index.js +3 -1
- package/esm/models/operations/sendchatcompletionrequest.d.ts +1 -1
- package/esm/models/operations/sendchatcompletionrequest.js +2 -1
- package/esm/react-query/betaResponsesSend.d.ts +1 -1
- package/esm/react-query/index.d.ts +2 -0
- package/esm/react-query/index.js +2 -0
- package/esm/react-query/modelsList.d.ts +2 -7
- package/esm/react-query/modelsList.js +0 -2
- package/esm/react-query/oAuthCreateAuthCode.d.ts +23 -0
- package/esm/react-query/oAuthCreateAuthCode.js +42 -0
- package/esm/react-query/oAuthExchangeAuthCodeForAPIKey.d.ts +23 -0
- package/esm/react-query/oAuthExchangeAuthCodeForAPIKey.js +42 -0
- package/esm/sdk/chat.d.ts +1 -1
- package/esm/sdk/models.d.ts +1 -1
- package/esm/sdk/oauth.d.ts +46 -0
- package/esm/sdk/oauth.js +67 -0
- package/esm/sdk/responses.d.ts +2 -2
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.js +4 -0
- package/jsr.json +1 -1
- package/package.json +3 -1
- package/vitest.config.ts +16 -1
- package/esm/models/operations/createapialpharesponses.d.ts +0 -58
- package/esm/models/operations/createapialpharesponses.js +0 -81
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ The [OpenRouter](https://openrouter.ai/) SDK gives access to over 300 large lang
|
|
|
20
20
|
* [Error Handling](#error-handling)
|
|
21
21
|
* [Debugging](#debugging)
|
|
22
22
|
* [Development](#development)
|
|
23
|
+
* [Running Tests](#running-tests)
|
|
23
24
|
* [Maturity](#maturity)
|
|
24
25
|
* [Contributions](#contributions)
|
|
25
26
|
|
|
@@ -123,7 +124,6 @@ async function run() {
|
|
|
123
124
|
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
124
125
|
models: [
|
|
125
126
|
"<value 1>",
|
|
126
|
-
"<value 2>",
|
|
127
127
|
],
|
|
128
128
|
text: {
|
|
129
129
|
format: {
|
|
@@ -132,15 +132,15 @@ async function run() {
|
|
|
132
132
|
verbosity: "medium",
|
|
133
133
|
},
|
|
134
134
|
reasoning: {
|
|
135
|
-
effort: "
|
|
135
|
+
effort: "high",
|
|
136
136
|
summary: "auto",
|
|
137
|
-
maxTokens:
|
|
137
|
+
maxTokens: 8661.16,
|
|
138
138
|
enabled: true,
|
|
139
139
|
},
|
|
140
|
-
maxOutputTokens:
|
|
140
|
+
maxOutputTokens: null,
|
|
141
141
|
temperature: 0.7,
|
|
142
142
|
topP: 0.9,
|
|
143
|
-
topK:
|
|
143
|
+
topK: 193.77,
|
|
144
144
|
promptCacheKey: "<value>",
|
|
145
145
|
previousResponseId: "<id>",
|
|
146
146
|
prompt: {
|
|
@@ -153,25 +153,25 @@ async function run() {
|
|
|
153
153
|
},
|
|
154
154
|
},
|
|
155
155
|
include: [
|
|
156
|
-
"
|
|
156
|
+
"reasoning.encrypted_content",
|
|
157
157
|
],
|
|
158
|
-
background:
|
|
158
|
+
background: true,
|
|
159
159
|
safetyIdentifier: "<value>",
|
|
160
|
-
store:
|
|
160
|
+
store: true,
|
|
161
161
|
serviceTier: "auto",
|
|
162
162
|
truncation: "auto",
|
|
163
163
|
provider: {
|
|
164
|
-
allowFallbacks:
|
|
165
|
-
requireParameters:
|
|
164
|
+
allowFallbacks: null,
|
|
165
|
+
requireParameters: true,
|
|
166
166
|
dataCollection: "deny",
|
|
167
167
|
zdr: true,
|
|
168
168
|
order: [
|
|
169
169
|
"OpenAI",
|
|
170
170
|
],
|
|
171
|
-
only:
|
|
172
|
-
ignore: [
|
|
171
|
+
only: [
|
|
173
172
|
"OpenAI",
|
|
174
173
|
],
|
|
174
|
+
ignore: null,
|
|
175
175
|
quantizations: [
|
|
176
176
|
"fp16",
|
|
177
177
|
],
|
|
@@ -180,7 +180,7 @@ async function run() {
|
|
|
180
180
|
prompt: "1000",
|
|
181
181
|
completion: 1000,
|
|
182
182
|
image: 1000,
|
|
183
|
-
audio: 1000,
|
|
183
|
+
audio: "1000",
|
|
184
184
|
request: 1000,
|
|
185
185
|
},
|
|
186
186
|
experimental: {},
|
|
@@ -188,13 +188,13 @@ async function run() {
|
|
|
188
188
|
plugins: [
|
|
189
189
|
{
|
|
190
190
|
id: "file-parser",
|
|
191
|
-
maxFiles:
|
|
191
|
+
maxFiles: 4870.55,
|
|
192
192
|
pdf: {
|
|
193
|
-
engine: "
|
|
193
|
+
engine: "mistral-ocr",
|
|
194
194
|
},
|
|
195
195
|
},
|
|
196
196
|
],
|
|
197
|
-
user: "
|
|
197
|
+
user: "Elmer_Yundt72",
|
|
198
198
|
});
|
|
199
199
|
|
|
200
200
|
console.log(result);
|
|
@@ -262,7 +262,6 @@ async function run() {
|
|
|
262
262
|
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
263
263
|
models: [
|
|
264
264
|
"<value 1>",
|
|
265
|
-
"<value 2>",
|
|
266
265
|
],
|
|
267
266
|
text: {
|
|
268
267
|
format: {
|
|
@@ -271,15 +270,15 @@ async function run() {
|
|
|
271
270
|
verbosity: "medium",
|
|
272
271
|
},
|
|
273
272
|
reasoning: {
|
|
274
|
-
effort: "
|
|
273
|
+
effort: "high",
|
|
275
274
|
summary: "auto",
|
|
276
|
-
maxTokens:
|
|
275
|
+
maxTokens: 8661.16,
|
|
277
276
|
enabled: true,
|
|
278
277
|
},
|
|
279
|
-
maxOutputTokens:
|
|
278
|
+
maxOutputTokens: null,
|
|
280
279
|
temperature: 0.7,
|
|
281
280
|
topP: 0.9,
|
|
282
|
-
topK:
|
|
281
|
+
topK: 193.77,
|
|
283
282
|
promptCacheKey: "<value>",
|
|
284
283
|
previousResponseId: "<id>",
|
|
285
284
|
prompt: {
|
|
@@ -292,25 +291,25 @@ async function run() {
|
|
|
292
291
|
},
|
|
293
292
|
},
|
|
294
293
|
include: [
|
|
295
|
-
"
|
|
294
|
+
"reasoning.encrypted_content",
|
|
296
295
|
],
|
|
297
|
-
background:
|
|
296
|
+
background: true,
|
|
298
297
|
safetyIdentifier: "<value>",
|
|
299
|
-
store:
|
|
298
|
+
store: true,
|
|
300
299
|
serviceTier: "auto",
|
|
301
300
|
truncation: "auto",
|
|
302
301
|
provider: {
|
|
303
|
-
allowFallbacks:
|
|
304
|
-
requireParameters:
|
|
302
|
+
allowFallbacks: null,
|
|
303
|
+
requireParameters: true,
|
|
305
304
|
dataCollection: "deny",
|
|
306
305
|
zdr: true,
|
|
307
306
|
order: [
|
|
308
307
|
"OpenAI",
|
|
309
308
|
],
|
|
310
|
-
only:
|
|
311
|
-
ignore: [
|
|
309
|
+
only: [
|
|
312
310
|
"OpenAI",
|
|
313
311
|
],
|
|
312
|
+
ignore: null,
|
|
314
313
|
quantizations: [
|
|
315
314
|
"fp16",
|
|
316
315
|
],
|
|
@@ -319,7 +318,7 @@ async function run() {
|
|
|
319
318
|
prompt: "1000",
|
|
320
319
|
completion: 1000,
|
|
321
320
|
image: 1000,
|
|
322
|
-
audio: 1000,
|
|
321
|
+
audio: "1000",
|
|
323
322
|
request: 1000,
|
|
324
323
|
},
|
|
325
324
|
experimental: {},
|
|
@@ -327,13 +326,13 @@ async function run() {
|
|
|
327
326
|
plugins: [
|
|
328
327
|
{
|
|
329
328
|
id: "file-parser",
|
|
330
|
-
maxFiles:
|
|
329
|
+
maxFiles: 4870.55,
|
|
331
330
|
pdf: {
|
|
332
|
-
engine: "
|
|
331
|
+
engine: "mistral-ocr",
|
|
333
332
|
},
|
|
334
333
|
},
|
|
335
334
|
],
|
|
336
|
-
user: "
|
|
335
|
+
user: "Elmer_Yundt72",
|
|
337
336
|
});
|
|
338
337
|
|
|
339
338
|
console.log(result);
|
|
@@ -419,6 +418,11 @@ run();
|
|
|
419
418
|
* [list](docs/sdks/models/README.md#list) - List all models and their properties
|
|
420
419
|
* [listForUser](docs/sdks/models/README.md#listforuser) - List models filtered by user provider preferences
|
|
421
420
|
|
|
421
|
+
### [oAuth](docs/sdks/oauth/README.md)
|
|
422
|
+
|
|
423
|
+
* [exchangeAuthCodeForAPIKey](docs/sdks/oauth/README.md#exchangeauthcodeforapikey) - Exchange authorization code for API key
|
|
424
|
+
* [createAuthCode](docs/sdks/oauth/README.md#createauthcode) - Create authorization code
|
|
425
|
+
|
|
422
426
|
### [parameters](docs/sdks/parameters/README.md)
|
|
423
427
|
|
|
424
428
|
* [getParameters](docs/sdks/parameters/README.md#getparameters) - Get a model's supported parameters and data about which are most popular
|
|
@@ -463,6 +467,8 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
|
463
467
|
- [`modelsCount`](docs/sdks/models/README.md#count) - Get total count of available models
|
|
464
468
|
- [`modelsList`](docs/sdks/models/README.md#list) - List all models and their properties
|
|
465
469
|
- [`modelsListForUser`](docs/sdks/models/README.md#listforuser) - List models filtered by user provider preferences
|
|
470
|
+
- [`oAuthCreateAuthCode`](docs/sdks/oauth/README.md#createauthcode) - Create authorization code
|
|
471
|
+
- [`oAuthExchangeAuthCodeForAPIKey`](docs/sdks/oauth/README.md#exchangeauthcodeforapikey) - Exchange authorization code for API key
|
|
466
472
|
- [`parametersGetParameters`](docs/sdks/parameters/README.md#getparameters) - Get a model's supported parameters and data about which are most popular
|
|
467
473
|
- [`providersList`](docs/sdks/providers/README.md#list) - List all providers
|
|
468
474
|
|
|
@@ -509,6 +515,8 @@ To learn about this feature and how to get started, check
|
|
|
509
515
|
- [`useModelsCount`](docs/sdks/models/README.md#count) - Get total count of available models
|
|
510
516
|
- [`useModelsList`](docs/sdks/models/README.md#list) - List all models and their properties
|
|
511
517
|
- [`useModelsListForUser`](docs/sdks/models/README.md#listforuser) - List models filtered by user provider preferences
|
|
518
|
+
- [`useOAuthCreateAuthCodeMutation`](docs/sdks/oauth/README.md#createauthcode) - Create authorization code
|
|
519
|
+
- [`useOAuthExchangeAuthCodeForAPIKeyMutation`](docs/sdks/oauth/README.md#exchangeauthcodeforapikey) - Exchange authorization code for API key
|
|
512
520
|
- [`useParametersGetParameters`](docs/sdks/parameters/README.md#getparameters) - Get a model's supported parameters and data about which are most popular
|
|
513
521
|
- [`useProvidersList`](docs/sdks/providers/README.md#list) - List all providers
|
|
514
522
|
|
|
@@ -569,7 +577,6 @@ async function run() {
|
|
|
569
577
|
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
570
578
|
models: [
|
|
571
579
|
"<value 1>",
|
|
572
|
-
"<value 2>",
|
|
573
580
|
],
|
|
574
581
|
text: {
|
|
575
582
|
format: {
|
|
@@ -578,15 +585,15 @@ async function run() {
|
|
|
578
585
|
verbosity: "medium",
|
|
579
586
|
},
|
|
580
587
|
reasoning: {
|
|
581
|
-
effort: "
|
|
588
|
+
effort: "high",
|
|
582
589
|
summary: "auto",
|
|
583
|
-
maxTokens:
|
|
590
|
+
maxTokens: 8661.16,
|
|
584
591
|
enabled: true,
|
|
585
592
|
},
|
|
586
|
-
maxOutputTokens:
|
|
593
|
+
maxOutputTokens: null,
|
|
587
594
|
temperature: 0.7,
|
|
588
595
|
topP: 0.9,
|
|
589
|
-
topK:
|
|
596
|
+
topK: 193.77,
|
|
590
597
|
promptCacheKey: "<value>",
|
|
591
598
|
previousResponseId: "<id>",
|
|
592
599
|
prompt: {
|
|
@@ -599,25 +606,25 @@ async function run() {
|
|
|
599
606
|
},
|
|
600
607
|
},
|
|
601
608
|
include: [
|
|
602
|
-
"
|
|
609
|
+
"reasoning.encrypted_content",
|
|
603
610
|
],
|
|
604
|
-
background:
|
|
611
|
+
background: true,
|
|
605
612
|
safetyIdentifier: "<value>",
|
|
606
|
-
store:
|
|
613
|
+
store: true,
|
|
607
614
|
serviceTier: "auto",
|
|
608
615
|
truncation: "auto",
|
|
609
616
|
provider: {
|
|
610
|
-
allowFallbacks:
|
|
611
|
-
requireParameters:
|
|
617
|
+
allowFallbacks: null,
|
|
618
|
+
requireParameters: true,
|
|
612
619
|
dataCollection: "deny",
|
|
613
620
|
zdr: true,
|
|
614
621
|
order: [
|
|
615
622
|
"OpenAI",
|
|
616
623
|
],
|
|
617
|
-
only:
|
|
618
|
-
ignore: [
|
|
624
|
+
only: [
|
|
619
625
|
"OpenAI",
|
|
620
626
|
],
|
|
627
|
+
ignore: null,
|
|
621
628
|
quantizations: [
|
|
622
629
|
"fp16",
|
|
623
630
|
],
|
|
@@ -626,7 +633,7 @@ async function run() {
|
|
|
626
633
|
prompt: "1000",
|
|
627
634
|
completion: 1000,
|
|
628
635
|
image: 1000,
|
|
629
|
-
audio: 1000,
|
|
636
|
+
audio: "1000",
|
|
630
637
|
request: 1000,
|
|
631
638
|
},
|
|
632
639
|
experimental: {},
|
|
@@ -634,13 +641,13 @@ async function run() {
|
|
|
634
641
|
plugins: [
|
|
635
642
|
{
|
|
636
643
|
id: "file-parser",
|
|
637
|
-
maxFiles:
|
|
644
|
+
maxFiles: 4870.55,
|
|
638
645
|
pdf: {
|
|
639
|
-
engine: "
|
|
646
|
+
engine: "mistral-ocr",
|
|
640
647
|
},
|
|
641
648
|
},
|
|
642
649
|
],
|
|
643
|
-
user: "
|
|
650
|
+
user: "Elmer_Yundt72",
|
|
644
651
|
});
|
|
645
652
|
|
|
646
653
|
console.log(result);
|
|
@@ -705,7 +712,6 @@ async function run() {
|
|
|
705
712
|
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
706
713
|
models: [
|
|
707
714
|
"<value 1>",
|
|
708
|
-
"<value 2>",
|
|
709
715
|
],
|
|
710
716
|
text: {
|
|
711
717
|
format: {
|
|
@@ -714,15 +720,15 @@ async function run() {
|
|
|
714
720
|
verbosity: "medium",
|
|
715
721
|
},
|
|
716
722
|
reasoning: {
|
|
717
|
-
effort: "
|
|
723
|
+
effort: "high",
|
|
718
724
|
summary: "auto",
|
|
719
|
-
maxTokens:
|
|
725
|
+
maxTokens: 8661.16,
|
|
720
726
|
enabled: true,
|
|
721
727
|
},
|
|
722
|
-
maxOutputTokens:
|
|
728
|
+
maxOutputTokens: null,
|
|
723
729
|
temperature: 0.7,
|
|
724
730
|
topP: 0.9,
|
|
725
|
-
topK:
|
|
731
|
+
topK: 193.77,
|
|
726
732
|
promptCacheKey: "<value>",
|
|
727
733
|
previousResponseId: "<id>",
|
|
728
734
|
prompt: {
|
|
@@ -735,25 +741,25 @@ async function run() {
|
|
|
735
741
|
},
|
|
736
742
|
},
|
|
737
743
|
include: [
|
|
738
|
-
"
|
|
744
|
+
"reasoning.encrypted_content",
|
|
739
745
|
],
|
|
740
|
-
background:
|
|
746
|
+
background: true,
|
|
741
747
|
safetyIdentifier: "<value>",
|
|
742
|
-
store:
|
|
748
|
+
store: true,
|
|
743
749
|
serviceTier: "auto",
|
|
744
750
|
truncation: "auto",
|
|
745
751
|
provider: {
|
|
746
|
-
allowFallbacks:
|
|
747
|
-
requireParameters:
|
|
752
|
+
allowFallbacks: null,
|
|
753
|
+
requireParameters: true,
|
|
748
754
|
dataCollection: "deny",
|
|
749
755
|
zdr: true,
|
|
750
756
|
order: [
|
|
751
757
|
"OpenAI",
|
|
752
758
|
],
|
|
753
|
-
only:
|
|
754
|
-
ignore: [
|
|
759
|
+
only: [
|
|
755
760
|
"OpenAI",
|
|
756
761
|
],
|
|
762
|
+
ignore: null,
|
|
757
763
|
quantizations: [
|
|
758
764
|
"fp16",
|
|
759
765
|
],
|
|
@@ -762,7 +768,7 @@ async function run() {
|
|
|
762
768
|
prompt: "1000",
|
|
763
769
|
completion: 1000,
|
|
764
770
|
image: 1000,
|
|
765
|
-
audio: 1000,
|
|
771
|
+
audio: "1000",
|
|
766
772
|
request: 1000,
|
|
767
773
|
},
|
|
768
774
|
experimental: {},
|
|
@@ -770,13 +776,13 @@ async function run() {
|
|
|
770
776
|
plugins: [
|
|
771
777
|
{
|
|
772
778
|
id: "file-parser",
|
|
773
|
-
maxFiles:
|
|
779
|
+
maxFiles: 4870.55,
|
|
774
780
|
pdf: {
|
|
775
|
-
engine: "
|
|
781
|
+
engine: "mistral-ocr",
|
|
776
782
|
},
|
|
777
783
|
},
|
|
778
784
|
],
|
|
779
|
-
user: "
|
|
785
|
+
user: "Elmer_Yundt72",
|
|
780
786
|
}, {
|
|
781
787
|
retries: {
|
|
782
788
|
strategy: "backoff",
|
|
@@ -853,7 +859,6 @@ async function run() {
|
|
|
853
859
|
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
854
860
|
models: [
|
|
855
861
|
"<value 1>",
|
|
856
|
-
"<value 2>",
|
|
857
862
|
],
|
|
858
863
|
text: {
|
|
859
864
|
format: {
|
|
@@ -862,15 +867,15 @@ async function run() {
|
|
|
862
867
|
verbosity: "medium",
|
|
863
868
|
},
|
|
864
869
|
reasoning: {
|
|
865
|
-
effort: "
|
|
870
|
+
effort: "high",
|
|
866
871
|
summary: "auto",
|
|
867
|
-
maxTokens:
|
|
872
|
+
maxTokens: 8661.16,
|
|
868
873
|
enabled: true,
|
|
869
874
|
},
|
|
870
|
-
maxOutputTokens:
|
|
875
|
+
maxOutputTokens: null,
|
|
871
876
|
temperature: 0.7,
|
|
872
877
|
topP: 0.9,
|
|
873
|
-
topK:
|
|
878
|
+
topK: 193.77,
|
|
874
879
|
promptCacheKey: "<value>",
|
|
875
880
|
previousResponseId: "<id>",
|
|
876
881
|
prompt: {
|
|
@@ -883,25 +888,25 @@ async function run() {
|
|
|
883
888
|
},
|
|
884
889
|
},
|
|
885
890
|
include: [
|
|
886
|
-
"
|
|
891
|
+
"reasoning.encrypted_content",
|
|
887
892
|
],
|
|
888
|
-
background:
|
|
893
|
+
background: true,
|
|
889
894
|
safetyIdentifier: "<value>",
|
|
890
|
-
store:
|
|
895
|
+
store: true,
|
|
891
896
|
serviceTier: "auto",
|
|
892
897
|
truncation: "auto",
|
|
893
898
|
provider: {
|
|
894
|
-
allowFallbacks:
|
|
895
|
-
requireParameters:
|
|
899
|
+
allowFallbacks: null,
|
|
900
|
+
requireParameters: true,
|
|
896
901
|
dataCollection: "deny",
|
|
897
902
|
zdr: true,
|
|
898
903
|
order: [
|
|
899
904
|
"OpenAI",
|
|
900
905
|
],
|
|
901
|
-
only:
|
|
902
|
-
ignore: [
|
|
906
|
+
only: [
|
|
903
907
|
"OpenAI",
|
|
904
908
|
],
|
|
909
|
+
ignore: null,
|
|
905
910
|
quantizations: [
|
|
906
911
|
"fp16",
|
|
907
912
|
],
|
|
@@ -910,7 +915,7 @@ async function run() {
|
|
|
910
915
|
prompt: "1000",
|
|
911
916
|
completion: 1000,
|
|
912
917
|
image: 1000,
|
|
913
|
-
audio: 1000,
|
|
918
|
+
audio: "1000",
|
|
914
919
|
request: 1000,
|
|
915
920
|
},
|
|
916
921
|
experimental: {},
|
|
@@ -918,13 +923,13 @@ async function run() {
|
|
|
918
923
|
plugins: [
|
|
919
924
|
{
|
|
920
925
|
id: "file-parser",
|
|
921
|
-
maxFiles:
|
|
926
|
+
maxFiles: 4870.55,
|
|
922
927
|
pdf: {
|
|
923
|
-
engine: "
|
|
928
|
+
engine: "mistral-ocr",
|
|
924
929
|
},
|
|
925
930
|
},
|
|
926
931
|
],
|
|
927
|
-
user: "
|
|
932
|
+
user: "Elmer_Yundt72",
|
|
928
933
|
});
|
|
929
934
|
|
|
930
935
|
console.log(result);
|
|
@@ -997,7 +1002,6 @@ async function run() {
|
|
|
997
1002
|
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
998
1003
|
models: [
|
|
999
1004
|
"<value 1>",
|
|
1000
|
-
"<value 2>",
|
|
1001
1005
|
],
|
|
1002
1006
|
text: {
|
|
1003
1007
|
format: {
|
|
@@ -1006,15 +1010,15 @@ async function run() {
|
|
|
1006
1010
|
verbosity: "medium",
|
|
1007
1011
|
},
|
|
1008
1012
|
reasoning: {
|
|
1009
|
-
effort: "
|
|
1013
|
+
effort: "high",
|
|
1010
1014
|
summary: "auto",
|
|
1011
|
-
maxTokens:
|
|
1015
|
+
maxTokens: 8661.16,
|
|
1012
1016
|
enabled: true,
|
|
1013
1017
|
},
|
|
1014
|
-
maxOutputTokens:
|
|
1018
|
+
maxOutputTokens: null,
|
|
1015
1019
|
temperature: 0.7,
|
|
1016
1020
|
topP: 0.9,
|
|
1017
|
-
topK:
|
|
1021
|
+
topK: 193.77,
|
|
1018
1022
|
promptCacheKey: "<value>",
|
|
1019
1023
|
previousResponseId: "<id>",
|
|
1020
1024
|
prompt: {
|
|
@@ -1027,25 +1031,25 @@ async function run() {
|
|
|
1027
1031
|
},
|
|
1028
1032
|
},
|
|
1029
1033
|
include: [
|
|
1030
|
-
"
|
|
1034
|
+
"reasoning.encrypted_content",
|
|
1031
1035
|
],
|
|
1032
|
-
background:
|
|
1036
|
+
background: true,
|
|
1033
1037
|
safetyIdentifier: "<value>",
|
|
1034
|
-
store:
|
|
1038
|
+
store: true,
|
|
1035
1039
|
serviceTier: "auto",
|
|
1036
1040
|
truncation: "auto",
|
|
1037
1041
|
provider: {
|
|
1038
|
-
allowFallbacks:
|
|
1039
|
-
requireParameters:
|
|
1042
|
+
allowFallbacks: null,
|
|
1043
|
+
requireParameters: true,
|
|
1040
1044
|
dataCollection: "deny",
|
|
1041
1045
|
zdr: true,
|
|
1042
1046
|
order: [
|
|
1043
1047
|
"OpenAI",
|
|
1044
1048
|
],
|
|
1045
|
-
only:
|
|
1046
|
-
ignore: [
|
|
1049
|
+
only: [
|
|
1047
1050
|
"OpenAI",
|
|
1048
1051
|
],
|
|
1052
|
+
ignore: null,
|
|
1049
1053
|
quantizations: [
|
|
1050
1054
|
"fp16",
|
|
1051
1055
|
],
|
|
@@ -1054,7 +1058,7 @@ async function run() {
|
|
|
1054
1058
|
prompt: "1000",
|
|
1055
1059
|
completion: 1000,
|
|
1056
1060
|
image: 1000,
|
|
1057
|
-
audio: 1000,
|
|
1061
|
+
audio: "1000",
|
|
1058
1062
|
request: 1000,
|
|
1059
1063
|
},
|
|
1060
1064
|
experimental: {},
|
|
@@ -1062,13 +1066,13 @@ async function run() {
|
|
|
1062
1066
|
plugins: [
|
|
1063
1067
|
{
|
|
1064
1068
|
id: "file-parser",
|
|
1065
|
-
maxFiles:
|
|
1069
|
+
maxFiles: 4870.55,
|
|
1066
1070
|
pdf: {
|
|
1067
|
-
engine: "
|
|
1071
|
+
engine: "mistral-ocr",
|
|
1068
1072
|
},
|
|
1069
1073
|
},
|
|
1070
1074
|
],
|
|
1071
|
-
user: "
|
|
1075
|
+
user: "Elmer_Yundt72",
|
|
1072
1076
|
});
|
|
1073
1077
|
|
|
1074
1078
|
console.log(result);
|
|
@@ -1111,20 +1115,20 @@ run();
|
|
|
1111
1115
|
|
|
1112
1116
|
|
|
1113
1117
|
**Inherit from [`OpenRouterError`](./src/models/errors/openroutererror.ts)**:
|
|
1114
|
-
* [`UnauthorizedResponseError`](./src/models/errors/unauthorizedresponseerror.ts): Unauthorized - Authentication required or invalid credentials. Status code `401`. Applicable to
|
|
1115
|
-
* [`
|
|
1116
|
-
* [`
|
|
1117
|
-
* [`
|
|
1118
|
-
* [`
|
|
1119
|
-
* [`
|
|
1120
|
-
* [`
|
|
1121
|
-
* [`BadGatewayResponseError`](./src/models/errors/badgatewayresponseerror.ts): Bad Gateway - Provider/upstream API failure. Status code `502`. Applicable to 2 of
|
|
1122
|
-
* [`EdgeNetworkTimeoutResponseError`](./src/models/errors/edgenetworktimeoutresponseerror.ts): Infrastructure Timeout - Provider request timed out at edge network. Status code `524`. Applicable to 2 of
|
|
1123
|
-
* [`ProviderOverloadedResponseError`](./src/models/errors/provideroverloadedresponseerror.ts): Provider Overloaded - Provider is temporarily overloaded. Status code `529`. Applicable to 2 of
|
|
1124
|
-
* [`RequestTimeoutResponseError`](./src/models/errors/requesttimeoutresponseerror.ts): Request Timeout - Operation exceeded time limit. Status code `408`. Applicable to 1 of
|
|
1125
|
-
* [`PayloadTooLargeResponseError`](./src/models/errors/payloadtoolargeresponseerror.ts): Payload Too Large - Request payload exceeds size limits. Status code `413`. Applicable to 1 of
|
|
1126
|
-
* [`UnprocessableEntityResponseError`](./src/models/errors/unprocessableentityresponseerror.ts): Unprocessable Entity - Semantic validation failure. Status code `422`. Applicable to 1 of
|
|
1127
|
-
* [`ServiceUnavailableResponseError`](./src/models/errors/serviceunavailableresponseerror.ts): Service Unavailable - Service temporarily unavailable. Status code `503`. Applicable to 1 of
|
|
1118
|
+
* [`UnauthorizedResponseError`](./src/models/errors/unauthorizedresponseerror.ts): Unauthorized - Authentication required or invalid credentials. Status code `401`. Applicable to 14 of 22 methods.*
|
|
1119
|
+
* [`BadRequestResponseError`](./src/models/errors/badrequestresponseerror.ts): Bad Request - Invalid request parameters or malformed input. Status code `400`. Applicable to 8 of 22 methods.*
|
|
1120
|
+
* [`TooManyRequestsResponseError`](./src/models/errors/toomanyrequestsresponseerror.ts): Too Many Requests - Rate limit exceeded. Status code `429`. Applicable to 8 of 22 methods.*
|
|
1121
|
+
* [`NotFoundResponseError`](./src/models/errors/notfoundresponseerror.ts): Not Found - Resource does not exist. Status code `404`. Applicable to 7 of 22 methods.*
|
|
1122
|
+
* [`ForbiddenResponseError`](./src/models/errors/forbiddenresponseerror.ts): Forbidden - Authentication successful but insufficient permissions. Status code `403`. Applicable to 3 of 22 methods.*
|
|
1123
|
+
* [`ChatError`](./src/models/errors/chaterror.ts): Bad request - invalid parameters. Applicable to 2 of 22 methods.*
|
|
1124
|
+
* [`PaymentRequiredResponseError`](./src/models/errors/paymentrequiredresponseerror.ts): Payment Required - Insufficient credits or quota to complete request. Status code `402`. Applicable to 2 of 22 methods.*
|
|
1125
|
+
* [`BadGatewayResponseError`](./src/models/errors/badgatewayresponseerror.ts): Bad Gateway - Provider/upstream API failure. Status code `502`. Applicable to 2 of 22 methods.*
|
|
1126
|
+
* [`EdgeNetworkTimeoutResponseError`](./src/models/errors/edgenetworktimeoutresponseerror.ts): Infrastructure Timeout - Provider request timed out at edge network. Status code `524`. Applicable to 2 of 22 methods.*
|
|
1127
|
+
* [`ProviderOverloadedResponseError`](./src/models/errors/provideroverloadedresponseerror.ts): Provider Overloaded - Provider is temporarily overloaded. Status code `529`. Applicable to 2 of 22 methods.*
|
|
1128
|
+
* [`RequestTimeoutResponseError`](./src/models/errors/requesttimeoutresponseerror.ts): Request Timeout - Operation exceeded time limit. Status code `408`. Applicable to 1 of 22 methods.*
|
|
1129
|
+
* [`PayloadTooLargeResponseError`](./src/models/errors/payloadtoolargeresponseerror.ts): Payload Too Large - Request payload exceeds size limits. Status code `413`. Applicable to 1 of 22 methods.*
|
|
1130
|
+
* [`UnprocessableEntityResponseError`](./src/models/errors/unprocessableentityresponseerror.ts): Unprocessable Entity - Semantic validation failure. Status code `422`. Applicable to 1 of 22 methods.*
|
|
1131
|
+
* [`ServiceUnavailableResponseError`](./src/models/errors/serviceunavailableresponseerror.ts): Service Unavailable - Service temporarily unavailable. Status code `503`. Applicable to 1 of 22 methods.*
|
|
1128
1132
|
* [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
|
|
1129
1133
|
|
|
1130
1134
|
</details>
|
|
@@ -1159,6 +1163,30 @@ You can also enable a default debug logger by setting an environment variable `O
|
|
|
1159
1163
|
|
|
1160
1164
|
# Development
|
|
1161
1165
|
|
|
1166
|
+
## Running Tests
|
|
1167
|
+
|
|
1168
|
+
To run the test suite, you'll need to set up your environment with an OpenRouter API key.
|
|
1169
|
+
|
|
1170
|
+
### Local Development
|
|
1171
|
+
|
|
1172
|
+
1. Copy the example environment file:
|
|
1173
|
+
|
|
1174
|
+
```bash
|
|
1175
|
+
cp .env.example .env
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
2. Edit `.env` and add your OpenRouter API key:
|
|
1179
|
+
|
|
1180
|
+
```bash
|
|
1181
|
+
OPENROUTER_API_KEY=your_api_key_here
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
3. Run the tests:
|
|
1185
|
+
|
|
1186
|
+
```bash
|
|
1187
|
+
npx vitest
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1162
1190
|
## Maturity
|
|
1163
1191
|
|
|
1164
1192
|
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
|
@@ -21,6 +21,6 @@ export declare function betaResponsesSend(client: OpenRouterCore, request: model
|
|
|
21
21
|
}, options?: RequestOptions): APIPromise<Result<models.OpenResponsesNonStreamingResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
22
22
|
export declare function betaResponsesSend(client: OpenRouterCore, request: models.OpenResponsesRequest & {
|
|
23
23
|
stream: true;
|
|
24
|
-
}, options?: RequestOptions): APIPromise<Result<EventStream<
|
|
25
|
-
export declare function betaResponsesSend(client: OpenRouterCore, request: models.OpenResponsesRequest, options?: RequestOptions): APIPromise<Result<operations.
|
|
24
|
+
}, options?: RequestOptions): APIPromise<Result<EventStream<models.OpenResponsesStreamEvent>, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
25
|
+
export declare function betaResponsesSend(client: OpenRouterCore, request: models.OpenResponsesRequest, options?: RequestOptions): APIPromise<Result<operations.CreateResponsesResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
26
26
|
//# sourceMappingURL=betaResponsesSend.d.ts.map
|
|
@@ -21,7 +21,7 @@ async function $do(client, request, options) {
|
|
|
21
21
|
}
|
|
22
22
|
const payload = parsed.value;
|
|
23
23
|
const body = encodeJSON("body", payload, { explode: true });
|
|
24
|
-
const path = pathToFunc("/
|
|
24
|
+
const path = pathToFunc("/responses")();
|
|
25
25
|
const headers = new Headers(compactMap({
|
|
26
26
|
"Content-Type": "application/json",
|
|
27
27
|
Accept: request?.stream ? "text/event-stream" : "application/json",
|
|
@@ -32,7 +32,7 @@ async function $do(client, request, options) {
|
|
|
32
32
|
const context = {
|
|
33
33
|
options: client._options,
|
|
34
34
|
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
35
|
-
operationID: "
|
|
35
|
+
operationID: "createResponses",
|
|
36
36
|
oAuth2Scopes: null,
|
|
37
37
|
resolvedSecurity: requestSecurity,
|
|
38
38
|
securitySource: client._options.apiKey,
|
|
@@ -84,7 +84,7 @@ async function $do(client, request, options) {
|
|
|
84
84
|
const responseFields = {
|
|
85
85
|
HttpMeta: { Response: response, Request: req },
|
|
86
86
|
};
|
|
87
|
-
const [result] = await M.match(M.json(200, operations.
|
|
87
|
+
const [result] = await M.match(M.json(200, operations.CreateResponsesResponse$inboundSchema), M.sse(200, operations.CreateResponsesResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(402, errors.PaymentRequiredResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(408, errors.RequestTimeoutResponseError$inboundSchema), M.jsonErr(413, errors.PayloadTooLargeResponseError$inboundSchema), M.jsonErr(422, errors.UnprocessableEntityResponseError$inboundSchema), M.jsonErr(429, errors.TooManyRequestsResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.jsonErr(502, errors.BadGatewayResponseError$inboundSchema), M.jsonErr(503, errors.ServiceUnavailableResponseError$inboundSchema), M.jsonErr(524, errors.EdgeNetworkTimeoutResponseError$inboundSchema), M.jsonErr(529, errors.ProviderOverloadedResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
88
88
|
if (!result.ok) {
|
|
89
89
|
return [result, { status: "complete", request: req, response }];
|
|
90
90
|
}
|
package/esm/funcs/chatSend.d.ts
CHANGED
|
@@ -21,6 +21,6 @@ export declare function chatSend(client: OpenRouterCore, request: models.ChatGen
|
|
|
21
21
|
}, options?: RequestOptions): APIPromise<Result<models.ChatResponse, errors.ChatError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
22
22
|
export declare function chatSend(client: OpenRouterCore, request: models.ChatGenerationParams & {
|
|
23
23
|
stream: true;
|
|
24
|
-
}, options?: RequestOptions): APIPromise<Result<EventStream<models.
|
|
24
|
+
}, options?: RequestOptions): APIPromise<Result<EventStream<models.ChatStreamingResponseChunkData>, errors.ChatError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
25
25
|
export declare function chatSend(client: OpenRouterCore, request: models.ChatGenerationParams, options?: RequestOptions): APIPromise<Result<operations.SendChatCompletionRequestResponse, errors.ChatError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
26
26
|
//# sourceMappingURL=chatSend.d.ts.map
|