Skip to content

Commit 360da34

Browse files
committed
setup npm
1 parent c7024ab commit 360da34

File tree

212 files changed

+377
-344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+377
-344
lines changed

.devcontainer/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mkdir samples
1010
npm install --ignore-scripts
1111
npm install -g ts-node --ignore-scripts
1212
npm link
13-
npm link openrouter
13+
npm link @openrouter/sdk
1414
TS_CONFIG_CONTENT=$(cat <<EOL
1515
{
1616
"compilerOptions": {

.github/workflows/sdk_generation.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ jobs:
3030
set_version: ${{ github.event.inputs.set_version }}
3131
secrets:
3232
github_access_token: ${{ secrets.GITHUB_TOKEN }}
33+
npm_token: ${{ secrets.NPM_TOKEN }}
3334
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}

.github/workflows/sdk_publish.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish
2+
permissions:
3+
checks: write
4+
contents: write
5+
pull-requests: write
6+
statuses: write
7+
id-token: write
8+
"on":
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- .speakeasy/gen.lock
14+
workflow_dispatch: {}
15+
jobs:
16+
publish:
17+
uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-publish.yaml@v15
18+
with:
19+
target: openrouter
20+
secrets:
21+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
22+
npm_token: ${{ secrets.NPM_TOKEN }}
23+
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}

.speakeasy/gen.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ management:
66
speakeasyVersion: 1.622.2
77
generationVersion: 2.711.4
88
releaseVersion: 0.0.0-beta.0
9-
configChecksum: 1f820324330044d6a48b831014bfba57
9+
configChecksum: ad5304d3b5e52b274ee22f4454e04f08
10+
published: true
1011
features:
1112
typescript:
1213
acceptHeaders: 2.81.2

.speakeasy/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ typescript:
6161
modelPropertyCasing: camel
6262
moduleFormat: dual
6363
outputModelSuffix: output
64-
packageName: openrouter
64+
packageName: '@openrouter/sdk'
6565
responseFormat: flat
6666
sseFlatResponse: false
6767
templateVersion: v2

.speakeasy/workflow.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ targets:
1414
sourceRevisionDigest: sha256:33ae487def452ee14ec8255ee26d55b3ad26e168d2294efe2992bb32259feb2e
1515
sourceBlobDigest: sha256:1f36153e04b279d7f1d297bbb9ce7cf750dd8790aa012d7c3291a16ee59c39a6
1616
codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples
17-
codeSamplesRevisionDigest: sha256:13206bdd3eff8a3c19782d61891937b1f9d2c481a99e7cd489df4c3850b7383f
17+
codeSamplesRevisionDigest: sha256:b321b255d705f018afadbd16e374a90e6e653be398e55f3221ac0f6cd811d4a6
1818
workflow:
1919
workflowVersion: 1.0.0
2020
speakeasyVersion: latest
@@ -29,6 +29,9 @@ workflow:
2929
openrouter:
3030
target: typescript
3131
source: OpenRouter API
32+
publish:
33+
npm:
34+
token: $npm_token
3235
codeSamples:
3336
registry:
3437
location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api-typescript-code-samples

.speakeasy/workflow.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ targets:
1111
openrouter:
1212
target: typescript
1313
source: OpenRouter API
14+
publish:
15+
npm:
16+
token: $npm_token
1417
codeSamples:
1518
registry:
1619
location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api-typescript-code-samples

FUNCTIONS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ specific category of applications.
1919
## Example
2020

2121
```typescript
22-
import { OpenRouterCore } from "openrouter/core.js";
23-
import { getCredits } from "openrouter/funcs/getCredits.js";
22+
import { OpenRouterCore } from "@openrouter/sdk/core.js";
23+
import { getCredits } from "@openrouter/sdk/funcs/getCredits.js";
2424

2525
// Use `OpenRouterCore` for best tree-shaking performance.
2626
// You can create one instance of it to use across an application.

REACT_QUERY.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ your React app at the root or layout component. For example:
1818

1919
```tsx
2020
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
21-
import { OpenRouterCore } from "openrouter";
22-
import { OpenRouterProvider } from "openrouter/react-query";
21+
import { OpenRouterCore } from "@openrouter/sdk";
22+
import { OpenRouterProvider } from "@openrouter/sdk/react-query";
2323

2424
const queryClient = new QueryClient();
2525
const openRouter = new OpenRouterCore({
@@ -29,8 +29,8 @@ const openRouter = new OpenRouterCore({
2929
});
3030

3131
// Retries are handled by the underlying SDK.
32-
queryClient.setQueryDefaults(["openrouter"], { retry: false });
33-
queryClient.setMutationDefaults(["openrouter"], { retry: false });
32+
queryClient.setQueryDefaults(["@openrouter/sdk"], { retry: false });
33+
queryClient.setMutationDefaults(["@openrouter/sdk"], { retry: false });
3434

3535
export function App() {
3636
return (
@@ -52,7 +52,7 @@ from TanStack Query.
5252
[use-query]: https://tanstack.com/query/v5/docs/framework/react/reference/useQuery
5353

5454
```tsx
55-
import { useGetCredits } from "openrouter/react-query/getCredits.js";
55+
import { useGetCredits } from "@openrouter/sdk/react-query/getCredits.js";
5656

5757
export function Example() {
5858
const { data, error, status } = useGetCredits();
@@ -68,7 +68,7 @@ more options provided by the query hooks to control these behaviors.
6868

6969
```tsx
7070
import { useState } from "react";
71-
import { useGetCredits } from "openrouter/react-query/getCredits.js";
71+
import { useGetCredits } from "@openrouter/sdk/react-query/getCredits.js";
7272

7373
export function ExampleWithOptions() {
7474
const [enabled, setEnabled] = useState(true);
@@ -109,7 +109,7 @@ Query.
109109
[use-mutation]: https://tanstack.com/query/v5/docs/framework/react/reference/useMutation
110110

111111
```tsx
112-
import { usePostCreditsCoinbaseMutation } from "openrouter/react-query/postCreditsCoinbase.js";
112+
import { usePostCreditsCoinbaseMutation } from "@openrouter/sdk/react-query/postCreditsCoinbase.js";
113113

114114
export function Example() {
115115
const { mutate, status } = usePostCreditsCoinbaseMutation();
@@ -137,7 +137,7 @@ Since the underlying SDK handles request timeouts and retries, there are a few
137137
more options provided by the mutation hooks to control these behaviors.
138138

139139
```tsx
140-
import { usePostCreditsCoinbaseMutation } from "openrouter/react-query/postCreditsCoinbase.js";
140+
import { usePostCreditsCoinbaseMutation } from "@openrouter/sdk/react-query/postCreditsCoinbase.js";
141141

142142
export function ExampleWithOptions() {
143143
const { mutate, status } = usePostCreditsCoinbaseMutation({
@@ -172,9 +172,9 @@ query hook there are two functions that help invalidate cached data:
172172

173173
```tsx
174174
import { useQueryClient } from "@tanstack/react-query";
175-
import { invalidateGetCredits, invalidateAllGetCredits } from "openrouter/react-query/getCredits.js";
175+
import { invalidateGetCredits, invalidateAllGetCredits } from "@openrouter/sdk/react-query/getCredits.js";
176176
// Replace this with a real mutation
177-
import { useExampleMutation } from "openrouter/react-query/example.js";
177+
import { useExampleMutation } from "@openrouter/sdk/react-query/example.js";
178178

179179
export function Example() {
180180
const { queryClient } = useQueryClient();
@@ -218,9 +218,9 @@ hooks that integrate neatly with React Suspense.
218218
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
219219
import { ErrorBoundary } from "react-error-boundary";
220220

221-
import { OpenRouterCore } from "openrouter";
222-
import { OpenRouterProvider } from "openrouter/react-query";
223-
import { useGetCreditsSuspense } from "openrouter/react-query/getCredits.js";
221+
import { OpenRouterCore } from "@openrouter/sdk";
222+
import { OpenRouterProvider } from "@openrouter/sdk/react-query";
223+
import { useGetCreditsSuspense } from "@openrouter/sdk/react-query/getCredits.js";
224224

225225
const queryClient = new QueryClient();
226226
const openRouter = new OpenRouterCore({
@@ -276,8 +276,8 @@ import {
276276
HydrationBoundary,
277277
QueryClient,
278278
} from "@tanstack/react-query";
279-
import { OpenRouterCore } from "openrouter";
280-
import { prefetchGetCredits } from "openrouter/react-query/getCredits.js";
279+
import { OpenRouterCore } from "@openrouter/sdk";
280+
import { prefetchGetCredits } from "@openrouter/sdk/react-query/getCredits.js";
281281

282282
export default async function Page() {
283283
const queryClient = new QueryClient();

README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,36 @@ For more information about the API: [OpenRouter Documentation](https://openroute
4545
<!-- Start SDK Installation [installation] -->
4646
## SDK Installation
4747

48-
> [!TIP]
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).
50-
51-
5248
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.
5349

5450
### NPM
5551

5652
```bash
57-
npm add <UNSET>
53+
npm add @openrouter/sdk
5854
# Install optional peer dependencies if you plan to use React hooks
5955
npm add @tanstack/react-query react react-dom
6056
```
6157

6258
### PNPM
6359

6460
```bash
65-
pnpm add <UNSET>
61+
pnpm add @openrouter/sdk
6662
# Install optional peer dependencies if you plan to use React hooks
6763
pnpm add @tanstack/react-query react react-dom
6864
```
6965

7066
### Bun
7167

7268
```bash
73-
bun add <UNSET>
69+
bun add @openrouter/sdk
7470
# Install optional peer dependencies if you plan to use React hooks
7571
bun add @tanstack/react-query react react-dom
7672
```
7773

7874
### Yarn
7975

8076
```bash
81-
yarn add <UNSET>
77+
yarn add @openrouter/sdk
8278
# Install optional peer dependencies if you plan to use React hooks
8379
yarn add @tanstack/react-query react react-dom
8480
```
@@ -99,7 +95,7 @@ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
9995
### Example
10096

10197
```typescript
102-
import { OpenRouter } from "openrouter";
98+
import { OpenRouter } from "@openrouter/sdk";
10399

104100
const openRouter = new OpenRouter({
105101
security: {
@@ -132,7 +128,7 @@ This SDK supports the following security schemes globally:
132128

133129
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:
134130
```typescript
135-
import { OpenRouter } from "openrouter";
131+
import { OpenRouter } from "@openrouter/sdk";
136132

137133
const openRouter = new OpenRouter({
138134
security: {
@@ -302,7 +298,7 @@ terminate when the server no longer has any events to send and closes the
302298
underlying connection.
303299

304300
```typescript
305-
import { OpenRouter } from "openrouter";
301+
import { OpenRouter } from "@openrouter/sdk";
306302

307303
const openRouter = new OpenRouter({
308304
security: {
@@ -331,7 +327,7 @@ Some of the endpoints in this SDK support retries. If you use the SDK without a
331327

332328
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
333329
```typescript
334-
import { OpenRouter } from "openrouter";
330+
import { OpenRouter } from "@openrouter/sdk";
335331

336332
const openRouter = new OpenRouter({
337333
security: {
@@ -362,7 +358,7 @@ run();
362358

363359
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
364360
```typescript
365-
import { OpenRouter } from "openrouter";
361+
import { OpenRouter } from "@openrouter/sdk";
366362

367363
const openRouter = new OpenRouter({
368364
retryConfig: {
@@ -407,8 +403,8 @@ run();
407403

408404
### Example
409405
```typescript
410-
import { OpenRouter } from "openrouter";
411-
import * as errors from "openrouter/models/errors";
406+
import { OpenRouter } from "@openrouter/sdk";
407+
import * as errors from "@openrouter/sdk/models/errors";
412408

413409
const openRouter = new OpenRouter({
414410
security: {
@@ -482,7 +478,7 @@ You can pass a logger that matches `console`'s interface as an SDK option.
482478
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
483479
484480
```typescript
485-
import { OpenRouter } from "openrouter";
481+
import { OpenRouter } from "@openrouter/sdk";
486482

487483
const sdk = new OpenRouter({ debugLogger: console });
488484
```

0 commit comments

Comments
 (0)