@openrouter/sdk 0.0.1-beta.14 → 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/README.md +25 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/chatgenerationtokenusage.d.ts +2 -2
- package/esm/models/chatgenerationtokenusage.js +2 -4
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/vitest.config.ts +11 -3
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
|
|
|
@@ -1162,6 +1163,30 @@ You can also enable a default debug logger by setting an environment variable `O
|
|
|
1162
1163
|
|
|
1163
1164
|
# Development
|
|
1164
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
|
+
|
|
1165
1190
|
## Maturity
|
|
1166
1191
|
|
|
1167
1192
|
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
package/esm/lib/config.d.ts
CHANGED
|
@@ -37,8 +37,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
37
37
|
export declare const SDK_METADATA: {
|
|
38
38
|
readonly language: "typescript";
|
|
39
39
|
readonly openapiDocVersion: "1.0.0";
|
|
40
|
-
readonly sdkVersion: "0.0.1-beta.
|
|
40
|
+
readonly sdkVersion: "0.0.1-beta.16";
|
|
41
41
|
readonly genVersion: "2.731.4";
|
|
42
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.0.1-beta.
|
|
42
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.0.1-beta.16 2.731.4 1.0.0 @openrouter/sdk";
|
|
43
43
|
};
|
|
44
44
|
//# sourceMappingURL=config.d.ts.map
|
package/esm/lib/config.js
CHANGED
|
@@ -25,8 +25,8 @@ export function serverURLFromOptions(options) {
|
|
|
25
25
|
export const SDK_METADATA = {
|
|
26
26
|
language: "typescript",
|
|
27
27
|
openapiDocVersion: "1.0.0",
|
|
28
|
-
sdkVersion: "0.0.1-beta.
|
|
28
|
+
sdkVersion: "0.0.1-beta.16",
|
|
29
29
|
genVersion: "2.731.4",
|
|
30
|
-
userAgent: "speakeasy-sdk/typescript 0.0.1-beta.
|
|
30
|
+
userAgent: "speakeasy-sdk/typescript 0.0.1-beta.16 2.731.4 1.0.0 @openrouter/sdk",
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=config.js.map
|
|
@@ -16,7 +16,7 @@ export type ChatGenerationTokenUsage = {
|
|
|
16
16
|
promptTokens: number;
|
|
17
17
|
totalTokens: number;
|
|
18
18
|
completionTokensDetails?: CompletionTokensDetails | undefined;
|
|
19
|
-
promptTokensDetails?: PromptTokensDetails | undefined;
|
|
19
|
+
promptTokensDetails?: PromptTokensDetails | null | undefined;
|
|
20
20
|
};
|
|
21
21
|
/** @internal */
|
|
22
22
|
export declare const CompletionTokensDetails$inboundSchema: z.ZodType<CompletionTokensDetails, unknown>;
|
|
@@ -74,7 +74,7 @@ export type ChatGenerationTokenUsage$Outbound = {
|
|
|
74
74
|
prompt_tokens: number;
|
|
75
75
|
total_tokens: number;
|
|
76
76
|
completion_tokens_details?: CompletionTokensDetails$Outbound | undefined;
|
|
77
|
-
prompt_tokens_details?: PromptTokensDetails$Outbound | undefined;
|
|
77
|
+
prompt_tokens_details?: PromptTokensDetails$Outbound | null | undefined;
|
|
78
78
|
};
|
|
79
79
|
/** @internal */
|
|
80
80
|
export declare const ChatGenerationTokenUsage$outboundSchema: z.ZodType<ChatGenerationTokenUsage$Outbound, ChatGenerationTokenUsage>;
|
|
@@ -93,8 +93,7 @@ export const ChatGenerationTokenUsage$inboundSchema = z.object({
|
|
|
93
93
|
total_tokens: z.number(),
|
|
94
94
|
completion_tokens_details: z.lazy(() => CompletionTokensDetails$inboundSchema)
|
|
95
95
|
.optional(),
|
|
96
|
-
prompt_tokens_details: z.lazy(() => PromptTokensDetails$inboundSchema)
|
|
97
|
-
.optional(),
|
|
96
|
+
prompt_tokens_details: z.nullable(z.lazy(() => PromptTokensDetails$inboundSchema)).optional(),
|
|
98
97
|
}).transform((v) => {
|
|
99
98
|
return remap$(v, {
|
|
100
99
|
"completion_tokens": "completionTokens",
|
|
@@ -111,8 +110,7 @@ export const ChatGenerationTokenUsage$outboundSchema = z.object({
|
|
|
111
110
|
totalTokens: z.number(),
|
|
112
111
|
completionTokensDetails: z.lazy(() => CompletionTokensDetails$outboundSchema)
|
|
113
112
|
.optional(),
|
|
114
|
-
promptTokensDetails: z.lazy(() => PromptTokensDetails$outboundSchema)
|
|
115
|
-
.optional(),
|
|
113
|
+
promptTokensDetails: z.nullable(z.lazy(() => PromptTokensDetails$outboundSchema)).optional(),
|
|
116
114
|
}).transform((v) => {
|
|
117
115
|
return remap$(v, {
|
|
118
116
|
completionTokens: "completion_tokens",
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/vitest.config.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { config } from "dotenv";
|
|
2
2
|
import { defineConfig } from "vitest/config";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { dirname, join } from "path";
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
// Load environment variables from .env file if it exists
|
|
10
|
+
// This will not override existing environment variables
|
|
11
|
+
config({ path: join(__dirname, ".env") });
|
|
6
12
|
|
|
7
13
|
export default defineConfig({
|
|
8
14
|
test: {
|
|
9
15
|
globals: true,
|
|
10
16
|
environment: "node",
|
|
17
|
+
// Don't override env vars - just let them pass through from the system
|
|
18
|
+
// The env object here will be merged with process.env
|
|
11
19
|
env: {
|
|
12
|
-
OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY
|
|
20
|
+
OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
|
|
13
21
|
},
|
|
14
22
|
include: ["tests/**/*.test.ts"],
|
|
15
23
|
hookTimeout: 30000,
|