@openrouter/sdk 0.0.1 → 0.1.0
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 +1 -109
- package/REACT_QUERY.md +4 -121
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/.devcontainer/README.md +0 -35
- package/examples/README.md +0 -31
package/FUNCTIONS.md
CHANGED
|
@@ -29,115 +29,7 @@ const openRouter = new OpenRouterCore({
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
async function run() {
|
|
32
|
-
const res = await betaResponsesSend(openRouter, {
|
|
33
|
-
input: [
|
|
34
|
-
{
|
|
35
|
-
type: "message",
|
|
36
|
-
role: "user",
|
|
37
|
-
content: "Hello, how are you?",
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
instructions: "<value>",
|
|
41
|
-
metadata: {
|
|
42
|
-
"user_id": "123",
|
|
43
|
-
"session_id": "abc-def-ghi",
|
|
44
|
-
},
|
|
45
|
-
tools: [
|
|
46
|
-
{
|
|
47
|
-
type: "function",
|
|
48
|
-
name: "get_current_weather",
|
|
49
|
-
description: "Get the current weather in a given location",
|
|
50
|
-
strict: true,
|
|
51
|
-
parameters: {
|
|
52
|
-
"type": "object",
|
|
53
|
-
"properties": {
|
|
54
|
-
"location": {
|
|
55
|
-
"type": "string",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
toolChoice: {
|
|
62
|
-
type: "function",
|
|
63
|
-
name: "<value>",
|
|
64
|
-
},
|
|
65
|
-
parallelToolCalls: true,
|
|
66
|
-
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
67
|
-
models: [
|
|
68
|
-
"<value 1>",
|
|
69
|
-
],
|
|
70
|
-
text: {
|
|
71
|
-
format: {
|
|
72
|
-
type: "text",
|
|
73
|
-
},
|
|
74
|
-
verbosity: "medium",
|
|
75
|
-
},
|
|
76
|
-
reasoning: {
|
|
77
|
-
effort: "high",
|
|
78
|
-
summary: "auto",
|
|
79
|
-
maxTokens: 8661.16,
|
|
80
|
-
enabled: true,
|
|
81
|
-
},
|
|
82
|
-
maxOutputTokens: null,
|
|
83
|
-
temperature: 0.7,
|
|
84
|
-
topP: 0.9,
|
|
85
|
-
topK: 193.77,
|
|
86
|
-
promptCacheKey: "<value>",
|
|
87
|
-
previousResponseId: "<id>",
|
|
88
|
-
prompt: {
|
|
89
|
-
id: "<id>",
|
|
90
|
-
variables: {
|
|
91
|
-
"key": {
|
|
92
|
-
type: "input_text",
|
|
93
|
-
text: "Hello, how can I help you?",
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
include: [
|
|
98
|
-
"reasoning.encrypted_content",
|
|
99
|
-
],
|
|
100
|
-
background: true,
|
|
101
|
-
safetyIdentifier: "<value>",
|
|
102
|
-
store: true,
|
|
103
|
-
serviceTier: "auto",
|
|
104
|
-
truncation: "auto",
|
|
105
|
-
provider: {
|
|
106
|
-
allowFallbacks: null,
|
|
107
|
-
requireParameters: true,
|
|
108
|
-
dataCollection: "deny",
|
|
109
|
-
zdr: true,
|
|
110
|
-
order: [
|
|
111
|
-
"OpenAI",
|
|
112
|
-
],
|
|
113
|
-
only: [
|
|
114
|
-
"OpenAI",
|
|
115
|
-
],
|
|
116
|
-
ignore: null,
|
|
117
|
-
quantizations: [
|
|
118
|
-
"fp16",
|
|
119
|
-
],
|
|
120
|
-
sort: "price",
|
|
121
|
-
maxPrice: {
|
|
122
|
-
prompt: "1000",
|
|
123
|
-
completion: 1000,
|
|
124
|
-
image: 1000,
|
|
125
|
-
audio: "1000",
|
|
126
|
-
request: 1000,
|
|
127
|
-
},
|
|
128
|
-
experimental: {},
|
|
129
|
-
},
|
|
130
|
-
plugins: [
|
|
131
|
-
{
|
|
132
|
-
id: "file-parser",
|
|
133
|
-
maxFiles: 4870.55,
|
|
134
|
-
pdf: {
|
|
135
|
-
engine: "mistral-ocr",
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
user: "Elmer_Yundt72",
|
|
140
|
-
});
|
|
32
|
+
const res = await betaResponsesSend(openRouter, {});
|
|
141
33
|
if (res.ok) {
|
|
142
34
|
const { value: result } = res;
|
|
143
35
|
console.log(result);
|
package/REACT_QUERY.md
CHANGED
|
@@ -53,9 +53,7 @@ from TanStack Query.
|
|
|
53
53
|
import { useAnalyticsGetUserActivity } from "@openrouter/sdk/react-query/analyticsGetUserActivity.js";
|
|
54
54
|
|
|
55
55
|
export function Example() {
|
|
56
|
-
const { data, error, status } = useAnalyticsGetUserActivity(
|
|
57
|
-
date: "2025-08-24",
|
|
58
|
-
});
|
|
56
|
+
const { data, error, status } = useAnalyticsGetUserActivity();
|
|
59
57
|
|
|
60
58
|
// Render the UI here...
|
|
61
59
|
}
|
|
@@ -73,9 +71,6 @@ import { useAnalyticsGetUserActivity } from "@openrouter/sdk/react-query/analyti
|
|
|
73
71
|
export function ExampleWithOptions() {
|
|
74
72
|
const [enabled, setEnabled] = useState(true);
|
|
75
73
|
const { data, error, status } = useAnalyticsGetUserActivity(
|
|
76
|
-
{
|
|
77
|
-
date: "2025-08-24",
|
|
78
|
-
},
|
|
79
74
|
{
|
|
80
75
|
// TanStack Query options:
|
|
81
76
|
enabled,
|
|
@@ -124,115 +119,7 @@ export function Example() {
|
|
|
124
119
|
|
|
125
120
|
// Read form data here...
|
|
126
121
|
|
|
127
|
-
mutate({
|
|
128
|
-
input: [
|
|
129
|
-
{
|
|
130
|
-
type: "message",
|
|
131
|
-
role: "user",
|
|
132
|
-
content: "Hello, how are you?",
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
instructions: "<value>",
|
|
136
|
-
metadata: {
|
|
137
|
-
"user_id": "123",
|
|
138
|
-
"session_id": "abc-def-ghi",
|
|
139
|
-
},
|
|
140
|
-
tools: [
|
|
141
|
-
{
|
|
142
|
-
type: "function",
|
|
143
|
-
name: "get_current_weather",
|
|
144
|
-
description: "Get the current weather in a given location",
|
|
145
|
-
strict: true,
|
|
146
|
-
parameters: {
|
|
147
|
-
"type": "object",
|
|
148
|
-
"properties": {
|
|
149
|
-
"location": {
|
|
150
|
-
"type": "string",
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
toolChoice: {
|
|
157
|
-
type: "function",
|
|
158
|
-
name: "<value>",
|
|
159
|
-
},
|
|
160
|
-
parallelToolCalls: true,
|
|
161
|
-
model: "anthropic/claude-4.5-sonnet-20250929",
|
|
162
|
-
models: [
|
|
163
|
-
"<value 1>",
|
|
164
|
-
],
|
|
165
|
-
text: {
|
|
166
|
-
format: {
|
|
167
|
-
type: "text",
|
|
168
|
-
},
|
|
169
|
-
verbosity: "medium",
|
|
170
|
-
},
|
|
171
|
-
reasoning: {
|
|
172
|
-
effort: "high",
|
|
173
|
-
summary: "auto",
|
|
174
|
-
maxTokens: 8661.16,
|
|
175
|
-
enabled: true,
|
|
176
|
-
},
|
|
177
|
-
maxOutputTokens: null,
|
|
178
|
-
temperature: 0.7,
|
|
179
|
-
topP: 0.9,
|
|
180
|
-
topK: 193.77,
|
|
181
|
-
promptCacheKey: "<value>",
|
|
182
|
-
previousResponseId: "<id>",
|
|
183
|
-
prompt: {
|
|
184
|
-
id: "<id>",
|
|
185
|
-
variables: {
|
|
186
|
-
"key": {
|
|
187
|
-
type: "input_text",
|
|
188
|
-
text: "Hello, how can I help you?",
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
include: [
|
|
193
|
-
"reasoning.encrypted_content",
|
|
194
|
-
],
|
|
195
|
-
background: true,
|
|
196
|
-
safetyIdentifier: "<value>",
|
|
197
|
-
store: true,
|
|
198
|
-
serviceTier: "auto",
|
|
199
|
-
truncation: "auto",
|
|
200
|
-
provider: {
|
|
201
|
-
allowFallbacks: null,
|
|
202
|
-
requireParameters: true,
|
|
203
|
-
dataCollection: "deny",
|
|
204
|
-
zdr: true,
|
|
205
|
-
order: [
|
|
206
|
-
"OpenAI",
|
|
207
|
-
],
|
|
208
|
-
only: [
|
|
209
|
-
"OpenAI",
|
|
210
|
-
],
|
|
211
|
-
ignore: null,
|
|
212
|
-
quantizations: [
|
|
213
|
-
"fp16",
|
|
214
|
-
],
|
|
215
|
-
sort: "price",
|
|
216
|
-
maxPrice: {
|
|
217
|
-
prompt: "1000",
|
|
218
|
-
completion: 1000,
|
|
219
|
-
image: 1000,
|
|
220
|
-
audio: "1000",
|
|
221
|
-
request: 1000,
|
|
222
|
-
},
|
|
223
|
-
experimental: {},
|
|
224
|
-
},
|
|
225
|
-
plugins: [
|
|
226
|
-
{
|
|
227
|
-
id: "file-parser",
|
|
228
|
-
maxFiles: 4870.55,
|
|
229
|
-
pdf: {
|
|
230
|
-
engine: "mistral-ocr",
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
user: "Elmer_Yundt72",
|
|
235
|
-
});
|
|
122
|
+
mutate({});
|
|
236
123
|
}}
|
|
237
124
|
>
|
|
238
125
|
{/* Form fields go here... */}
|
|
@@ -366,9 +253,7 @@ export function App() {
|
|
|
366
253
|
}
|
|
367
254
|
|
|
368
255
|
function Example() {
|
|
369
|
-
const { data } = useAnalyticsGetUserActivitySuspense(
|
|
370
|
-
date: "2025-08-24",
|
|
371
|
-
});
|
|
256
|
+
const { data } = useAnalyticsGetUserActivitySuspense();
|
|
372
257
|
|
|
373
258
|
// Render the UI here...
|
|
374
259
|
}
|
|
@@ -396,9 +281,7 @@ export default async function Page() {
|
|
|
396
281
|
apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
|
|
397
282
|
});
|
|
398
283
|
|
|
399
|
-
await prefetchAnalyticsGetUserActivity(
|
|
400
|
-
date: "2025-08-24",
|
|
401
|
-
});
|
|
284
|
+
await prefetchAnalyticsGetUserActivity(openRouter);
|
|
402
285
|
|
|
403
286
|
return (
|
|
404
287
|
// HydrationBoundary is a Client Component, so hydration will happen there.
|
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
|
|
41
|
-
readonly genVersion: "2.
|
|
42
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.0
|
|
40
|
+
readonly sdkVersion: "0.1.0";
|
|
41
|
+
readonly genVersion: "2.739.1";
|
|
42
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.1.0 2.739.1 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
|
|
29
|
-
genVersion: "2.
|
|
30
|
-
userAgent: "speakeasy-sdk/typescript 0.0
|
|
28
|
+
sdkVersion: "0.1.0",
|
|
29
|
+
genVersion: "2.739.1",
|
|
30
|
+
userAgent: "speakeasy-sdk/typescript 0.1.0 2.739.1 1.0.0 @openrouter/sdk",
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=config.js.map
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/.devcontainer/README.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<div align="center">
|
|
3
|
-
<a href="https://codespaces.new/OpenRouterTeam/typescript-sdk.git/tree/main"><img src="https://github.com/codespaces/badge.svg" /></a>
|
|
4
|
-
</div>
|
|
5
|
-
<br>
|
|
6
|
-
|
|
7
|
-
> **Remember to shutdown a GitHub Codespace when it is not in use!**
|
|
8
|
-
|
|
9
|
-
# Dev Containers Quick Start
|
|
10
|
-
|
|
11
|
-
The default location for usage snippets is the `samples` directory.
|
|
12
|
-
|
|
13
|
-
## Running a Usage Sample
|
|
14
|
-
|
|
15
|
-
A sample usage example has been provided in a `root.ts` file. As you work with the SDK, it's expected that you will modify these samples to fit your needs. To execute this particular snippet, use the command below.
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
ts-node root.ts
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Generating Additional Usage Samples
|
|
22
|
-
|
|
23
|
-
The speakeasy CLI allows you to generate more usage snippets. Here's how:
|
|
24
|
-
|
|
25
|
-
- To generate a sample for a specific operation by providing an operation ID, use:
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
speakeasy generate usage -s .speakeasy/out.openapi.yaml -l typescript -i {INPUT_OPERATION_ID} -o ./samples
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
- To generate samples for an entire namespace (like a tag or group name), use:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
speakeasy generate usage -s .speakeasy/out.openapi.yaml -l typescript -n {INPUT_TAG_NAME} -o ./samples
|
|
35
|
-
```
|
package/examples/README.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# @openrouter/sdk Examples
|
|
2
|
-
|
|
3
|
-
This directory contains example scripts demonstrating how to use the @openrouter/sdk SDK.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- Node.js (v18 or higher)
|
|
8
|
-
- npm
|
|
9
|
-
|
|
10
|
-
## Setup
|
|
11
|
-
|
|
12
|
-
1. Copy `.env.template` to `.env`:
|
|
13
|
-
```bash
|
|
14
|
-
cp .env.template .env
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
2. Edit `.env` and add your actual credentials (API keys, tokens, etc.)
|
|
18
|
-
|
|
19
|
-
## Running the Examples
|
|
20
|
-
|
|
21
|
-
To run an example file from the examples directory:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm run build && npx tsx example.ts
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Creating new examples
|
|
28
|
-
|
|
29
|
-
Duplicate an existing example file, they won't be overwritten by the generation process.
|
|
30
|
-
|
|
31
|
-
|