@openrouter/sdk 0.0.1-beta.10 → 0.0.1-beta.12
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 +110 -1
- package/REACT_QUERY.md +110 -1
- package/README.md +682 -14
- package/esm/funcs/analyticsGetUserActivity.d.ts +1 -1
- package/esm/funcs/analyticsGetUserActivity.js +2 -2
- package/esm/funcs/apiKeysCreate.d.ts +1 -1
- package/esm/funcs/apiKeysCreate.js +2 -2
- package/esm/funcs/apiKeysDelete.d.ts +1 -1
- package/esm/funcs/apiKeysDelete.js +2 -2
- package/esm/funcs/apiKeysGet.d.ts +1 -1
- package/esm/funcs/apiKeysGet.js +2 -2
- package/esm/funcs/apiKeysGetCurrentKeyMetadata.d.ts +1 -1
- package/esm/funcs/apiKeysGetCurrentKeyMetadata.js +2 -2
- package/esm/funcs/apiKeysList.d.ts +1 -1
- package/esm/funcs/apiKeysList.js +2 -2
- package/esm/funcs/apiKeysUpdate.d.ts +1 -1
- package/esm/funcs/apiKeysUpdate.js +2 -2
- package/esm/funcs/betaResponsesSend.d.ts +9 -1
- package/esm/funcs/betaResponsesSend.js +36 -12
- package/esm/funcs/chatSend.d.ts +7 -0
- package/esm/funcs/chatSend.js +1 -7
- package/esm/funcs/creditsCreateCoinbaseCharge.d.ts +1 -1
- package/esm/funcs/creditsCreateCoinbaseCharge.js +15 -5
- package/esm/funcs/creditsGetCredits.d.ts +1 -1
- package/esm/funcs/creditsGetCredits.js +2 -2
- package/esm/funcs/endpointsList.d.ts +1 -1
- package/esm/funcs/endpointsList.js +2 -2
- package/esm/funcs/endpointsListZdrEndpoints.d.ts +2 -1
- package/esm/funcs/endpointsListZdrEndpoints.js +6 -2
- package/esm/funcs/generationsGetGeneration.d.ts +1 -1
- package/esm/funcs/generationsGetGeneration.js +13 -2
- package/esm/funcs/modelsCount.d.ts +3 -2
- package/esm/funcs/modelsCount.js +7 -3
- package/esm/funcs/modelsList.d.ts +2 -1
- package/esm/funcs/modelsList.js +6 -2
- package/esm/funcs/modelsListForUser.d.ts +3 -1
- package/esm/funcs/modelsListForUser.js +7 -3
- package/esm/funcs/parametersGetParameters.d.ts +1 -1
- package/esm/funcs/parametersGetParameters.js +2 -2
- package/esm/funcs/providersList.d.ts +1 -1
- package/esm/funcs/providersList.js +1 -1
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/models/badgatewayresponseerrordata.d.ts +40 -0
- package/esm/models/badgatewayresponseerrordata.js +35 -0
- package/esm/models/badrequestresponseerrordata.d.ts +40 -0
- package/esm/models/badrequestresponseerrordata.js +35 -0
- package/esm/models/chatgenerationparams.d.ts +2 -2
- package/esm/models/chatgenerationparams.js +2 -2
- package/esm/models/chatmessagecontentitemaudio.d.ts +10 -10
- package/esm/models/chatmessagecontentitemaudio.js +14 -14
- package/esm/models/chatstreamingresponsechunk.d.ts +15 -15
- package/esm/models/chatstreamingresponsechunk.js +15 -15
- package/esm/models/completioncreateparams.d.ts +2 -2
- package/esm/models/completioncreateparams.js +2 -2
- package/esm/models/createchargerequest.d.ts +31 -2
- package/esm/models/createchargerequest.js +47 -2
- package/esm/models/defaultparameters.d.ts +36 -0
- package/esm/models/defaultparameters.js +46 -0
- package/esm/models/edgenetworktimeoutresponseerrordata.d.ts +40 -0
- package/esm/models/edgenetworktimeoutresponseerrordata.js +35 -0
- package/esm/models/endpointstatus.d.ts +26 -0
- package/esm/models/endpointstatus.js +36 -0
- package/esm/models/errors/badgatewayresponseerror.d.ts +52 -0
- package/esm/models/errors/badgatewayresponseerror.js +63 -0
- package/esm/models/errors/badrequestresponseerror.d.ts +52 -0
- package/esm/models/errors/badrequestresponseerror.js +63 -0
- package/esm/models/errors/edgenetworktimeoutresponseerror.d.ts +52 -0
- package/esm/models/errors/edgenetworktimeoutresponseerror.js +63 -0
- package/esm/models/errors/forbiddenresponseerror.d.ts +52 -0
- package/esm/models/errors/forbiddenresponseerror.js +63 -0
- package/esm/models/errors/index.d.ts +14 -2
- package/esm/models/errors/index.js +14 -2
- package/esm/models/errors/internalserverresponseerror.d.ts +52 -0
- package/esm/models/errors/internalserverresponseerror.js +63 -0
- package/esm/models/errors/notfoundresponseerror.d.ts +52 -0
- package/esm/models/errors/{errorresponse.js → notfoundresponseerror.js} +16 -17
- package/esm/models/errors/payloadtoolargeresponseerror.d.ts +52 -0
- package/esm/models/errors/payloadtoolargeresponseerror.js +63 -0
- package/esm/models/errors/paymentrequiredresponseerror.d.ts +52 -0
- package/esm/models/errors/paymentrequiredresponseerror.js +63 -0
- package/esm/models/errors/provideroverloadedresponseerror.d.ts +52 -0
- package/esm/models/errors/provideroverloadedresponseerror.js +63 -0
- package/esm/models/errors/requesttimeoutresponseerror.d.ts +52 -0
- package/esm/models/errors/requesttimeoutresponseerror.js +63 -0
- package/esm/models/errors/serviceunavailableresponseerror.d.ts +52 -0
- package/esm/models/errors/serviceunavailableresponseerror.js +63 -0
- package/esm/models/errors/toomanyrequestsresponseerror.d.ts +52 -0
- package/esm/models/errors/toomanyrequestsresponseerror.js +63 -0
- package/esm/models/errors/unauthorizedresponseerror.d.ts +52 -0
- package/esm/models/errors/unauthorizedresponseerror.js +63 -0
- package/esm/models/errors/unprocessableentityresponseerror.d.ts +52 -0
- package/esm/models/errors/unprocessableentityresponseerror.js +63 -0
- package/esm/models/forbiddenresponseerrordata.d.ts +40 -0
- package/esm/models/forbiddenresponseerrordata.js +35 -0
- package/esm/models/index.d.ts +37 -1
- package/esm/models/index.js +37 -1
- package/esm/models/inputmodality.d.ts +24 -0
- package/esm/models/inputmodality.js +34 -0
- package/esm/models/instructtype.d.ts +48 -0
- package/esm/models/instructtype.js +55 -0
- package/esm/models/internalserverresponseerrordata.d.ts +40 -0
- package/esm/models/internalserverresponseerrordata.js +35 -0
- package/esm/models/listendpointsresponse.d.ts +126 -2
- package/esm/models/listendpointsresponse.js +115 -2
- package/esm/models/model.d.ts +101 -0
- package/esm/models/model.js +82 -0
- package/esm/models/modelarchitecture.d.ts +104 -0
- package/esm/models/modelarchitecture.js +107 -0
- package/esm/models/modelgroup.d.ts +45 -0
- package/esm/models/modelgroup.js +53 -0
- package/esm/models/modelscountresponse.d.ts +40 -2
- package/esm/models/modelscountresponse.js +31 -2
- package/esm/models/modelslistresponse.d.ts +10 -2
- package/esm/models/modelslistresponse.js +7 -2
- package/esm/models/notfoundresponseerrordata.d.ts +40 -0
- package/esm/models/notfoundresponseerrordata.js +35 -0
- package/esm/models/openairesponsesincludable.d.ts +25 -0
- package/esm/models/openairesponsesincludable.js +35 -0
- package/esm/models/openairesponsesinputunion.d.ts +78 -78
- package/esm/models/openairesponsesinputunion.js +124 -126
- package/esm/models/openresponseseasyinputmessage.d.ts +246 -0
- package/esm/models/openresponseseasyinputmessage.js +283 -0
- package/esm/models/openresponsesfunctioncalloutput.d.ts +64 -0
- package/esm/models/openresponsesfunctioncalloutput.js +67 -0
- package/esm/models/openresponsesfunctiontoolcall.d.ts +66 -0
- package/esm/models/openresponsesfunctiontoolcall.js +69 -0
- package/esm/models/openresponsesinput.d.ts +60 -0
- package/esm/models/openresponsesinput.js +113 -0
- package/esm/models/openresponsesinputmessageitem.d.ts +193 -0
- package/esm/models/openresponsesinputmessageitem.js +210 -0
- package/esm/models/openresponsesnonstreamingresponse.d.ts +13 -13
- package/esm/models/openresponsesnonstreamingresponse.js +13 -13
- package/esm/models/openresponsesreasoning.d.ts +179 -0
- package/esm/models/openresponsesreasoning.js +194 -0
- package/esm/models/openresponsesreasoningconfig.d.ts +40 -0
- package/esm/models/openresponsesreasoningconfig.js +48 -0
- package/esm/models/openresponsesrequest.d.ts +736 -2
- package/esm/models/openresponsesrequest.js +789 -2
- package/esm/models/openresponsesresponsetext.d.ts +59 -0
- package/esm/models/openresponsesresponsetext.js +64 -0
- package/esm/models/operations/createapialpharesponses.d.ts +3 -3
- package/esm/models/operations/createapialpharesponses.js +0 -2
- package/esm/models/operations/getmodels.d.ts +2 -2
- package/esm/models/operations/getmodels.js +2 -10
- package/esm/models/operations/index.d.ts +0 -1
- package/esm/models/operations/index.js +0 -1
- package/esm/models/operations/listendpointszdr.d.ts +3 -24
- package/esm/models/operations/listendpointszdr.js +2 -29
- package/esm/models/operations/listmodelsuser.d.ts +0 -22
- package/esm/models/operations/listmodelsuser.js +0 -28
- package/esm/models/operations/listproviders.d.ts +0 -36
- package/esm/models/operations/listproviders.js +0 -28
- package/esm/models/outputmodality.d.ts +23 -0
- package/esm/models/outputmodality.js +33 -0
- package/esm/models/parameter.d.ts +43 -0
- package/esm/models/parameter.js +54 -0
- package/esm/models/payloadtoolargeresponseerrordata.d.ts +40 -0
- package/esm/models/payloadtoolargeresponseerrordata.js +35 -0
- package/esm/models/paymentrequiredresponseerrordata.d.ts +40 -0
- package/esm/models/paymentrequiredresponseerrordata.js +35 -0
- package/esm/models/perrequestlimits.d.ts +40 -0
- package/esm/models/perrequestlimits.js +44 -0
- package/esm/models/providername.d.ts +106 -0
- package/esm/models/providername.js +116 -0
- package/esm/models/provideroverloadedresponseerrordata.d.ts +40 -0
- package/esm/models/provideroverloadedresponseerrordata.js +35 -0
- package/esm/models/publicendpoint.d.ts +140 -2
- package/esm/models/publicendpoint.js +156 -2
- package/esm/models/publicpricing.d.ts +87 -0
- package/esm/models/publicpricing.js +73 -0
- package/esm/models/quantization.d.ts +29 -0
- package/esm/models/quantization.js +39 -0
- package/esm/models/requesttimeoutresponseerrordata.d.ts +40 -0
- package/esm/models/requesttimeoutresponseerrordata.js +35 -0
- package/esm/models/responseserrorfield.d.ts +10 -10
- package/esm/models/responseserrorfield.js +14 -14
- package/esm/models/responsetextconfig.d.ts +10 -10
- package/esm/models/responsetextconfig.js +14 -15
- package/esm/models/serviceunavailableresponseerrordata.d.ts +40 -0
- package/esm/models/serviceunavailableresponseerrordata.js +35 -0
- package/esm/models/toomanyrequestsresponseerrordata.d.ts +40 -0
- package/esm/models/toomanyrequestsresponseerrordata.js +35 -0
- package/esm/models/topproviderinfo.d.ts +45 -0
- package/esm/models/topproviderinfo.js +48 -0
- package/esm/models/unauthorizedresponseerrordata.d.ts +40 -0
- package/esm/models/unauthorizedresponseerrordata.js +35 -0
- package/esm/models/unprocessableentityresponseerrordata.d.ts +40 -0
- package/esm/models/unprocessableentityresponseerrordata.js +35 -0
- package/esm/react-query/modelsCount.d.ts +2 -2
- package/esm/react-query/modelsListForUser.d.ts +2 -1
- package/esm/sdk/chat.d.ts +7 -0
- package/esm/sdk/chat.js +0 -6
- package/esm/sdk/models.d.ts +3 -2
- package/esm/sdk/responses.d.ts +7 -0
- package/esm/sdk/responses.js +0 -6
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/vitest.config.ts +11 -0
- package/esm/models/errorresponse.d.ts +0 -155
- package/esm/models/errorresponse.js +0 -167
- package/esm/models/errors/errorresponse.d.ts +0 -46
- package/esm/models/errors/listproviders.d.ts +0 -49
- package/esm/models/errors/listproviders.js +0 -51
- package/esm/models/operations/listmodelscount.d.ts +0 -26
- package/esm/models/operations/listmodelscount.js +0 -34
package/README.md
CHANGED
|
@@ -86,7 +86,116 @@ const openRouter = new OpenRouter({
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
async function run() {
|
|
89
|
-
const result = await openRouter.beta.responses.send({
|
|
89
|
+
const result = await openRouter.beta.responses.send({
|
|
90
|
+
input: [
|
|
91
|
+
{
|
|
92
|
+
type: "message",
|
|
93
|
+
role: "user",
|
|
94
|
+
content: "Hello, how are you?",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
instructions: "<value>",
|
|
98
|
+
metadata: {
|
|
99
|
+
"user_id": "123",
|
|
100
|
+
"session_id": "abc-def-ghi",
|
|
101
|
+
},
|
|
102
|
+
tools: [
|
|
103
|
+
{
|
|
104
|
+
type: "function",
|
|
105
|
+
name: "get_current_weather",
|
|
106
|
+
description: "Get the current weather in a given location",
|
|
107
|
+
strict: true,
|
|
108
|
+
parameters: {
|
|
109
|
+
"type": "object",
|
|
110
|
+
"properties": {
|
|
111
|
+
"location": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
toolChoice: {
|
|
119
|
+
type: "function",
|
|
120
|
+
name: "<value>",
|
|
121
|
+
},
|
|
122
|
+
parallelToolCalls: true,
|
|
123
|
+
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
124
|
+
models: [
|
|
125
|
+
"<value 1>",
|
|
126
|
+
"<value 2>",
|
|
127
|
+
],
|
|
128
|
+
text: {
|
|
129
|
+
format: {
|
|
130
|
+
type: "text",
|
|
131
|
+
},
|
|
132
|
+
verbosity: "medium",
|
|
133
|
+
},
|
|
134
|
+
reasoning: {
|
|
135
|
+
effort: "minimal",
|
|
136
|
+
summary: "auto",
|
|
137
|
+
maxTokens: 5632.72,
|
|
138
|
+
enabled: true,
|
|
139
|
+
},
|
|
140
|
+
maxOutputTokens: 5913.88,
|
|
141
|
+
temperature: 0.7,
|
|
142
|
+
topP: 0.9,
|
|
143
|
+
topK: 1770.66,
|
|
144
|
+
promptCacheKey: "<value>",
|
|
145
|
+
previousResponseId: "<id>",
|
|
146
|
+
prompt: {
|
|
147
|
+
id: "<id>",
|
|
148
|
+
variables: {
|
|
149
|
+
"key": {
|
|
150
|
+
type: "input_text",
|
|
151
|
+
text: "Hello, how can I help you?",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
include: [
|
|
156
|
+
"file_search_call.results",
|
|
157
|
+
],
|
|
158
|
+
background: false,
|
|
159
|
+
safetyIdentifier: "<value>",
|
|
160
|
+
store: false,
|
|
161
|
+
serviceTier: "auto",
|
|
162
|
+
truncation: "auto",
|
|
163
|
+
provider: {
|
|
164
|
+
allowFallbacks: false,
|
|
165
|
+
requireParameters: false,
|
|
166
|
+
dataCollection: "deny",
|
|
167
|
+
zdr: true,
|
|
168
|
+
order: [
|
|
169
|
+
"OpenAI",
|
|
170
|
+
],
|
|
171
|
+
only: null,
|
|
172
|
+
ignore: [
|
|
173
|
+
"OpenAI",
|
|
174
|
+
],
|
|
175
|
+
quantizations: [
|
|
176
|
+
"fp16",
|
|
177
|
+
],
|
|
178
|
+
sort: "price",
|
|
179
|
+
maxPrice: {
|
|
180
|
+
prompt: "1000",
|
|
181
|
+
completion: 1000,
|
|
182
|
+
image: 1000,
|
|
183
|
+
audio: 1000,
|
|
184
|
+
request: 1000,
|
|
185
|
+
},
|
|
186
|
+
experimental: {},
|
|
187
|
+
},
|
|
188
|
+
plugins: [
|
|
189
|
+
{
|
|
190
|
+
id: "file-parser",
|
|
191
|
+
maxFiles: 6167.86,
|
|
192
|
+
pdf: {
|
|
193
|
+
engine: "native",
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
user: "Minnie.Ratke",
|
|
198
|
+
});
|
|
90
199
|
|
|
91
200
|
console.log(result);
|
|
92
201
|
}
|
|
@@ -116,7 +225,116 @@ const openRouter = new OpenRouter({
|
|
|
116
225
|
});
|
|
117
226
|
|
|
118
227
|
async function run() {
|
|
119
|
-
const result = await openRouter.beta.responses.send({
|
|
228
|
+
const result = await openRouter.beta.responses.send({
|
|
229
|
+
input: [
|
|
230
|
+
{
|
|
231
|
+
type: "message",
|
|
232
|
+
role: "user",
|
|
233
|
+
content: "Hello, how are you?",
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
instructions: "<value>",
|
|
237
|
+
metadata: {
|
|
238
|
+
"user_id": "123",
|
|
239
|
+
"session_id": "abc-def-ghi",
|
|
240
|
+
},
|
|
241
|
+
tools: [
|
|
242
|
+
{
|
|
243
|
+
type: "function",
|
|
244
|
+
name: "get_current_weather",
|
|
245
|
+
description: "Get the current weather in a given location",
|
|
246
|
+
strict: true,
|
|
247
|
+
parameters: {
|
|
248
|
+
"type": "object",
|
|
249
|
+
"properties": {
|
|
250
|
+
"location": {
|
|
251
|
+
"type": "string",
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
toolChoice: {
|
|
258
|
+
type: "function",
|
|
259
|
+
name: "<value>",
|
|
260
|
+
},
|
|
261
|
+
parallelToolCalls: true,
|
|
262
|
+
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
263
|
+
models: [
|
|
264
|
+
"<value 1>",
|
|
265
|
+
"<value 2>",
|
|
266
|
+
],
|
|
267
|
+
text: {
|
|
268
|
+
format: {
|
|
269
|
+
type: "text",
|
|
270
|
+
},
|
|
271
|
+
verbosity: "medium",
|
|
272
|
+
},
|
|
273
|
+
reasoning: {
|
|
274
|
+
effort: "minimal",
|
|
275
|
+
summary: "auto",
|
|
276
|
+
maxTokens: 5632.72,
|
|
277
|
+
enabled: true,
|
|
278
|
+
},
|
|
279
|
+
maxOutputTokens: 5913.88,
|
|
280
|
+
temperature: 0.7,
|
|
281
|
+
topP: 0.9,
|
|
282
|
+
topK: 1770.66,
|
|
283
|
+
promptCacheKey: "<value>",
|
|
284
|
+
previousResponseId: "<id>",
|
|
285
|
+
prompt: {
|
|
286
|
+
id: "<id>",
|
|
287
|
+
variables: {
|
|
288
|
+
"key": {
|
|
289
|
+
type: "input_text",
|
|
290
|
+
text: "Hello, how can I help you?",
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
include: [
|
|
295
|
+
"file_search_call.results",
|
|
296
|
+
],
|
|
297
|
+
background: false,
|
|
298
|
+
safetyIdentifier: "<value>",
|
|
299
|
+
store: false,
|
|
300
|
+
serviceTier: "auto",
|
|
301
|
+
truncation: "auto",
|
|
302
|
+
provider: {
|
|
303
|
+
allowFallbacks: false,
|
|
304
|
+
requireParameters: false,
|
|
305
|
+
dataCollection: "deny",
|
|
306
|
+
zdr: true,
|
|
307
|
+
order: [
|
|
308
|
+
"OpenAI",
|
|
309
|
+
],
|
|
310
|
+
only: null,
|
|
311
|
+
ignore: [
|
|
312
|
+
"OpenAI",
|
|
313
|
+
],
|
|
314
|
+
quantizations: [
|
|
315
|
+
"fp16",
|
|
316
|
+
],
|
|
317
|
+
sort: "price",
|
|
318
|
+
maxPrice: {
|
|
319
|
+
prompt: "1000",
|
|
320
|
+
completion: 1000,
|
|
321
|
+
image: 1000,
|
|
322
|
+
audio: 1000,
|
|
323
|
+
request: 1000,
|
|
324
|
+
},
|
|
325
|
+
experimental: {},
|
|
326
|
+
},
|
|
327
|
+
plugins: [
|
|
328
|
+
{
|
|
329
|
+
id: "file-parser",
|
|
330
|
+
maxFiles: 6167.86,
|
|
331
|
+
pdf: {
|
|
332
|
+
engine: "native",
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
user: "Minnie.Ratke",
|
|
337
|
+
});
|
|
120
338
|
|
|
121
339
|
console.log(result);
|
|
122
340
|
}
|
|
@@ -136,7 +354,11 @@ const openRouter = new OpenRouter();
|
|
|
136
354
|
async function run() {
|
|
137
355
|
const result = await openRouter.credits.createCoinbaseCharge({
|
|
138
356
|
bearer: process.env["OPENROUTER_BEARER"] ?? "",
|
|
139
|
-
}, {
|
|
357
|
+
}, {
|
|
358
|
+
amount: 100,
|
|
359
|
+
sender: "0x1234567890123456789012345678901234567890",
|
|
360
|
+
chainId: 1,
|
|
361
|
+
});
|
|
140
362
|
|
|
141
363
|
console.log(result);
|
|
142
364
|
}
|
|
@@ -310,7 +532,116 @@ const openRouter = new OpenRouter({
|
|
|
310
532
|
});
|
|
311
533
|
|
|
312
534
|
async function run() {
|
|
313
|
-
const result = await openRouter.beta.responses.send({
|
|
535
|
+
const result = await openRouter.beta.responses.send({
|
|
536
|
+
input: [
|
|
537
|
+
{
|
|
538
|
+
type: "message",
|
|
539
|
+
role: "user",
|
|
540
|
+
content: "Hello, how are you?",
|
|
541
|
+
},
|
|
542
|
+
],
|
|
543
|
+
instructions: "<value>",
|
|
544
|
+
metadata: {
|
|
545
|
+
"user_id": "123",
|
|
546
|
+
"session_id": "abc-def-ghi",
|
|
547
|
+
},
|
|
548
|
+
tools: [
|
|
549
|
+
{
|
|
550
|
+
type: "function",
|
|
551
|
+
name: "get_current_weather",
|
|
552
|
+
description: "Get the current weather in a given location",
|
|
553
|
+
strict: true,
|
|
554
|
+
parameters: {
|
|
555
|
+
"type": "object",
|
|
556
|
+
"properties": {
|
|
557
|
+
"location": {
|
|
558
|
+
"type": "string",
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
],
|
|
564
|
+
toolChoice: {
|
|
565
|
+
type: "function",
|
|
566
|
+
name: "<value>",
|
|
567
|
+
},
|
|
568
|
+
parallelToolCalls: true,
|
|
569
|
+
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
570
|
+
models: [
|
|
571
|
+
"<value 1>",
|
|
572
|
+
"<value 2>",
|
|
573
|
+
],
|
|
574
|
+
text: {
|
|
575
|
+
format: {
|
|
576
|
+
type: "text",
|
|
577
|
+
},
|
|
578
|
+
verbosity: "medium",
|
|
579
|
+
},
|
|
580
|
+
reasoning: {
|
|
581
|
+
effort: "minimal",
|
|
582
|
+
summary: "auto",
|
|
583
|
+
maxTokens: 5632.72,
|
|
584
|
+
enabled: true,
|
|
585
|
+
},
|
|
586
|
+
maxOutputTokens: 5913.88,
|
|
587
|
+
temperature: 0.7,
|
|
588
|
+
topP: 0.9,
|
|
589
|
+
topK: 1770.66,
|
|
590
|
+
promptCacheKey: "<value>",
|
|
591
|
+
previousResponseId: "<id>",
|
|
592
|
+
prompt: {
|
|
593
|
+
id: "<id>",
|
|
594
|
+
variables: {
|
|
595
|
+
"key": {
|
|
596
|
+
type: "input_text",
|
|
597
|
+
text: "Hello, how can I help you?",
|
|
598
|
+
},
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
include: [
|
|
602
|
+
"file_search_call.results",
|
|
603
|
+
],
|
|
604
|
+
background: false,
|
|
605
|
+
safetyIdentifier: "<value>",
|
|
606
|
+
store: false,
|
|
607
|
+
serviceTier: "auto",
|
|
608
|
+
truncation: "auto",
|
|
609
|
+
provider: {
|
|
610
|
+
allowFallbacks: false,
|
|
611
|
+
requireParameters: false,
|
|
612
|
+
dataCollection: "deny",
|
|
613
|
+
zdr: true,
|
|
614
|
+
order: [
|
|
615
|
+
"OpenAI",
|
|
616
|
+
],
|
|
617
|
+
only: null,
|
|
618
|
+
ignore: [
|
|
619
|
+
"OpenAI",
|
|
620
|
+
],
|
|
621
|
+
quantizations: [
|
|
622
|
+
"fp16",
|
|
623
|
+
],
|
|
624
|
+
sort: "price",
|
|
625
|
+
maxPrice: {
|
|
626
|
+
prompt: "1000",
|
|
627
|
+
completion: 1000,
|
|
628
|
+
image: 1000,
|
|
629
|
+
audio: 1000,
|
|
630
|
+
request: 1000,
|
|
631
|
+
},
|
|
632
|
+
experimental: {},
|
|
633
|
+
},
|
|
634
|
+
plugins: [
|
|
635
|
+
{
|
|
636
|
+
id: "file-parser",
|
|
637
|
+
maxFiles: 6167.86,
|
|
638
|
+
pdf: {
|
|
639
|
+
engine: "native",
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
],
|
|
643
|
+
user: "Minnie.Ratke",
|
|
644
|
+
});
|
|
314
645
|
|
|
315
646
|
console.log(result);
|
|
316
647
|
}
|
|
@@ -337,7 +668,116 @@ const openRouter = new OpenRouter({
|
|
|
337
668
|
});
|
|
338
669
|
|
|
339
670
|
async function run() {
|
|
340
|
-
const result = await openRouter.beta.responses.send({
|
|
671
|
+
const result = await openRouter.beta.responses.send({
|
|
672
|
+
input: [
|
|
673
|
+
{
|
|
674
|
+
type: "message",
|
|
675
|
+
role: "user",
|
|
676
|
+
content: "Hello, how are you?",
|
|
677
|
+
},
|
|
678
|
+
],
|
|
679
|
+
instructions: "<value>",
|
|
680
|
+
metadata: {
|
|
681
|
+
"user_id": "123",
|
|
682
|
+
"session_id": "abc-def-ghi",
|
|
683
|
+
},
|
|
684
|
+
tools: [
|
|
685
|
+
{
|
|
686
|
+
type: "function",
|
|
687
|
+
name: "get_current_weather",
|
|
688
|
+
description: "Get the current weather in a given location",
|
|
689
|
+
strict: true,
|
|
690
|
+
parameters: {
|
|
691
|
+
"type": "object",
|
|
692
|
+
"properties": {
|
|
693
|
+
"location": {
|
|
694
|
+
"type": "string",
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
],
|
|
700
|
+
toolChoice: {
|
|
701
|
+
type: "function",
|
|
702
|
+
name: "<value>",
|
|
703
|
+
},
|
|
704
|
+
parallelToolCalls: true,
|
|
705
|
+
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
706
|
+
models: [
|
|
707
|
+
"<value 1>",
|
|
708
|
+
"<value 2>",
|
|
709
|
+
],
|
|
710
|
+
text: {
|
|
711
|
+
format: {
|
|
712
|
+
type: "text",
|
|
713
|
+
},
|
|
714
|
+
verbosity: "medium",
|
|
715
|
+
},
|
|
716
|
+
reasoning: {
|
|
717
|
+
effort: "minimal",
|
|
718
|
+
summary: "auto",
|
|
719
|
+
maxTokens: 5632.72,
|
|
720
|
+
enabled: true,
|
|
721
|
+
},
|
|
722
|
+
maxOutputTokens: 5913.88,
|
|
723
|
+
temperature: 0.7,
|
|
724
|
+
topP: 0.9,
|
|
725
|
+
topK: 1770.66,
|
|
726
|
+
promptCacheKey: "<value>",
|
|
727
|
+
previousResponseId: "<id>",
|
|
728
|
+
prompt: {
|
|
729
|
+
id: "<id>",
|
|
730
|
+
variables: {
|
|
731
|
+
"key": {
|
|
732
|
+
type: "input_text",
|
|
733
|
+
text: "Hello, how can I help you?",
|
|
734
|
+
},
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
include: [
|
|
738
|
+
"file_search_call.results",
|
|
739
|
+
],
|
|
740
|
+
background: false,
|
|
741
|
+
safetyIdentifier: "<value>",
|
|
742
|
+
store: false,
|
|
743
|
+
serviceTier: "auto",
|
|
744
|
+
truncation: "auto",
|
|
745
|
+
provider: {
|
|
746
|
+
allowFallbacks: false,
|
|
747
|
+
requireParameters: false,
|
|
748
|
+
dataCollection: "deny",
|
|
749
|
+
zdr: true,
|
|
750
|
+
order: [
|
|
751
|
+
"OpenAI",
|
|
752
|
+
],
|
|
753
|
+
only: null,
|
|
754
|
+
ignore: [
|
|
755
|
+
"OpenAI",
|
|
756
|
+
],
|
|
757
|
+
quantizations: [
|
|
758
|
+
"fp16",
|
|
759
|
+
],
|
|
760
|
+
sort: "price",
|
|
761
|
+
maxPrice: {
|
|
762
|
+
prompt: "1000",
|
|
763
|
+
completion: 1000,
|
|
764
|
+
image: 1000,
|
|
765
|
+
audio: 1000,
|
|
766
|
+
request: 1000,
|
|
767
|
+
},
|
|
768
|
+
experimental: {},
|
|
769
|
+
},
|
|
770
|
+
plugins: [
|
|
771
|
+
{
|
|
772
|
+
id: "file-parser",
|
|
773
|
+
maxFiles: 6167.86,
|
|
774
|
+
pdf: {
|
|
775
|
+
engine: "native",
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
],
|
|
779
|
+
user: "Minnie.Ratke",
|
|
780
|
+
}, {
|
|
341
781
|
retries: {
|
|
342
782
|
strategy: "backoff",
|
|
343
783
|
backoff: {
|
|
@@ -376,7 +816,116 @@ const openRouter = new OpenRouter({
|
|
|
376
816
|
});
|
|
377
817
|
|
|
378
818
|
async function run() {
|
|
379
|
-
const result = await openRouter.beta.responses.send({
|
|
819
|
+
const result = await openRouter.beta.responses.send({
|
|
820
|
+
input: [
|
|
821
|
+
{
|
|
822
|
+
type: "message",
|
|
823
|
+
role: "user",
|
|
824
|
+
content: "Hello, how are you?",
|
|
825
|
+
},
|
|
826
|
+
],
|
|
827
|
+
instructions: "<value>",
|
|
828
|
+
metadata: {
|
|
829
|
+
"user_id": "123",
|
|
830
|
+
"session_id": "abc-def-ghi",
|
|
831
|
+
},
|
|
832
|
+
tools: [
|
|
833
|
+
{
|
|
834
|
+
type: "function",
|
|
835
|
+
name: "get_current_weather",
|
|
836
|
+
description: "Get the current weather in a given location",
|
|
837
|
+
strict: true,
|
|
838
|
+
parameters: {
|
|
839
|
+
"type": "object",
|
|
840
|
+
"properties": {
|
|
841
|
+
"location": {
|
|
842
|
+
"type": "string",
|
|
843
|
+
},
|
|
844
|
+
},
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
],
|
|
848
|
+
toolChoice: {
|
|
849
|
+
type: "function",
|
|
850
|
+
name: "<value>",
|
|
851
|
+
},
|
|
852
|
+
parallelToolCalls: true,
|
|
853
|
+
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
854
|
+
models: [
|
|
855
|
+
"<value 1>",
|
|
856
|
+
"<value 2>",
|
|
857
|
+
],
|
|
858
|
+
text: {
|
|
859
|
+
format: {
|
|
860
|
+
type: "text",
|
|
861
|
+
},
|
|
862
|
+
verbosity: "medium",
|
|
863
|
+
},
|
|
864
|
+
reasoning: {
|
|
865
|
+
effort: "minimal",
|
|
866
|
+
summary: "auto",
|
|
867
|
+
maxTokens: 5632.72,
|
|
868
|
+
enabled: true,
|
|
869
|
+
},
|
|
870
|
+
maxOutputTokens: 5913.88,
|
|
871
|
+
temperature: 0.7,
|
|
872
|
+
topP: 0.9,
|
|
873
|
+
topK: 1770.66,
|
|
874
|
+
promptCacheKey: "<value>",
|
|
875
|
+
previousResponseId: "<id>",
|
|
876
|
+
prompt: {
|
|
877
|
+
id: "<id>",
|
|
878
|
+
variables: {
|
|
879
|
+
"key": {
|
|
880
|
+
type: "input_text",
|
|
881
|
+
text: "Hello, how can I help you?",
|
|
882
|
+
},
|
|
883
|
+
},
|
|
884
|
+
},
|
|
885
|
+
include: [
|
|
886
|
+
"file_search_call.results",
|
|
887
|
+
],
|
|
888
|
+
background: false,
|
|
889
|
+
safetyIdentifier: "<value>",
|
|
890
|
+
store: false,
|
|
891
|
+
serviceTier: "auto",
|
|
892
|
+
truncation: "auto",
|
|
893
|
+
provider: {
|
|
894
|
+
allowFallbacks: false,
|
|
895
|
+
requireParameters: false,
|
|
896
|
+
dataCollection: "deny",
|
|
897
|
+
zdr: true,
|
|
898
|
+
order: [
|
|
899
|
+
"OpenAI",
|
|
900
|
+
],
|
|
901
|
+
only: null,
|
|
902
|
+
ignore: [
|
|
903
|
+
"OpenAI",
|
|
904
|
+
],
|
|
905
|
+
quantizations: [
|
|
906
|
+
"fp16",
|
|
907
|
+
],
|
|
908
|
+
sort: "price",
|
|
909
|
+
maxPrice: {
|
|
910
|
+
prompt: "1000",
|
|
911
|
+
completion: 1000,
|
|
912
|
+
image: 1000,
|
|
913
|
+
audio: 1000,
|
|
914
|
+
request: 1000,
|
|
915
|
+
},
|
|
916
|
+
experimental: {},
|
|
917
|
+
},
|
|
918
|
+
plugins: [
|
|
919
|
+
{
|
|
920
|
+
id: "file-parser",
|
|
921
|
+
maxFiles: 6167.86,
|
|
922
|
+
pdf: {
|
|
923
|
+
engine: "native",
|
|
924
|
+
},
|
|
925
|
+
},
|
|
926
|
+
],
|
|
927
|
+
user: "Minnie.Ratke",
|
|
928
|
+
});
|
|
380
929
|
|
|
381
930
|
console.log(result);
|
|
382
931
|
}
|
|
@@ -411,8 +960,115 @@ const openRouter = new OpenRouter({
|
|
|
411
960
|
|
|
412
961
|
async function run() {
|
|
413
962
|
try {
|
|
414
|
-
const result = await openRouter.
|
|
415
|
-
|
|
963
|
+
const result = await openRouter.beta.responses.send({
|
|
964
|
+
input: [
|
|
965
|
+
{
|
|
966
|
+
type: "message",
|
|
967
|
+
role: "user",
|
|
968
|
+
content: "Hello, how are you?",
|
|
969
|
+
},
|
|
970
|
+
],
|
|
971
|
+
instructions: "<value>",
|
|
972
|
+
metadata: {
|
|
973
|
+
"user_id": "123",
|
|
974
|
+
"session_id": "abc-def-ghi",
|
|
975
|
+
},
|
|
976
|
+
tools: [
|
|
977
|
+
{
|
|
978
|
+
type: "function",
|
|
979
|
+
name: "get_current_weather",
|
|
980
|
+
description: "Get the current weather in a given location",
|
|
981
|
+
strict: true,
|
|
982
|
+
parameters: {
|
|
983
|
+
"type": "object",
|
|
984
|
+
"properties": {
|
|
985
|
+
"location": {
|
|
986
|
+
"type": "string",
|
|
987
|
+
},
|
|
988
|
+
},
|
|
989
|
+
},
|
|
990
|
+
},
|
|
991
|
+
],
|
|
992
|
+
toolChoice: {
|
|
993
|
+
type: "function",
|
|
994
|
+
name: "<value>",
|
|
995
|
+
},
|
|
996
|
+
parallelToolCalls: true,
|
|
997
|
+
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
998
|
+
models: [
|
|
999
|
+
"<value 1>",
|
|
1000
|
+
"<value 2>",
|
|
1001
|
+
],
|
|
1002
|
+
text: {
|
|
1003
|
+
format: {
|
|
1004
|
+
type: "text",
|
|
1005
|
+
},
|
|
1006
|
+
verbosity: "medium",
|
|
1007
|
+
},
|
|
1008
|
+
reasoning: {
|
|
1009
|
+
effort: "minimal",
|
|
1010
|
+
summary: "auto",
|
|
1011
|
+
maxTokens: 5632.72,
|
|
1012
|
+
enabled: true,
|
|
1013
|
+
},
|
|
1014
|
+
maxOutputTokens: 5913.88,
|
|
1015
|
+
temperature: 0.7,
|
|
1016
|
+
topP: 0.9,
|
|
1017
|
+
topK: 1770.66,
|
|
1018
|
+
promptCacheKey: "<value>",
|
|
1019
|
+
previousResponseId: "<id>",
|
|
1020
|
+
prompt: {
|
|
1021
|
+
id: "<id>",
|
|
1022
|
+
variables: {
|
|
1023
|
+
"key": {
|
|
1024
|
+
type: "input_text",
|
|
1025
|
+
text: "Hello, how can I help you?",
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
},
|
|
1029
|
+
include: [
|
|
1030
|
+
"file_search_call.results",
|
|
1031
|
+
],
|
|
1032
|
+
background: false,
|
|
1033
|
+
safetyIdentifier: "<value>",
|
|
1034
|
+
store: false,
|
|
1035
|
+
serviceTier: "auto",
|
|
1036
|
+
truncation: "auto",
|
|
1037
|
+
provider: {
|
|
1038
|
+
allowFallbacks: false,
|
|
1039
|
+
requireParameters: false,
|
|
1040
|
+
dataCollection: "deny",
|
|
1041
|
+
zdr: true,
|
|
1042
|
+
order: [
|
|
1043
|
+
"OpenAI",
|
|
1044
|
+
],
|
|
1045
|
+
only: null,
|
|
1046
|
+
ignore: [
|
|
1047
|
+
"OpenAI",
|
|
1048
|
+
],
|
|
1049
|
+
quantizations: [
|
|
1050
|
+
"fp16",
|
|
1051
|
+
],
|
|
1052
|
+
sort: "price",
|
|
1053
|
+
maxPrice: {
|
|
1054
|
+
prompt: "1000",
|
|
1055
|
+
completion: 1000,
|
|
1056
|
+
image: 1000,
|
|
1057
|
+
audio: 1000,
|
|
1058
|
+
request: 1000,
|
|
1059
|
+
},
|
|
1060
|
+
experimental: {},
|
|
1061
|
+
},
|
|
1062
|
+
plugins: [
|
|
1063
|
+
{
|
|
1064
|
+
id: "file-parser",
|
|
1065
|
+
maxFiles: 6167.86,
|
|
1066
|
+
pdf: {
|
|
1067
|
+
engine: "native",
|
|
1068
|
+
},
|
|
1069
|
+
},
|
|
1070
|
+
],
|
|
1071
|
+
user: "Minnie.Ratke",
|
|
416
1072
|
});
|
|
417
1073
|
|
|
418
1074
|
console.log(result);
|
|
@@ -425,8 +1081,8 @@ async function run() {
|
|
|
425
1081
|
console.log(error.headers);
|
|
426
1082
|
|
|
427
1083
|
// Depending on the method different errors may be thrown
|
|
428
|
-
if (error instanceof errors.
|
|
429
|
-
console.log(error.data$.error); // models.
|
|
1084
|
+
if (error instanceof errors.BadRequestResponseError) {
|
|
1085
|
+
console.log(error.data$.error); // models.BadRequestResponseErrorData
|
|
430
1086
|
console.log(error.data$.userId); // string
|
|
431
1087
|
}
|
|
432
1088
|
}
|
|
@@ -438,10 +1094,11 @@ run();
|
|
|
438
1094
|
```
|
|
439
1095
|
|
|
440
1096
|
### Error Classes
|
|
441
|
-
**Primary
|
|
1097
|
+
**Primary errors:**
|
|
442
1098
|
* [`OpenRouterError`](./src/models/errors/openroutererror.ts): The base class for HTTP error responses.
|
|
1099
|
+
* [`InternalServerResponseError`](./src/models/errors/internalserverresponseerror.ts): Internal Server Error - Unexpected server error. Status code `500`. *
|
|
443
1100
|
|
|
444
|
-
<details><summary>Less common errors (
|
|
1101
|
+
<details><summary>Less common errors (20)</summary>
|
|
445
1102
|
|
|
446
1103
|
<br />
|
|
447
1104
|
|
|
@@ -454,9 +1111,20 @@ run();
|
|
|
454
1111
|
|
|
455
1112
|
|
|
456
1113
|
**Inherit from [`OpenRouterError`](./src/models/errors/openroutererror.ts)**:
|
|
457
|
-
* [`
|
|
1114
|
+
* [`UnauthorizedResponseError`](./src/models/errors/unauthorizedresponseerror.ts): Unauthorized - Authentication required or invalid credentials. Status code `401`. Applicable to 13 of 20 methods.*
|
|
1115
|
+
* [`TooManyRequestsResponseError`](./src/models/errors/toomanyrequestsresponseerror.ts): Too Many Requests - Rate limit exceeded. Status code `429`. Applicable to 8 of 20 methods.*
|
|
1116
|
+
* [`NotFoundResponseError`](./src/models/errors/notfoundresponseerror.ts): Not Found - Resource does not exist. Status code `404`. Applicable to 7 of 20 methods.*
|
|
1117
|
+
* [`BadRequestResponseError`](./src/models/errors/badrequestresponseerror.ts): Bad Request - Invalid request parameters or malformed input. Status code `400`. Applicable to 6 of 20 methods.*
|
|
458
1118
|
* [`ChatError`](./src/models/errors/chaterror.ts): Bad request - invalid parameters. Applicable to 2 of 20 methods.*
|
|
459
|
-
* [`
|
|
1119
|
+
* [`PaymentRequiredResponseError`](./src/models/errors/paymentrequiredresponseerror.ts): Payment Required - Insufficient credits or quota to complete request. Status code `402`. Applicable to 2 of 20 methods.*
|
|
1120
|
+
* [`ForbiddenResponseError`](./src/models/errors/forbiddenresponseerror.ts): Forbidden - Authentication successful but insufficient permissions. Status code `403`. Applicable to 2 of 20 methods.*
|
|
1121
|
+
* [`BadGatewayResponseError`](./src/models/errors/badgatewayresponseerror.ts): Bad Gateway - Provider/upstream API failure. Status code `502`. Applicable to 2 of 20 methods.*
|
|
1122
|
+
* [`EdgeNetworkTimeoutResponseError`](./src/models/errors/edgenetworktimeoutresponseerror.ts): Infrastructure Timeout - Provider request timed out at edge network. Status code `524`. Applicable to 2 of 20 methods.*
|
|
1123
|
+
* [`ProviderOverloadedResponseError`](./src/models/errors/provideroverloadedresponseerror.ts): Provider Overloaded - Provider is temporarily overloaded. Status code `529`. Applicable to 2 of 20 methods.*
|
|
1124
|
+
* [`RequestTimeoutResponseError`](./src/models/errors/requesttimeoutresponseerror.ts): Request Timeout - Operation exceeded time limit. Status code `408`. Applicable to 1 of 20 methods.*
|
|
1125
|
+
* [`PayloadTooLargeResponseError`](./src/models/errors/payloadtoolargeresponseerror.ts): Payload Too Large - Request payload exceeds size limits. Status code `413`. Applicable to 1 of 20 methods.*
|
|
1126
|
+
* [`UnprocessableEntityResponseError`](./src/models/errors/unprocessableentityresponseerror.ts): Unprocessable Entity - Semantic validation failure. Status code `422`. Applicable to 1 of 20 methods.*
|
|
1127
|
+
* [`ServiceUnavailableResponseError`](./src/models/errors/serviceunavailableresponseerror.ts): Service Unavailable - Service temporarily unavailable. Status code `503`. Applicable to 1 of 20 methods.*
|
|
460
1128
|
* [`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.
|
|
461
1129
|
|
|
462
1130
|
</details>
|