Skip to content

Commit 998edb0

Browse files
committed
fixes and tests
1 parent 52d6fdd commit 998edb0

18 files changed

+419
-96
lines changed

.speakeasy/gen.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
lockVersion: 2.0.0
22
id: 8b6cd71c-ea04-44da-af45-e43968b5928d
33
management:
4-
docChecksum: a815b143d071828ce4ab7b3a743ec82c
4+
docChecksum: 9d79e7680beab7c04249798b91065cc4
55
docVersion: 1.0.0
66
speakeasyVersion: 1.642.1
77
generationVersion: 2.731.4
8-
releaseVersion: 0.0.1-beta.14
9-
configChecksum: 6639946bd9c6d122465a7506943348f4
8+
releaseVersion: 0.0.1-beta.16
9+
configChecksum: 4a7712d499110c49acf1cf697001b209
1010
repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git
1111
installationURL: https://github.com/OpenRouterTeam/typescript-sdk
1212
published: true

.speakeasy/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ generation:
2929
generateNewTests: true
3030
skipResponseBodyAssertions: false
3131
typescript:
32-
version: 0.0.1-beta.14
32+
version: 0.0.1-beta.16
3333
acceptHeaderEnum: false
3434
additionalDependencies:
3535
dependencies: {}

.speakeasy/in.openapi.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,12 +4756,14 @@ components:
47564756
rejected_prediction_tokens:
47574757
type: number
47584758
prompt_tokens_details:
4759-
type: object
4760-
properties:
4761-
cached_tokens:
4762-
type: number
4763-
audio_tokens:
4764-
type: number
4759+
anyOf:
4760+
- type: object
4761+
properties:
4762+
cached_tokens:
4763+
type: number
4764+
audio_tokens:
4765+
type: number
4766+
- type: 'null'
47654767
required:
47664768
- completion_tokens
47674769
- prompt_tokens

.speakeasy/out.openapi.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4779,12 +4779,14 @@ components:
47794779
rejected_prediction_tokens:
47804780
type: number
47814781
prompt_tokens_details:
4782-
type: object
4783-
properties:
4784-
cached_tokens:
4785-
type: number
4786-
audio_tokens:
4787-
type: number
4782+
anyOf:
4783+
- type: object
4784+
properties:
4785+
cached_tokens:
4786+
type: number
4787+
audio_tokens:
4788+
type: number
4789+
- type: 'null'
47884790
required:
47894791
- completion_tokens
47904792
- prompt_tokens

.speakeasy/workflow.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ speakeasyVersion: 1.642.1
22
sources:
33
OpenRouter API:
44
sourceNamespace: open-router-chat-completions-api
5-
sourceRevisionDigest: sha256:6dd11a2a3212f61a00c0e0b6309aaf39cc3d2575493aea2b54aafb0cf187d272
6-
sourceBlobDigest: sha256:e46f40a6a57e7eb1c21a40c388f46b9b7b36ed0dd9ea78d480d300d83ace2fe3
5+
sourceRevisionDigest: sha256:d5386ba830642c25b458e63884bd42475fcb8b37d442312cbc7468a541d3e5c0
6+
sourceBlobDigest: sha256:c4cf70faabb2eed400c9b5e1a9185ae65baf8f5cb2575ad4457f6a4fe340a931
77
tags:
88
- latest
99
- 1.0.0
1010
targets:
1111
openrouter:
1212
source: OpenRouter API
1313
sourceNamespace: open-router-chat-completions-api
14-
sourceRevisionDigest: sha256:6dd11a2a3212f61a00c0e0b6309aaf39cc3d2575493aea2b54aafb0cf187d272
15-
sourceBlobDigest: sha256:e46f40a6a57e7eb1c21a40c388f46b9b7b36ed0dd9ea78d480d300d83ace2fe3
14+
sourceRevisionDigest: sha256:d5386ba830642c25b458e63884bd42475fcb8b37d442312cbc7468a541d3e5c0
15+
sourceBlobDigest: sha256:c4cf70faabb2eed400c9b5e1a9185ae65baf8f5cb2575ad4457f6a4fe340a931
1616
codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples
17-
codeSamplesRevisionDigest: sha256:1d36752fa1859baae015ab744eb16369c7c2a9d9de92e60135d98860d2ab4741
17+
codeSamplesRevisionDigest: sha256:c880eaee9f97ea8027b797a2fc9b2b561f763470c9f68c1e0b865b78150ff5b3
1818
workflow:
1919
workflowVersion: 1.0.0
2020
speakeasyVersion: latest

README.md

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The [OpenRouter](https://openrouter.ai/) SDK gives access to over 300 large lang
2020
* [Error Handling](#error-handling)
2121
* [Debugging](#debugging)
2222
* [Development](#development)
23+
* [Running Tests](#running-tests)
2324
* [Maturity](#maturity)
2425
* [Contributions](#contributions)
2526

@@ -216,7 +217,6 @@ This SDK supports the following security scheme globally:
216217
| `apiKey` | http | HTTP Bearer | `OPENROUTER_API_KEY` |
217218

218219
To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:
219-
220220
```typescript
221221
import { OpenRouter } from "@openrouter/sdk";
222222

@@ -345,7 +345,6 @@ run();
345345
### Per-Operation Security Schemes
346346

347347
Some operations in this SDK require the security scheme to be specified at the request level. For example:
348-
349348
```typescript
350349
import { OpenRouter } from "@openrouter/sdk";
351350

@@ -450,28 +449,28 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
450449

451450
<summary>Available standalone functions</summary>
452451

453-
* [`analyticsGetUserActivity`](docs/sdks/analytics/README.md#getuseractivity) - Get user activity grouped by endpoint
454-
* [`apiKeysCreate`](docs/sdks/apikeys/README.md#create) - Create a new API key
455-
* [`apiKeysDelete`](docs/sdks/apikeys/README.md#delete) - Delete an API key
456-
* [`apiKeysGet`](docs/sdks/apikeys/README.md#get) - Get a single API key
457-
* [`apiKeysGetCurrentKeyMetadata`](docs/sdks/apikeys/README.md#getcurrentkeymetadata) - Get current API key
458-
* [`apiKeysList`](docs/sdks/apikeys/README.md#list) - List API keys
459-
* [`apiKeysUpdate`](docs/sdks/apikeys/README.md#update) - Update an API key
460-
* [`betaResponsesSend`](docs/sdks/responses/README.md#send) - Create a response
461-
* [`chatSend`](docs/sdks/chat/README.md#send) - Create a chat completion
462-
* [`completionsGenerate`](docs/sdks/completions/README.md#generate) - Create a completion
463-
* [`creditsCreateCoinbaseCharge`](docs/sdks/credits/README.md#createcoinbasecharge) - Create a Coinbase charge for crypto payment
464-
* [`creditsGetCredits`](docs/sdks/credits/README.md#getcredits) - Get remaining credits
465-
* [`endpointsList`](docs/sdks/endpoints/README.md#list) - List all endpoints for a model
466-
* [`endpointsListZdrEndpoints`](docs/sdks/endpoints/README.md#listzdrendpoints) - Preview the impact of ZDR on the available endpoints
467-
* [`generationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
468-
* [`modelsCount`](docs/sdks/models/README.md#count) - Get total count of available models
469-
* [`modelsList`](docs/sdks/models/README.md#list) - List all models and their properties
470-
* [`modelsListForUser`](docs/sdks/models/README.md#listforuser) - List models filtered by user provider preferences
471-
* [`oAuthCreateAuthCode`](docs/sdks/oauth/README.md#createauthcode) - Create authorization code
472-
* [`oAuthExchangeAuthCodeForAPIKey`](docs/sdks/oauth/README.md#exchangeauthcodeforapikey) - Exchange authorization code for API key
473-
* [`parametersGetParameters`](docs/sdks/parameters/README.md#getparameters) - Get a model's supported parameters and data about which are most popular
474-
* [`providersList`](docs/sdks/providers/README.md#list) - List all providers
452+
- [`analyticsGetUserActivity`](docs/sdks/analytics/README.md#getuseractivity) - Get user activity grouped by endpoint
453+
- [`apiKeysCreate`](docs/sdks/apikeys/README.md#create) - Create a new API key
454+
- [`apiKeysDelete`](docs/sdks/apikeys/README.md#delete) - Delete an API key
455+
- [`apiKeysGet`](docs/sdks/apikeys/README.md#get) - Get a single API key
456+
- [`apiKeysGetCurrentKeyMetadata`](docs/sdks/apikeys/README.md#getcurrentkeymetadata) - Get current API key
457+
- [`apiKeysList`](docs/sdks/apikeys/README.md#list) - List API keys
458+
- [`apiKeysUpdate`](docs/sdks/apikeys/README.md#update) - Update an API key
459+
- [`betaResponsesSend`](docs/sdks/responses/README.md#send) - Create a response
460+
- [`chatSend`](docs/sdks/chat/README.md#send) - Create a chat completion
461+
- [`completionsGenerate`](docs/sdks/completions/README.md#generate) - Create a completion
462+
- [`creditsCreateCoinbaseCharge`](docs/sdks/credits/README.md#createcoinbasecharge) - Create a Coinbase charge for crypto payment
463+
- [`creditsGetCredits`](docs/sdks/credits/README.md#getcredits) - Get remaining credits
464+
- [`endpointsList`](docs/sdks/endpoints/README.md#list) - List all endpoints for a model
465+
- [`endpointsListZdrEndpoints`](docs/sdks/endpoints/README.md#listzdrendpoints) - Preview the impact of ZDR on the available endpoints
466+
- [`generationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
467+
- [`modelsCount`](docs/sdks/models/README.md#count) - Get total count of available models
468+
- [`modelsList`](docs/sdks/models/README.md#list) - List all models and their properties
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
472+
- [`parametersGetParameters`](docs/sdks/parameters/README.md#getparameters) - Get a model's supported parameters and data about which are most popular
473+
- [`providersList`](docs/sdks/providers/README.md#list) - List all providers
475474

476475
</details>
477476
<!-- End Standalone functions [standalone-funcs] -->
@@ -498,28 +497,28 @@ To learn about this feature and how to get started, check
498497

499498
<summary>Available React hooks</summary>
500499

501-
* [`useAnalyticsGetUserActivity`](docs/sdks/analytics/README.md#getuseractivity) - Get user activity grouped by endpoint
502-
* [`useApiKeysCreateMutation`](docs/sdks/apikeys/README.md#create) - Create a new API key
503-
* [`useApiKeysDeleteMutation`](docs/sdks/apikeys/README.md#delete) - Delete an API key
504-
* [`useApiKeysGet`](docs/sdks/apikeys/README.md#get) - Get a single API key
505-
* [`useApiKeysGetCurrentKeyMetadata`](docs/sdks/apikeys/README.md#getcurrentkeymetadata) - Get current API key
506-
* [`useApiKeysList`](docs/sdks/apikeys/README.md#list) - List API keys
507-
* [`useApiKeysUpdateMutation`](docs/sdks/apikeys/README.md#update) - Update an API key
508-
* [`useBetaResponsesSendMutation`](docs/sdks/responses/README.md#send) - Create a response
509-
* [`useChatSendMutation`](docs/sdks/chat/README.md#send) - Create a chat completion
510-
* [`useCompletionsGenerateMutation`](docs/sdks/completions/README.md#generate) - Create a completion
511-
* [`useCreditsCreateCoinbaseChargeMutation`](docs/sdks/credits/README.md#createcoinbasecharge) - Create a Coinbase charge for crypto payment
512-
* [`useCreditsGetCredits`](docs/sdks/credits/README.md#getcredits) - Get remaining credits
513-
* [`useEndpointsList`](docs/sdks/endpoints/README.md#list) - List all endpoints for a model
514-
* [`useEndpointsListZdrEndpoints`](docs/sdks/endpoints/README.md#listzdrendpoints) - Preview the impact of ZDR on the available endpoints
515-
* [`useGenerationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
516-
* [`useModelsCount`](docs/sdks/models/README.md#count) - Get total count of available models
517-
* [`useModelsList`](docs/sdks/models/README.md#list) - List all models and their properties
518-
* [`useModelsListForUser`](docs/sdks/models/README.md#listforuser) - List models filtered by user provider preferences
519-
* [`useOAuthCreateAuthCodeMutation`](docs/sdks/oauth/README.md#createauthcode) - Create authorization code
520-
* [`useOAuthExchangeAuthCodeForAPIKeyMutation`](docs/sdks/oauth/README.md#exchangeauthcodeforapikey) - Exchange authorization code for API key
521-
* [`useParametersGetParameters`](docs/sdks/parameters/README.md#getparameters) - Get a model's supported parameters and data about which are most popular
522-
* [`useProvidersList`](docs/sdks/providers/README.md#list) - List all providers
500+
- [`useAnalyticsGetUserActivity`](docs/sdks/analytics/README.md#getuseractivity) - Get user activity grouped by endpoint
501+
- [`useApiKeysCreateMutation`](docs/sdks/apikeys/README.md#create) - Create a new API key
502+
- [`useApiKeysDeleteMutation`](docs/sdks/apikeys/README.md#delete) - Delete an API key
503+
- [`useApiKeysGet`](docs/sdks/apikeys/README.md#get) - Get a single API key
504+
- [`useApiKeysGetCurrentKeyMetadata`](docs/sdks/apikeys/README.md#getcurrentkeymetadata) - Get current API key
505+
- [`useApiKeysList`](docs/sdks/apikeys/README.md#list) - List API keys
506+
- [`useApiKeysUpdateMutation`](docs/sdks/apikeys/README.md#update) - Update an API key
507+
- [`useBetaResponsesSendMutation`](docs/sdks/responses/README.md#send) - Create a response
508+
- [`useChatSendMutation`](docs/sdks/chat/README.md#send) - Create a chat completion
509+
- [`useCompletionsGenerateMutation`](docs/sdks/completions/README.md#generate) - Create a completion
510+
- [`useCreditsCreateCoinbaseChargeMutation`](docs/sdks/credits/README.md#createcoinbasecharge) - Create a Coinbase charge for crypto payment
511+
- [`useCreditsGetCredits`](docs/sdks/credits/README.md#getcredits) - Get remaining credits
512+
- [`useEndpointsList`](docs/sdks/endpoints/README.md#list) - List all endpoints for a model
513+
- [`useEndpointsListZdrEndpoints`](docs/sdks/endpoints/README.md#listzdrendpoints) - Preview the impact of ZDR on the available endpoints
514+
- [`useGenerationsGetGeneration`](docs/sdks/generations/README.md#getgeneration) - Get request & usage metadata for a generation
515+
- [`useModelsCount`](docs/sdks/models/README.md#count) - Get total count of available models
516+
- [`useModelsList`](docs/sdks/models/README.md#list) - List all models and their properties
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
520+
- [`useParametersGetParameters`](docs/sdks/parameters/README.md#getparameters) - Get a model's supported parameters and data about which are most popular
521+
- [`useProvidersList`](docs/sdks/providers/README.md#list) - List all providers
523522

524523
</details>
525524
<!-- End React hooks with TanStack Query [react-query] -->
@@ -668,7 +667,6 @@ run();
668667
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.
669668

670669
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
671-
672670
```typescript
673671
import { OpenRouter } from "@openrouter/sdk";
674672

@@ -806,7 +804,6 @@ run();
806804
```
807805

808806
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
809-
810807
```typescript
811808
import { OpenRouter } from "@openrouter/sdk";
812809

@@ -958,7 +955,6 @@ run();
958955
| `error.data$` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
959956

960957
### Example
961-
962958
```typescript
963959
import { OpenRouter } from "@openrouter/sdk";
964960
import * as errors from "@openrouter/sdk/models/errors";
@@ -1102,9 +1098,7 @@ run();
11021098
```
11031099

11041100
### Error Classes
1105-
11061101
**Primary errors:**
1107-
11081102
* [`OpenRouterError`](./src/models/errors/openroutererror.ts): The base class for HTTP error responses.
11091103
* [`InternalServerResponseError`](./src/models/errors/internalserverresponseerror.ts): Internal Server Error - Unexpected server error. Status code `500`. *
11101104

@@ -1113,15 +1107,14 @@ run();
11131107
<br />
11141108

11151109
**Network errors:**
1116-
11171110
* [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
11181111
* [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
11191112
* [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
11201113
* [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
11211114
* [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
11221115

1123-
**Inherit from [`OpenRouterError`](./src/models/errors/openroutererror.ts)**:
11241116

1117+
**Inherit from [`OpenRouterError`](./src/models/errors/openroutererror.ts)**:
11251118
* [`UnauthorizedResponseError`](./src/models/errors/unauthorizedresponseerror.ts): Unauthorized - Authentication required or invalid credentials. Status code `401`. Applicable to 14 of 22 methods.*
11261119
* [`BadRequestResponseError`](./src/models/errors/badrequestresponseerror.ts): Bad Request - Invalid request parameters or malformed input. Status code `400`. Applicable to 8 of 22 methods.*
11271120
* [`TooManyRequestsResponseError`](./src/models/errors/toomanyrequestsresponseerror.ts): Too Many Requests - Rate limit exceeded. Status code `429`. Applicable to 8 of 22 methods.*

docs/models/chatgenerationtokenusage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let value: ChatGenerationTokenUsage = {
1616
rejectedPredictionTokens: 2801.33,
1717
},
1818
promptTokensDetails: {
19-
cachedTokens: 6205.53,
20-
audioTokens: 1522.95,
19+
cachedTokens: 1522.95,
20+
audioTokens: 8854.61,
2121
},
2222
};
2323
```

docs/models/chatresponse.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ let value: ChatResponse = {
2323
rejectedPredictionTokens: 2801.33,
2424
},
2525
promptTokensDetails: {
26-
cachedTokens: 6205.53,
27-
audioTokens: 1522.95,
26+
cachedTokens: 1522.95,
27+
audioTokens: 8854.61,
2828
},
2929
},
3030
};

docs/models/chatstreamingresponsechunk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ let value: ChatStreamingResponseChunk = {
7474
rejectedPredictionTokens: 2801.33,
7575
},
7676
promptTokensDetails: {
77-
cachedTokens: 6205.53,
78-
audioTokens: 1522.95,
77+
cachedTokens: 1522.95,
78+
audioTokens: 8854.61,
7979
},
8080
},
8181
},

docs/models/chatstreamingresponsechunkdata.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ let value: ChatStreamingResponseChunkData = {
2727
rejectedPredictionTokens: 2801.33,
2828
},
2929
promptTokensDetails: {
30-
cachedTokens: 6205.53,
31-
audioTokens: 1522.95,
30+
cachedTokens: 1522.95,
31+
audioTokens: 8854.61,
3232
},
3333
},
3434
};

0 commit comments

Comments
 (0)