@openrouter/sdk 0.1.13 → 0.1.18

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.
Files changed (73) hide show
  1. package/README.md +0 -8
  2. package/esm/lib/config.d.ts +10 -2
  3. package/esm/lib/config.js +2 -2
  4. package/esm/lib/env.d.ts +13 -0
  5. package/esm/lib/env.js +16 -0
  6. package/esm/lib/sdks.js +2 -2
  7. package/esm/models/chatmessagecontentitem.d.ts +5 -0
  8. package/esm/models/chatmessagecontentitem.js +3 -0
  9. package/esm/models/chatmessagecontentitemfile.d.ts +36 -0
  10. package/esm/models/chatmessagecontentitemfile.js +51 -0
  11. package/esm/models/chatmessagecontentitemvideo.d.ts +11 -23
  12. package/esm/models/chatmessagecontentitemvideo.js +11 -24
  13. package/esm/models/index.d.ts +2 -0
  14. package/esm/models/index.js +2 -0
  15. package/esm/models/videourl.d.ts +17 -0
  16. package/esm/models/videourl.js +21 -0
  17. package/jsr.json +1 -1
  18. package/package.json +2 -16
  19. package/REACT_QUERY.md +0 -296
  20. package/esm/react-query/_context.d.ts +0 -8
  21. package/esm/react-query/_context.js +0 -14
  22. package/esm/react-query/_types.d.ts +0 -27
  23. package/esm/react-query/_types.js +0 -5
  24. package/esm/react-query/analyticsGetUserActivity.d.ts +0 -36
  25. package/esm/react-query/analyticsGetUserActivity.js +0 -77
  26. package/esm/react-query/apiKeysCreate.d.ts +0 -20
  27. package/esm/react-query/apiKeysCreate.js +0 -39
  28. package/esm/react-query/apiKeysDelete.d.ts +0 -20
  29. package/esm/react-query/apiKeysDelete.js +0 -39
  30. package/esm/react-query/apiKeysGet.d.ts +0 -24
  31. package/esm/react-query/apiKeysGet.js +0 -66
  32. package/esm/react-query/apiKeysGetCurrentKeyMetadata.d.ts +0 -29
  33. package/esm/react-query/apiKeysGetCurrentKeyMetadata.js +0 -66
  34. package/esm/react-query/apiKeysList.d.ts +0 -37
  35. package/esm/react-query/apiKeysList.js +0 -69
  36. package/esm/react-query/apiKeysUpdate.d.ts +0 -20
  37. package/esm/react-query/apiKeysUpdate.js +0 -39
  38. package/esm/react-query/betaResponsesSend.d.ts +0 -24
  39. package/esm/react-query/betaResponsesSend.js +0 -42
  40. package/esm/react-query/chatSend.d.ts +0 -24
  41. package/esm/react-query/chatSend.js +0 -42
  42. package/esm/react-query/completionsGenerate.d.ts +0 -23
  43. package/esm/react-query/completionsGenerate.js +0 -42
  44. package/esm/react-query/creditsCreateCoinbaseCharge.d.ts +0 -25
  45. package/esm/react-query/creditsCreateCoinbaseCharge.js +0 -42
  46. package/esm/react-query/creditsGetCredits.d.ts +0 -29
  47. package/esm/react-query/creditsGetCredits.js +0 -66
  48. package/esm/react-query/embeddingsGenerate.d.ts +0 -23
  49. package/esm/react-query/embeddingsGenerate.js +0 -42
  50. package/esm/react-query/embeddingsListModels.d.ts +0 -29
  51. package/esm/react-query/embeddingsListModels.js +0 -66
  52. package/esm/react-query/endpointsList.d.ts +0 -24
  53. package/esm/react-query/endpointsList.js +0 -66
  54. package/esm/react-query/endpointsListZdrEndpoints.d.ts +0 -23
  55. package/esm/react-query/endpointsListZdrEndpoints.js +0 -60
  56. package/esm/react-query/generationsGetGeneration.d.ts +0 -30
  57. package/esm/react-query/generationsGetGeneration.js +0 -71
  58. package/esm/react-query/index.d.ts +0 -27
  59. package/esm/react-query/index.js +0 -30
  60. package/esm/react-query/modelsCount.d.ts +0 -23
  61. package/esm/react-query/modelsCount.js +0 -60
  62. package/esm/react-query/modelsList.d.ts +0 -38
  63. package/esm/react-query/modelsList.js +0 -69
  64. package/esm/react-query/modelsListForUser.d.ts +0 -24
  65. package/esm/react-query/modelsListForUser.js +0 -60
  66. package/esm/react-query/oAuthCreateAuthCode.d.ts +0 -23
  67. package/esm/react-query/oAuthCreateAuthCode.js +0 -42
  68. package/esm/react-query/oAuthExchangeAuthCodeForAPIKey.d.ts +0 -23
  69. package/esm/react-query/oAuthExchangeAuthCodeForAPIKey.js +0 -42
  70. package/esm/react-query/parametersGetParameters.d.ts +0 -38
  71. package/esm/react-query/parametersGetParameters.js +0 -80
  72. package/esm/react-query/providersList.d.ts +0 -23
  73. package/esm/react-query/providersList.js +0 -60
package/REACT_QUERY.md DELETED
@@ -1,296 +0,0 @@
1
- # React hooks
2
-
3
- This SDK provides React hooks and utilies for making queries and mutations that
4
- can take the pain out of building front-end applications for the web or React
5
- Native.
6
-
7
- They are built as a thin wrapper around [TanStack Query for React v5][rq], a
8
- powerful, asynchronous state management library. A good understanding of that
9
- library will be very helpful while using them. In addition to hooks, there are
10
- several helper functions that can be used for cache management and data fetching
11
- during server-rendering and in React Server Components.
12
-
13
- ## Getting started
14
-
15
- To get started using React hooks, you will need to inject TanStack query and an
16
- SDK instance into your application. Typically, this will be done high up in
17
- your React app at the root or layout component. For example:
18
-
19
- ```tsx
20
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
21
- import { OpenRouterCore } from "@openrouter/sdk";
22
- import { OpenRouterProvider } from "@openrouter/sdk/react-query";
23
-
24
- const queryClient = new QueryClient();
25
- const openRouter = new OpenRouterCore({
26
- apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
27
- });
28
-
29
- // Retries are handled by the underlying SDK.
30
- queryClient.setQueryDefaults(["@openrouter/sdk"], { retry: false });
31
- queryClient.setMutationDefaults(["@openrouter/sdk"], { retry: false });
32
-
33
- export function App() {
34
- return (
35
- <QueryClientProvider client={queryClient}>
36
- <OpenRouterProvider client={openRouter}>
37
- {/* Your app logic starts here */}
38
- </OpenRouterProvider>
39
- </QueryClientProvider>
40
- );
41
- }
42
- ```
43
-
44
- ## Queries
45
-
46
- Query hooks are the basic building block for fetching data. In addition to
47
- request data, they take the same options as the [`useQuery` hook][use-query]
48
- from TanStack Query.
49
-
50
- [use-query]: https://tanstack.com/query/v5/docs/framework/react/reference/useQuery
51
-
52
- ```tsx
53
- import { useAnalyticsGetUserActivity } from "@openrouter/sdk/react-query/analyticsGetUserActivity.js";
54
-
55
- export function Example() {
56
- const { data, error, status } = useAnalyticsGetUserActivity();
57
-
58
- // Render the UI here...
59
- }
60
- ```
61
-
62
- ### Query timeouts and retries
63
-
64
- Since the underlying SDK handles request timeouts and retries, there are a few
65
- more options provided by the query hooks to control these behaviors.
66
-
67
- ```tsx
68
- import { useState } from "react";
69
- import { useAnalyticsGetUserActivity } from "@openrouter/sdk/react-query/analyticsGetUserActivity.js";
70
-
71
- export function ExampleWithOptions() {
72
- const [enabled, setEnabled] = useState(true);
73
- const { data, error, status } = useAnalyticsGetUserActivity(
74
- {
75
- // TanStack Query options:
76
- enabled,
77
- staleTime: 60 * 1000, // 1 minute
78
- gcTime: 5 * 60 * 1000, // 5 minutes
79
-
80
- // Request options for the underlying API call:
81
- timeoutMs: 1000,
82
- retryCodes: ["5XX"],
83
- retries: {
84
- strategy: "backoff",
85
- backoff: {
86
- initialInterval: 500,
87
- maxInterval: 10 * 1000, // 10 seconds
88
- exponent: 1.5,
89
- maxElapsedTime: 60 * 1000, // 1 minute
90
- },
91
- },
92
- }
93
- );
94
-
95
- // Render the UI here...
96
- }
97
- ```
98
-
99
-
100
- ## Mutations
101
-
102
- Operations that can have side-effects in this SDK are exposed as mutation hooks.
103
- These can be integrated into HTML forms to submit data to the API. They also
104
- take the same options as the [`useMutation` hook][use-mutation] from TanStack
105
- Query.
106
-
107
- [use-mutation]: https://tanstack.com/query/v5/docs/framework/react/reference/useMutation
108
-
109
- ```tsx
110
- import { useBetaResponsesSendMutation } from "@openrouter/sdk/react-query/betaResponsesSend.js";
111
-
112
- export function Example() {
113
- const { mutate, status } = useBetaResponsesSendMutation();
114
-
115
- return (
116
- <form
117
- onSubmit={(e) => {
118
- e.preventDefault();
119
-
120
- // Read form data here...
121
-
122
- mutate({});
123
- }}
124
- >
125
- {/* Form fields go here... */}
126
- <button type="submit" disabled={status === "pending"}>Submit</button>
127
- </form>
128
- );
129
- }
130
- ```
131
-
132
- ### Mutation timeouts and retries
133
-
134
- Since the underlying SDK handles request timeouts and retries, there are a few
135
- more options provided by the mutation hooks to control these behaviors.
136
-
137
- ```tsx
138
- import { useBetaResponsesSendMutation } from "@openrouter/sdk/react-query/betaResponsesSend.js";
139
-
140
- export function ExampleWithOptions() {
141
- const { mutate, status } = useBetaResponsesSendMutation({
142
- // TanStack Query options:
143
- networkMode: "online",
144
- gcTime: 5 * 60 * 1000, // 5 minutes
145
-
146
- // Request options for the underlying API call:
147
- timeoutMs: 1000,
148
- retryCodes: ["5XX"],
149
- retries: {
150
- strategy: "backoff",
151
- backoff: {
152
- initialInterval: 500,
153
- maxInterval: 10 * 1000, // 10 seconds
154
- exponent: 1.5,
155
- maxElapsedTime: 60 * 1000, // 1 minute
156
- },
157
- },
158
- });
159
-
160
- // Render the UI here...
161
- }
162
- ```
163
-
164
-
165
- ## Cache invalidation
166
-
167
- In many instances, triggering a mutation hook requires invalidating specific
168
- query data currently residing in the TanStack Query's cache. Alongside every
169
- query hook there are two functions that help invalidate cached data:
170
-
171
- ```tsx
172
- import { useQueryClient } from "@tanstack/react-query";
173
- import { invalidateAnalyticsGetUserActivity, invalidateAllAnalyticsGetUserActivity } from "@openrouter/sdk/react-query/analyticsGetUserActivity.js";
174
- // Replace this with a real mutation
175
- import { useExampleMutation } from "@openrouter/sdk/react-query/example.js";
176
-
177
- export function Example() {
178
- const { queryClient } = useQueryClient();
179
- const { mutate, status } = useExampleMutation();
180
-
181
- return (
182
- <form
183
- onSubmit={(e) => {
184
- e.preventDefault();
185
-
186
- const formData = new FormData(e.target);
187
-
188
- mutate(formData, {
189
- onSuccess: () => {
190
- // Invalidate a single cache entry:
191
- invalidateAnalyticsGetUserActivity(queryClient, /* ... arguments ... */);
192
- // OR, invalidate all cache entries for the query targets:
193
- invalidateAllAnalyticsGetUserActivity(queryClient);
194
- },
195
- });
196
- }}
197
- >
198
- {/* Form fields go here... */}
199
-
200
- <button type="submit" disabled={status === "pending"}>Submit</button>
201
- </form>
202
- );
203
- }
204
- ```
205
-
206
-
207
- ## Integration with React Suspense
208
-
209
- TanStack Query predates React Suspense and out of the box it does a great job at
210
- exposing the lifecycle of asynchronous tasks. However, if you are already using
211
- Suspense in your app, the default hooks will not trigger suspense boundaries.
212
- This is why the library and, by extension, this SDK also provide equivalent
213
- hooks that integrate neatly with React Suspense.
214
-
215
- ```tsx
216
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
217
- import { ErrorBoundary } from "react-error-boundary";
218
-
219
- import { OpenRouterCore } from "@openrouter/sdk";
220
- import { OpenRouterProvider } from "@openrouter/sdk/react-query";
221
- import { useAnalyticsGetUserActivitySuspense } from "@openrouter/sdk/react-query/analyticsGetUserActivity.js";
222
-
223
- const queryClient = new QueryClient();
224
- const openRouter = new OpenRouterCore({
225
- apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
226
- });
227
-
228
- export function App() {
229
- return (
230
- <QueryClientProvider client={queryClient}>
231
- <OpenRouterProvider client={openRouter}>
232
- <QueryErrorResetBoundary>
233
- {({ reset }) => (
234
- <ErrorBoundary
235
- fallbackRender={({ error, resetErrorBoundary }) => (
236
- <div>
237
- There was an error!{' '}
238
- <Button onClick={() => resetErrorBoundary()}>Try again</Button>
239
- <pre>{error.message}</pre>
240
- </div>
241
- )}
242
- onReset={reset}
243
- >
244
- <React.Suspense fallback={<h1>Loading...</h1>}>
245
- <Example />
246
- </React.Suspense>
247
- </ErrorBoundary>
248
- )}
249
- </QueryErrorResetBoundary>
250
- </OpenRouterProvider>
251
- </QueryClientProvider>
252
- );
253
- }
254
-
255
- function Example() {
256
- const { data } = useAnalyticsGetUserActivitySuspense();
257
-
258
- // Render the UI here...
259
- }
260
- ```
261
-
262
-
263
- ## Server-rendering and React Server Components
264
-
265
- Query hooks are also side-loaded with prefetch helper functions. These functions
266
- can be used to fetch data from the API during server-rendering and in React
267
- Server Components so that it can be available immediately on page load to any
268
- components that use the corresponding hooks:
269
- ```tsx
270
- import {
271
- dehydrate,
272
- HydrationBoundary,
273
- QueryClient,
274
- } from "@tanstack/react-query";
275
- import { OpenRouterCore } from "@openrouter/sdk";
276
- import { prefetchAnalyticsGetUserActivity } from "@openrouter/sdk/react-query/analyticsGetUserActivity.js";
277
-
278
- export default async function Page() {
279
- const queryClient = new QueryClient();
280
- const openRouter = new OpenRouterCore({
281
- apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
282
- });
283
-
284
- await prefetchAnalyticsGetUserActivity(openRouter);
285
-
286
- return (
287
- // HydrationBoundary is a Client Component, so hydration will happen there.
288
- <HydrationBoundary state={dehydrate(queryClient)}>
289
- {/* Client components under this point will also have data on page load. */}
290
- </HydrationBoundary>
291
- );
292
- }
293
- ```
294
-
295
-
296
- [rq]: https://tanstack.com/query/v5/docs/framework/react/overview
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { OpenRouterCore } from "../core.js";
3
- export declare function OpenRouterProvider(props: {
4
- client: OpenRouterCore;
5
- children: React.ReactNode;
6
- }): React.ReactNode;
7
- export declare function useOpenRouterContext(): OpenRouterCore;
8
- //# sourceMappingURL=_context.d.ts.map
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from "react";
3
- const OpenRouterContext = React.createContext(null);
4
- export function OpenRouterProvider(props) {
5
- return (_jsx(OpenRouterContext.Provider, { value: props.client, children: props.children }));
6
- }
7
- export function useOpenRouterContext() {
8
- const value = React.useContext(OpenRouterContext);
9
- if (value === null) {
10
- throw new Error("SDK not initialized. Create an instance of OpenRouterCore and pass it to <OpenRouterProvider />.");
11
- }
12
- return value;
13
- }
14
- //# sourceMappingURL=_context.js.map
@@ -1,27 +0,0 @@
1
- import { RequestOptions } from "../lib/sdks.js";
2
- import { PageIterator } from "../types/operations.js";
3
- import type { DefaultError, InfiniteData, InfiniteQueryPageParamsOptions, OmitKeyof, QueryKey, QueryObserverOptions, SkipToken, UseMutationOptions, UseQueryOptions, UseSuspenseQueryOptions } from "@tanstack/react-query";
4
- interface UseInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, "suspense"> {
5
- /**
6
- * Set this to `false` to unsubscribe this observer from updates to the query cache.
7
- * Defaults to `true`.
8
- */
9
- subscribed?: boolean;
10
- }
11
- interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserverOptions<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey, TPageParam>, InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {
12
- }
13
- interface UseSuspenseInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, "queryFn" | "enabled" | "throwOnError" | "placeholderData"> {
14
- queryFn?: Exclude<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>["queryFn"], SkipToken>;
15
- }
16
- export type TupleToPrefixes<T extends any[]> = T extends [...infer Prefix, any] ? TupleToPrefixes<Prefix> | T : never;
17
- export type QueryHookOptions<Data> = Omit<UseQueryOptions<Data, Error>, "queryKey" | "queryFn" | "select" | keyof RequestOptions> & RequestOptions;
18
- export type SuspenseQueryHookOptions<Data> = Omit<UseSuspenseQueryOptions<Data, Error>, "queryKey" | "queryFn" | "select" | keyof RequestOptions> & RequestOptions;
19
- export type InfiniteQueryHookOptions<Data extends PageIterator<unknown, unknown>> = Omit<UseInfiniteQueryOptions<Data, Error, InfiniteData<Data, Data["~next"]>, QueryKey, Data["~next"]>, "queryKey" | "queryFn" | "select" | "getNextPageParam" | "getPreviousPageParam" | "initialPageParam" | keyof RequestOptions> & RequestOptions & {
20
- initialPageParam?: Data["~next"];
21
- };
22
- export type SuspenseInfiniteQueryHookOptions<Data extends PageIterator<unknown, unknown>> = Omit<UseSuspenseInfiniteQueryOptions<Data, Error, InfiniteData<Data, Data["~next"]>, QueryKey, Data["~next"]>, "queryKey" | "queryFn" | "select" | "getNextPageParam" | "getPreviousPageParam" | "initialPageParam" | keyof RequestOptions> & RequestOptions & {
23
- initialPageParam?: Data["~next"];
24
- };
25
- export type MutationHookOptions<Data = unknown, Err = Error, Variables = unknown> = Omit<UseMutationOptions<Data, Err, Variables>, "mutationKey" | "mutationFn" | keyof RequestOptions> & RequestOptions;
26
- export {};
27
- //# sourceMappingURL=_types.d.ts.map
@@ -1,5 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- export {};
5
- //# sourceMappingURL=_types.js.map
@@ -1,36 +0,0 @@
1
- import { InvalidateQueryFilters, QueryClient, QueryFunctionContext, QueryKey, UseQueryResult, UseSuspenseQueryResult } from "@tanstack/react-query";
2
- import { OpenRouterCore } from "../core.js";
3
- import { RequestOptions } from "../lib/sdks.js";
4
- import * as operations from "../models/operations/index.js";
5
- import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes } from "./_types.js";
6
- export type AnalyticsGetUserActivityQueryData = operations.GetUserActivityResponse;
7
- /**
8
- * Get user activity grouped by endpoint
9
- *
10
- * @remarks
11
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days
12
- */
13
- export declare function useAnalyticsGetUserActivity(request?: operations.GetUserActivityRequest | undefined, options?: QueryHookOptions<AnalyticsGetUserActivityQueryData>): UseQueryResult<AnalyticsGetUserActivityQueryData, Error>;
14
- /**
15
- * Get user activity grouped by endpoint
16
- *
17
- * @remarks
18
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days
19
- */
20
- export declare function useAnalyticsGetUserActivitySuspense(request?: operations.GetUserActivityRequest | undefined, options?: SuspenseQueryHookOptions<AnalyticsGetUserActivityQueryData>): UseSuspenseQueryResult<AnalyticsGetUserActivityQueryData, Error>;
21
- export declare function prefetchAnalyticsGetUserActivity(queryClient: QueryClient, client$: OpenRouterCore, request?: operations.GetUserActivityRequest | undefined): Promise<void>;
22
- export declare function setAnalyticsGetUserActivityData(client: QueryClient, queryKeyBase: [parameters: {
23
- date?: string | undefined;
24
- }], data: AnalyticsGetUserActivityQueryData): AnalyticsGetUserActivityQueryData | undefined;
25
- export declare function invalidateAnalyticsGetUserActivity(client: QueryClient, queryKeyBase: TupleToPrefixes<[parameters: {
26
- date?: string | undefined;
27
- }]>, filters?: Omit<InvalidateQueryFilters, "queryKey" | "predicate" | "exact">): Promise<void>;
28
- export declare function invalidateAllAnalyticsGetUserActivity(client: QueryClient, filters?: Omit<InvalidateQueryFilters, "queryKey" | "predicate" | "exact">): Promise<void>;
29
- export declare function buildAnalyticsGetUserActivityQuery(client$: OpenRouterCore, request?: operations.GetUserActivityRequest | undefined, options?: RequestOptions): {
30
- queryKey: QueryKey;
31
- queryFn: (context: QueryFunctionContext) => Promise<AnalyticsGetUserActivityQueryData>;
32
- };
33
- export declare function queryKeyAnalyticsGetUserActivity(parameters: {
34
- date?: string | undefined;
35
- }): QueryKey;
36
- //# sourceMappingURL=analyticsGetUserActivity.d.ts.map
@@ -1,77 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- import { useQuery, useSuspenseQuery, } from "@tanstack/react-query";
5
- import { analyticsGetUserActivity } from "../funcs/analyticsGetUserActivity.js";
6
- import { combineSignals } from "../lib/primitives.js";
7
- import { unwrapAsync } from "../types/fp.js";
8
- import { useOpenRouterContext } from "./_context.js";
9
- /**
10
- * Get user activity grouped by endpoint
11
- *
12
- * @remarks
13
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days
14
- */
15
- export function useAnalyticsGetUserActivity(request, options) {
16
- const client = useOpenRouterContext();
17
- return useQuery({
18
- ...buildAnalyticsGetUserActivityQuery(client, request, options),
19
- ...options,
20
- });
21
- }
22
- /**
23
- * Get user activity grouped by endpoint
24
- *
25
- * @remarks
26
- * Returns user activity data grouped by endpoint for the last 30 (completed) UTC days
27
- */
28
- export function useAnalyticsGetUserActivitySuspense(request, options) {
29
- const client = useOpenRouterContext();
30
- return useSuspenseQuery({
31
- ...buildAnalyticsGetUserActivityQuery(client, request, options),
32
- ...options,
33
- });
34
- }
35
- export function prefetchAnalyticsGetUserActivity(queryClient, client$, request) {
36
- return queryClient.prefetchQuery({
37
- ...buildAnalyticsGetUserActivityQuery(client$, request),
38
- });
39
- }
40
- export function setAnalyticsGetUserActivityData(client, queryKeyBase, data) {
41
- const key = queryKeyAnalyticsGetUserActivity(...queryKeyBase);
42
- return client.setQueryData(key, data);
43
- }
44
- export function invalidateAnalyticsGetUserActivity(client, queryKeyBase, filters) {
45
- return client.invalidateQueries({
46
- ...filters,
47
- queryKey: [
48
- "@openrouter/sdk",
49
- "Analytics",
50
- "getUserActivity",
51
- ...queryKeyBase,
52
- ],
53
- });
54
- }
55
- export function invalidateAllAnalyticsGetUserActivity(client, filters) {
56
- return client.invalidateQueries({
57
- ...filters,
58
- queryKey: ["@openrouter/sdk", "Analytics", "getUserActivity"],
59
- });
60
- }
61
- export function buildAnalyticsGetUserActivityQuery(client$, request, options) {
62
- return {
63
- queryKey: queryKeyAnalyticsGetUserActivity({ date: request?.date }),
64
- queryFn: async function analyticsGetUserActivityQueryFn(ctx) {
65
- const sig = combineSignals(ctx.signal, options?.fetchOptions?.signal);
66
- const mergedOptions = {
67
- ...options,
68
- fetchOptions: { ...options?.fetchOptions, signal: sig },
69
- };
70
- return unwrapAsync(analyticsGetUserActivity(client$, request, mergedOptions));
71
- },
72
- };
73
- }
74
- export function queryKeyAnalyticsGetUserActivity(parameters) {
75
- return ["@openrouter/sdk", "Analytics", "getUserActivity", parameters];
76
- }
77
- //# sourceMappingURL=analyticsGetUserActivity.js.map
@@ -1,20 +0,0 @@
1
- import { MutationKey, UseMutationResult } from "@tanstack/react-query";
2
- import { OpenRouterCore } from "../core.js";
3
- import { RequestOptions } from "../lib/sdks.js";
4
- import * as operations from "../models/operations/index.js";
5
- import { MutationHookOptions } from "./_types.js";
6
- export type ApiKeysCreateMutationVariables = {
7
- request: operations.CreateKeysRequest;
8
- options?: RequestOptions;
9
- };
10
- export type ApiKeysCreateMutationData = operations.CreateKeysResponse;
11
- /**
12
- * Create a new API key
13
- */
14
- export declare function useApiKeysCreateMutation(options?: MutationHookOptions<ApiKeysCreateMutationData, Error, ApiKeysCreateMutationVariables>): UseMutationResult<ApiKeysCreateMutationData, Error, ApiKeysCreateMutationVariables>;
15
- export declare function mutationKeyApiKeysCreate(): MutationKey;
16
- export declare function buildApiKeysCreateMutation(client$: OpenRouterCore, hookOptions?: RequestOptions): {
17
- mutationKey: MutationKey;
18
- mutationFn: (variables: ApiKeysCreateMutationVariables) => Promise<ApiKeysCreateMutationData>;
19
- };
20
- //# sourceMappingURL=apiKeysCreate.d.ts.map
@@ -1,39 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- import { useMutation, } from "@tanstack/react-query";
5
- import { apiKeysCreate } from "../funcs/apiKeysCreate.js";
6
- import { combineSignals } from "../lib/primitives.js";
7
- import { unwrapAsync } from "../types/fp.js";
8
- import { useOpenRouterContext } from "./_context.js";
9
- /**
10
- * Create a new API key
11
- */
12
- export function useApiKeysCreateMutation(options) {
13
- const client = useOpenRouterContext();
14
- return useMutation({
15
- ...buildApiKeysCreateMutation(client, options),
16
- ...options,
17
- });
18
- }
19
- export function mutationKeyApiKeysCreate() {
20
- return ["@openrouter/sdk", "API Keys", "create"];
21
- }
22
- export function buildApiKeysCreateMutation(client$, hookOptions) {
23
- return {
24
- mutationKey: mutationKeyApiKeysCreate(),
25
- mutationFn: function apiKeysCreateMutationFn({ request, options, }) {
26
- const mergedOptions = {
27
- ...hookOptions,
28
- ...options,
29
- fetchOptions: {
30
- ...hookOptions?.fetchOptions,
31
- ...options?.fetchOptions,
32
- signal: combineSignals(hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal),
33
- },
34
- };
35
- return unwrapAsync(apiKeysCreate(client$, request, mergedOptions));
36
- },
37
- };
38
- }
39
- //# sourceMappingURL=apiKeysCreate.js.map
@@ -1,20 +0,0 @@
1
- import { MutationKey, UseMutationResult } from "@tanstack/react-query";
2
- import { OpenRouterCore } from "../core.js";
3
- import { RequestOptions } from "../lib/sdks.js";
4
- import * as operations from "../models/operations/index.js";
5
- import { MutationHookOptions } from "./_types.js";
6
- export type ApiKeysDeleteMutationVariables = {
7
- request: operations.DeleteKeysRequest;
8
- options?: RequestOptions;
9
- };
10
- export type ApiKeysDeleteMutationData = operations.DeleteKeysResponse;
11
- /**
12
- * Delete an API key
13
- */
14
- export declare function useApiKeysDeleteMutation(options?: MutationHookOptions<ApiKeysDeleteMutationData, Error, ApiKeysDeleteMutationVariables>): UseMutationResult<ApiKeysDeleteMutationData, Error, ApiKeysDeleteMutationVariables>;
15
- export declare function mutationKeyApiKeysDelete(): MutationKey;
16
- export declare function buildApiKeysDeleteMutation(client$: OpenRouterCore, hookOptions?: RequestOptions): {
17
- mutationKey: MutationKey;
18
- mutationFn: (variables: ApiKeysDeleteMutationVariables) => Promise<ApiKeysDeleteMutationData>;
19
- };
20
- //# sourceMappingURL=apiKeysDelete.d.ts.map
@@ -1,39 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- */
4
- import { useMutation, } from "@tanstack/react-query";
5
- import { apiKeysDelete } from "../funcs/apiKeysDelete.js";
6
- import { combineSignals } from "../lib/primitives.js";
7
- import { unwrapAsync } from "../types/fp.js";
8
- import { useOpenRouterContext } from "./_context.js";
9
- /**
10
- * Delete an API key
11
- */
12
- export function useApiKeysDeleteMutation(options) {
13
- const client = useOpenRouterContext();
14
- return useMutation({
15
- ...buildApiKeysDeleteMutation(client, options),
16
- ...options,
17
- });
18
- }
19
- export function mutationKeyApiKeysDelete() {
20
- return ["@openrouter/sdk", "API Keys", "delete"];
21
- }
22
- export function buildApiKeysDeleteMutation(client$, hookOptions) {
23
- return {
24
- mutationKey: mutationKeyApiKeysDelete(),
25
- mutationFn: function apiKeysDeleteMutationFn({ request, options, }) {
26
- const mergedOptions = {
27
- ...hookOptions,
28
- ...options,
29
- fetchOptions: {
30
- ...hookOptions?.fetchOptions,
31
- ...options?.fetchOptions,
32
- signal: combineSignals(hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal),
33
- },
34
- };
35
- return unwrapAsync(apiKeysDelete(client$, request, mergedOptions));
36
- },
37
- };
38
- }
39
- //# sourceMappingURL=apiKeysDelete.js.map
@@ -1,24 +0,0 @@
1
- import { InvalidateQueryFilters, QueryClient, QueryFunctionContext, QueryKey, UseQueryResult, UseSuspenseQueryResult } from "@tanstack/react-query";
2
- import { OpenRouterCore } from "../core.js";
3
- import { RequestOptions } from "../lib/sdks.js";
4
- import * as operations from "../models/operations/index.js";
5
- import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes } from "./_types.js";
6
- export type ApiKeysGetQueryData = operations.GetKeyResponse;
7
- /**
8
- * Get a single API key
9
- */
10
- export declare function useApiKeysGet(request: operations.GetKeyRequest, options?: QueryHookOptions<ApiKeysGetQueryData>): UseQueryResult<ApiKeysGetQueryData, Error>;
11
- /**
12
- * Get a single API key
13
- */
14
- export declare function useApiKeysGetSuspense(request: operations.GetKeyRequest, options?: SuspenseQueryHookOptions<ApiKeysGetQueryData>): UseSuspenseQueryResult<ApiKeysGetQueryData, Error>;
15
- export declare function prefetchApiKeysGet(queryClient: QueryClient, client$: OpenRouterCore, request: operations.GetKeyRequest): Promise<void>;
16
- export declare function setApiKeysGetData(client: QueryClient, queryKeyBase: [hash: string], data: ApiKeysGetQueryData): ApiKeysGetQueryData | undefined;
17
- export declare function invalidateApiKeysGet(client: QueryClient, queryKeyBase: TupleToPrefixes<[hash: string]>, filters?: Omit<InvalidateQueryFilters, "queryKey" | "predicate" | "exact">): Promise<void>;
18
- export declare function invalidateAllApiKeysGet(client: QueryClient, filters?: Omit<InvalidateQueryFilters, "queryKey" | "predicate" | "exact">): Promise<void>;
19
- export declare function buildApiKeysGetQuery(client$: OpenRouterCore, request: operations.GetKeyRequest, options?: RequestOptions): {
20
- queryKey: QueryKey;
21
- queryFn: (context: QueryFunctionContext) => Promise<ApiKeysGetQueryData>;
22
- };
23
- export declare function queryKeyApiKeysGet(hash: string): QueryKey;
24
- //# sourceMappingURL=apiKeysGet.d.ts.map