You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can set the security parameters through the `security` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
113
+
To authenticate with the API the `apiKey`parameter must be set when initializing the SDK client instance. For example:
117
114
```typescript
118
115
import { OpenRouter } from"@openrouter/sdk";
119
116
120
117
const openRouter =newOpenRouter({
121
-
security: {
122
-
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
123
-
},
118
+
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
124
119
});
125
120
126
121
asyncfunction run() {
@@ -131,6 +126,26 @@ async function run() {
131
126
132
127
run();
133
128
129
+
```
130
+
131
+
### Per-Operation Security Schemes
132
+
133
+
Some operations in this SDK require the security scheme to be specified at the request level. For example:
134
+
```typescript
135
+
import { OpenRouter } from"@openrouter/sdk";
136
+
137
+
const openRouter =newOpenRouter();
138
+
139
+
asyncfunction run() {
140
+
const result =awaitopenRouter.postCreditsCoinbase({
141
+
bearer: process.env["OPENROUTER_BEARER"] ??"",
142
+
});
143
+
144
+
console.log(result);
145
+
}
146
+
147
+
run();
148
+
134
149
```
135
150
<!-- End Authentication [security] -->
136
151
@@ -288,9 +303,7 @@ underlying connection.
288
303
import { OpenRouter } from"@openrouter/sdk";
289
304
290
305
const openRouter =newOpenRouter({
291
-
security: {
292
-
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
293
-
},
306
+
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
294
307
});
295
308
296
309
asyncfunction run() {
@@ -317,9 +330,7 @@ To change the default retry strategy for a single API call, simply provide a ret
317
330
import { OpenRouter } from"@openrouter/sdk";
318
331
319
332
const openRouter =newOpenRouter({
320
-
security: {
321
-
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
322
-
},
333
+
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
323
334
});
324
335
325
336
asyncfunction run() {
@@ -358,9 +369,7 @@ const openRouter = new OpenRouter({
358
369
},
359
370
retryConnectionErrors: false,
360
371
},
361
-
security: {
362
-
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
363
-
},
372
+
apiKey: process.env["OPENROUTER_API_KEY"] ??"",
364
373
});
365
374
366
375
asyncfunction run() {
@@ -394,9 +403,7 @@ import { OpenRouter } from "@openrouter/sdk";
0 commit comments