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
@@ -49,6 +48,7 @@ For more information about the API: [OpenRouter Documentation](https://openroute
49
48
> [!TIP]
50
49
> To finish publishing your SDK to npm and others you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
51
50
51
+
52
52
The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
53
53
54
54
### NPM
@@ -131,7 +131,6 @@ This SDK supports the following security schemes globally:
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:
134
-
135
134
```typescript
136
135
import { OpenRouter } from"openrouter";
137
136
@@ -223,26 +222,26 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
223
222
224
223
<summary>Available standalone functions</summary>
225
224
226
-
*[`analyticsGetActivity`](docs/sdks/analytics/README.md#getactivity) - Get user activity grouped by endpoint
227
-
*[`apiKeysDeleteKeysHash`](docs/sdks/apikeys/README.md#deletekeyshash) - Delete an API key
228
-
*[`apiKeysGetAuthKey`](docs/sdks/apikeys/README.md#getauthkey) - Get current API key
229
-
*[`apiKeysGetKey`](docs/sdks/apikeys/README.md#getkey) - Get current API key
230
-
*[`apiKeysGetKeys`](docs/sdks/apikeys/README.md#getkeys) - List API keys
231
-
*[`apiKeysGetKeysHash`](docs/sdks/apikeys/README.md#getkeyshash) - Get a single API key
232
-
*[`apiKeysPatchKeysHash`](docs/sdks/apikeys/README.md#patchkeyshash) - Update an API key
233
-
*[`apiKeysPostKeys`](docs/sdks/apikeys/README.md#postkeys) - Create a new API key
234
-
*[`chatSend`](docs/sdks/chat/README.md#send) - Create a chat completion
235
-
*[`embeddingsPostEmbeddings`](docs/sdks/embeddings/README.md#postembeddings) - Submit an embedding request
236
-
*[`endpointsGetEndpointsZdr`](docs/sdks/endpoints/README.md#getendpointszdr) - Preview the impact of ZDR on the available endpoints
237
-
*[`endpointsGetModelsAuthorSlugEndpoints`](docs/sdks/endpoints/README.md#getmodelsauthorslugendpoints) - List all endpoints for a model
238
-
*[`generationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
239
-
*[`getCredits`](docs/sdks/openrouter/README.md#getcredits) - Get total credits purchased and used for the authenticated user
*[`modelsGetModels`](docs/sdks/models/README.md#getmodels) - List all models and their properties
242
-
*[`modelsGetModelsCount`](docs/sdks/models/README.md#getmodelscount) - Get total count of available models
243
-
*[`modelsGetModelsUser`](docs/sdks/models/README.md#getmodelsuser) - List models filtered by user provider preferences
244
-
*[`parametersGetParametersAuthorSlug`](docs/sdks/parameters/README.md#getparametersauthorslug) - Get a model's supported parameters and data about which are most popular
245
-
*[`postCreditsCoinbase`](docs/sdks/openrouter/README.md#postcreditscoinbase) - Create a Coinbase charge for crypto payment
225
+
-[`analyticsGetActivity`](docs/sdks/analytics/README.md#getactivity) - Get user activity grouped by endpoint
226
+
-[`apiKeysDeleteKeysHash`](docs/sdks/apikeys/README.md#deletekeyshash) - Delete an API key
227
+
-[`apiKeysGetAuthKey`](docs/sdks/apikeys/README.md#getauthkey) - Get current API key
228
+
-[`apiKeysGetKey`](docs/sdks/apikeys/README.md#getkey) - Get current API key
229
+
-[`apiKeysGetKeys`](docs/sdks/apikeys/README.md#getkeys) - List API keys
230
+
-[`apiKeysGetKeysHash`](docs/sdks/apikeys/README.md#getkeyshash) - Get a single API key
231
+
-[`apiKeysPatchKeysHash`](docs/sdks/apikeys/README.md#patchkeyshash) - Update an API key
232
+
-[`apiKeysPostKeys`](docs/sdks/apikeys/README.md#postkeys) - Create a new API key
233
+
-[`chatSend`](docs/sdks/chat/README.md#send) - Create a chat completion
234
+
-[`embeddingsPostEmbeddings`](docs/sdks/embeddings/README.md#postembeddings) - Submit an embedding request
235
+
-[`endpointsGetEndpointsZdr`](docs/sdks/endpoints/README.md#getendpointszdr) - Preview the impact of ZDR on the available endpoints
236
+
-[`endpointsGetModelsAuthorSlugEndpoints`](docs/sdks/endpoints/README.md#getmodelsauthorslugendpoints) - List all endpoints for a model
237
+
-[`generationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
238
+
-[`getCredits`](docs/sdks/openrouter/README.md#getcredits) - Get total credits purchased and used for the authenticated user
-[`modelsGetModels`](docs/sdks/models/README.md#getmodels) - List all models and their properties
241
+
-[`modelsGetModelsCount`](docs/sdks/models/README.md#getmodelscount) - Get total count of available models
242
+
-[`modelsGetModelsUser`](docs/sdks/models/README.md#getmodelsuser) - List models filtered by user provider preferences
243
+
-[`parametersGetParametersAuthorSlug`](docs/sdks/parameters/README.md#getparametersauthorslug) - Get a model's supported parameters and data about which are most popular
244
+
-[`postCreditsCoinbase`](docs/sdks/openrouter/README.md#postcreditscoinbase) - Create a Coinbase charge for crypto payment
246
245
247
246
</details>
248
247
<!-- End Standalone functions [standalone-funcs] -->
@@ -269,26 +268,26 @@ To learn about this feature and how to get started, check
269
268
270
269
<summary>Available React hooks</summary>
271
270
272
-
*[`useAnalyticsGetActivity`](docs/sdks/analytics/README.md#getactivity) - Get user activity grouped by endpoint
273
-
*[`useApiKeysDeleteKeysHashMutation`](docs/sdks/apikeys/README.md#deletekeyshash) - Delete an API key
274
-
*[`useApiKeysGetAuthKey`](docs/sdks/apikeys/README.md#getauthkey) - Get current API key
275
-
*[`useApiKeysGetKey`](docs/sdks/apikeys/README.md#getkey) - Get current API key
276
-
*[`useApiKeysGetKeys`](docs/sdks/apikeys/README.md#getkeys) - List API keys
277
-
*[`useApiKeysGetKeysHash`](docs/sdks/apikeys/README.md#getkeyshash) - Get a single API key
278
-
*[`useApiKeysPatchKeysHashMutation`](docs/sdks/apikeys/README.md#patchkeyshash) - Update an API key
279
-
*[`useApiKeysPostKeysMutation`](docs/sdks/apikeys/README.md#postkeys) - Create a new API key
280
-
*[`useChatSendMutation`](docs/sdks/chat/README.md#send) - Create a chat completion
281
-
*[`useEmbeddingsPostEmbeddingsMutation`](docs/sdks/embeddings/README.md#postembeddings) - Submit an embedding request
282
-
*[`useEndpointsGetEndpointsZdr`](docs/sdks/endpoints/README.md#getendpointszdr) - Preview the impact of ZDR on the available endpoints
283
-
*[`useEndpointsGetModelsAuthorSlugEndpoints`](docs/sdks/endpoints/README.md#getmodelsauthorslugendpoints) - List all endpoints for a model
284
-
*[`useGenerationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
285
-
*[`useGetCredits`](docs/sdks/openrouter/README.md#getcredits) - Get total credits purchased and used for the authenticated user
*[`useModelsGetModels`](docs/sdks/models/README.md#getmodels) - List all models and their properties
288
-
*[`useModelsGetModelsCount`](docs/sdks/models/README.md#getmodelscount) - Get total count of available models
289
-
*[`useModelsGetModelsUser`](docs/sdks/models/README.md#getmodelsuser) - List models filtered by user provider preferences
290
-
*[`useParametersGetParametersAuthorSlug`](docs/sdks/parameters/README.md#getparametersauthorslug) - Get a model's supported parameters and data about which are most popular
291
-
*[`usePostCreditsCoinbaseMutation`](docs/sdks/openrouter/README.md#postcreditscoinbase) - Create a Coinbase charge for crypto payment
271
+
-[`useAnalyticsGetActivity`](docs/sdks/analytics/README.md#getactivity) - Get user activity grouped by endpoint
272
+
-[`useApiKeysDeleteKeysHashMutation`](docs/sdks/apikeys/README.md#deletekeyshash) - Delete an API key
273
+
-[`useApiKeysGetAuthKey`](docs/sdks/apikeys/README.md#getauthkey) - Get current API key
274
+
-[`useApiKeysGetKey`](docs/sdks/apikeys/README.md#getkey) - Get current API key
275
+
-[`useApiKeysGetKeys`](docs/sdks/apikeys/README.md#getkeys) - List API keys
276
+
-[`useApiKeysGetKeysHash`](docs/sdks/apikeys/README.md#getkeyshash) - Get a single API key
277
+
-[`useApiKeysPatchKeysHashMutation`](docs/sdks/apikeys/README.md#patchkeyshash) - Update an API key
278
+
-[`useApiKeysPostKeysMutation`](docs/sdks/apikeys/README.md#postkeys) - Create a new API key
279
+
-[`useChatSendMutation`](docs/sdks/chat/README.md#send) - Create a chat completion
280
+
-[`useEmbeddingsPostEmbeddingsMutation`](docs/sdks/embeddings/README.md#postembeddings) - Submit an embedding request
281
+
-[`useEndpointsGetEndpointsZdr`](docs/sdks/endpoints/README.md#getendpointszdr) - Preview the impact of ZDR on the available endpoints
282
+
-[`useEndpointsGetModelsAuthorSlugEndpoints`](docs/sdks/endpoints/README.md#getmodelsauthorslugendpoints) - List all endpoints for a model
283
+
-[`useGenerationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
284
+
-[`useGetCredits`](docs/sdks/openrouter/README.md#getcredits) - Get total credits purchased and used for the authenticated user
-[`useModelsGetModels`](docs/sdks/models/README.md#getmodels) - List all models and their properties
287
+
-[`useModelsGetModelsCount`](docs/sdks/models/README.md#getmodelscount) - Get total count of available models
288
+
-[`useModelsGetModelsUser`](docs/sdks/models/README.md#getmodelsuser) - List models filtered by user provider preferences
289
+
-[`useParametersGetParametersAuthorSlug`](docs/sdks/parameters/README.md#getparametersauthorslug) - Get a model's supported parameters and data about which are most popular
290
+
-[`usePostCreditsCoinbaseMutation`](docs/sdks/openrouter/README.md#postcreditscoinbase) - Create a Coinbase charge for crypto payment
292
291
293
292
</details>
294
293
<!-- End React hooks with TanStack Query [react-query] -->
@@ -331,7 +330,6 @@ run();
331
330
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
332
331
333
332
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
334
-
335
333
```typescript
336
334
import { OpenRouter } from"openrouter";
337
335
@@ -363,7 +361,6 @@ run();
363
361
```
364
362
365
363
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
366
-
367
364
```typescript
368
365
import { OpenRouter } from"openrouter";
369
366
@@ -409,7 +406,6 @@ run();
409
406
|`error.data$`|| Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
410
407
411
408
### Example
412
-
413
409
```typescript
414
410
import { OpenRouter } from"openrouter";
415
411
import*aserrorsfrom"openrouter/models/errors";
@@ -446,25 +442,22 @@ run();
446
442
```
447
443
448
444
### Error Classes
449
-
450
445
**Primary error:**
451
-
452
446
*[`OpenRouterError`](./src/models/errors/openroutererror.ts): The base class for HTTP error responses.
453
447
454
448
<details><summary>Less common errors (8)</summary>
455
449
456
450
<br />
457
451
458
452
**Network errors:**
459
-
460
453
*[`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
461
454
*[`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
462
455
*[`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
463
456
*[`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
464
457
*[`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
465
458
466
-
**Inherit from [`OpenRouterError`](./src/models/errors/openroutererror.ts)**:
467
459
460
+
**Inherit from [`OpenRouterError`](./src/models/errors/openroutererror.ts)**:
468
461
*[`ChatError`](./src/models/errors/chaterror.ts): Bad request - invalid parameters. Applicable to 1 of 20 methods.*
469
462
*[`InternalServerError`](./src/models/errors/internalservererror.ts): Internal Server Error. Status code `500`. Applicable to 1 of 20 methods.*
470
463
*[`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.
0 commit comments