Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

sdk.gen.ts

353 lines11.8 KB

1// This file is auto-generated by @hey-api/openapi-ts
2​
3import { client } from './client.gen.js'
4import type {
5 Client,
6 ClientMeta,
7 Options as Options2,
8 RequestResult,
9 TDataShape,
10} from './client/index.js'
11import type {
12 EstimateCostData,
13 EstimateCostErrors,
14 EstimateCostResponses,
15 ExportCatalogData,
16 ExportCatalogErrors,
17 ExportCatalogResponses,
18 ExtractFalPricingData,
19 ExtractFalPricingErrors,
20 ExtractFalPricingResponses,
21 GetActivitySchemasData,
22 GetActivitySchemasErrors,
23 GetActivitySchemasResponses,
24 GetModelData,
25 GetModelErrors,
26 GetModelResponses,
27 GetProviderData,
28 GetProviderErrors,
29 GetProviderOpenApiData,
30 GetProviderOpenApiErrors,
31 GetProviderOpenApiResponses,
32 GetProviderResponses,
33 GetSchemaData,
34 GetSchemaErrors,
35 GetSchemaResponses,
36 GetServiceIndexData,
37 GetServiceIndexResponses,
38 GetStatusData,
39 GetStatusResponses,
40 ListAllSchemasData,
41 ListAllSchemasResponses,
42 ListChangesData,
43 ListChangesResponses,
44 ListModelsData,
45 ListModelsResponses,
46 ListProviderModelsData,
47 ListProviderModelsErrors,
48 ListProviderModelsResponses,
49 ListProviderSchemasData,
50 ListProviderSchemasErrors,
51 ListProviderSchemasResponses,
52 ListProvidersData,
53 ListProvidersResponses,
54 SyncProviderData,
55 SyncProviderErrors,
56 SyncProviderResponses,
57 ValidatePayloadData,
58 ValidatePayloadErrors,
59 ValidatePayloadResponses,
60} from './types.gen.js'
61​
62export type Options<
63 TData extends TDataShape = TDataShape,
64 ThrowOnError extends boolean = boolean,
65 TResponse = unknown,
66> = Options2<TData, ThrowOnError, TResponse> & {
67 /**
68 * You can provide a client instance returned by `createClient()` instead of
69 * individual options. This might be also useful if you want to implement a
70 * custom client.
71 */
72 client?: Client
73 /**
74 * You can pass arbitrary values through the `meta` object. This can be
75 * used to access values that aren't defined as part of the SDK function.
76 */
77 meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta
79​
80/**
81 * Service description and endpoint index
82 */
83export const getServiceIndex = <ThrowOnError extends boolean = false>(
84 options?: Options<GetServiceIndexData, ThrowOnError>,
85): RequestResult<GetServiceIndexResponses, unknown, ThrowOnError> =>
86 (options?.client ?? client).get<
87 GetServiceIndexResponses,
88 unknown,
89 ThrowOnError
90 >({ url: '/v1', ...options })
91​
92/**
93 * Per-provider sync status and row counts
94 */
95export const getStatus = <ThrowOnError extends boolean = false>(
96 options?: Options<GetStatusData, ThrowOnError>,
97): RequestResult<GetStatusResponses, unknown, ThrowOnError> =>
98 (options?.client ?? client).get<GetStatusResponses, unknown, ThrowOnError>({
99 url: '/v1/status',
100 ...options,
101 })
102​
103/**
104 * List monitored providers with sync status
105 */
106export const listProviders = <ThrowOnError extends boolean = false>(
107 options?: Options<ListProvidersData, ThrowOnError>,
108): RequestResult<ListProvidersResponses, unknown, ThrowOnError> =>
109 (options?.client ?? client).get<
110 ListProvidersResponses,
111 unknown,
112 ThrowOnError
113 >({ url: '/v1/providers', ...options })
114​
115/**
116 * One provider: status, counts, live models per activity
117 *
118 * The same row as GET /v1/providers plus activities: live model counts keyed by activity, the values GET /v1/openapi/{provider}?activity= and GET /v1/models?activity= accept.
119 */
120export const getProvider = <ThrowOnError extends boolean = false>(
121 options: Options<GetProviderData, ThrowOnError>,
122): RequestResult<GetProviderResponses, GetProviderErrors, ThrowOnError> =>
123 (options.client ?? client).get<
124 GetProviderResponses,
125 GetProviderErrors,
126 ThrowOnError
127 >({ url: '/v1/providers/{provider}', ...options })
128​
129/**
130 * List models for one provider
131 */
132export const listProviderModels = <ThrowOnError extends boolean = false>(
133 options: Options<ListProviderModelsData, ThrowOnError>,
134): RequestResult<
135 ListProviderModelsResponses,
136 ListProviderModelsErrors,
137 ThrowOnError
138> =>
139 (options.client ?? client).get<
140 ListProviderModelsResponses,
141 ListProviderModelsErrors,
142 ThrowOnError
143 >({ url: '/v1/providers/{provider}/models', ...options })
144​
145/**
146 * Cross-provider model catalog
147 *
148 * The headline "what can I use right now" endpoint. Filterable.
149 */
150export const listModels = <ThrowOnError extends boolean = false>(
151 options?: Options<ListModelsData, ThrowOnError>,
152): RequestResult<ListModelsResponses, unknown, ThrowOnError> =>
153 (options?.client ?? client).get<ListModelsResponses, unknown, ThrowOnError>({
154 url: '/v1/models',
155 ...options,
156 })
157​
158/**
159 * Full metadata for one model
160 */
161export const getModel = <ThrowOnError extends boolean = false>(
162 options: Options<GetModelData, ThrowOnError>,
163): RequestResult<GetModelResponses, GetModelErrors, ThrowOnError> =>
164 (options.client ?? client).get<
165 GetModelResponses,
166 GetModelErrors,
167 ThrowOnError
168 >({ url: '/v1/models/{provider}/{modelId}', ...options })
169​
170/**
171 * System-wide schema index
172 *
173 * Every provider with extracted schemas, each with its activities and endpoint ids — the discovery entry point for all schemas on the system.
174 */
175export const listAllSchemas = <ThrowOnError extends boolean = false>(
176 options?: Options<ListAllSchemasData, ThrowOnError>,
177): RequestResult<ListAllSchemasResponses, unknown, ThrowOnError> =>
178 (options?.client ?? client).get<
179 ListAllSchemasResponses,
180 unknown,
181 ThrowOnError
182 >({ url: '/v1/schemas', ...options })
183​
184/**
185 * Activities and endpoint ids for a provider
186 */
187export const listProviderSchemas = <ThrowOnError extends boolean = false>(
188 options: Options<ListProviderSchemasData, ThrowOnError>,
189): RequestResult<
190 ListProviderSchemasResponses,
191 ListProviderSchemasErrors,
192 ThrowOnError
193> =>
194 (options.client ?? client).get<
195 ListProviderSchemasResponses,
196 ListProviderSchemasErrors,
197 ThrowOnError
198 >({ url: '/v1/schemas/{provider}', ...options })
199​
200/**
201 * Endpoint-id-keyed schema map for one activity
202 */
203export const getActivitySchemas = <ThrowOnError extends boolean = false>(
204 options: Options<GetActivitySchemasData, ThrowOnError>,
205): RequestResult<
206 GetActivitySchemasResponses,
207 GetActivitySchemasErrors,
208 ThrowOnError
209> =>
210 (options.client ?? client).get<
211 GetActivitySchemasResponses,
212 GetActivitySchemasErrors,
213 ThrowOnError
214 >({ url: '/v1/schemas/{provider}/{activity}', ...options })
215​
216/**
217 * One self-contained JSON Schema
218 */
219export const getSchema = <ThrowOnError extends boolean = false>(
220 options: Options<GetSchemaData, ThrowOnError>,
221): RequestResult<GetSchemaResponses, GetSchemaErrors, ThrowOnError> =>
222 (options.client ?? client).get<
223 GetSchemaResponses,
224 GetSchemaErrors,
225 ThrowOnError
226 >({ url: '/v1/schemas/{provider}/{activity}/{endpointId}', ...options })
227​
228/**
229 * Generation-only OpenAPI document for one provider
230 *
231 * Assembled from classified endpoints plus the provider connect profile (servers, auth, required headers). Not a raw upstream-spec mirror. FAL (model-grained, queue) is one document: POST /{endpoint_id} and GET /{endpoint_id}/requests/{request_id}. endpoint_id is the model raw id (x-modelschemas-encode raw: do not percent-encode slashes). With no selector the bodies are untyped; ?activity= narrows the enum and inlines each model's own body schema (x-modelschemas-model), up to 1024 models; ?model= is that one model's paths. Reactor publishes platform HTTP only (POST /tokens, Reactor-API-Key). Model commands stay component schemas tagged x-modelschemas-model and x-modelschemas-transport: realtime, not paths on the API host. A filter that matches no endpoint returns 400 spec_requires_selector; there is no cap on the number of paths in a provider-grained document. An unsynced provider returns 404 no_endpoints. ?model= pins the live model enum on provider-grained specs; it does not drop endpoints.
232 */
233export const getProviderOpenApi = <ThrowOnError extends boolean = false>(
234 options: Options<GetProviderOpenApiData, ThrowOnError>,
235): RequestResult<
236 GetProviderOpenApiResponses,
237 GetProviderOpenApiErrors,
238 ThrowOnError
239> =>
240 (options.client ?? client).get<
241 GetProviderOpenApiResponses,
242 GetProviderOpenApiErrors,
243 ThrowOnError
244 >({ url: '/v1/openapi/{provider}', ...options })
245​
246/**
247 * Validate a payload against a provider endpoint schema
248 */
249export const validatePayload = <ThrowOnError extends boolean = false>(
250 options: Options<ValidatePayloadData, ThrowOnError>,
251): RequestResult<
252 ValidatePayloadResponses,
253 ValidatePayloadErrors,
254 ThrowOnError
255> =>
256 (options.client ?? client).post<
257 ValidatePayloadResponses,
258 ValidatePayloadErrors,
259 ThrowOnError
260 >({
261 url: '/v1/validate',
262 ...options,
263 headers: {
264 'Content-Type': 'application/json',
265 ...options.headers,
266 },
267 })
268​
269/**
270 * Evaluate a stored rate card against request and usage
271 */
272export const estimateCost = <ThrowOnError extends boolean = false>(
273 options: Options<EstimateCostData, ThrowOnError>,
274): RequestResult<EstimateCostResponses, EstimateCostErrors, ThrowOnError> =>
275 (options.client ?? client).post<
276 EstimateCostResponses,
277 EstimateCostErrors,
278 ThrowOnError
279 >({
280 url: '/v1/estimate',
281 ...options,
282 headers: {
283 'Content-Type': 'application/json',
284 ...options.headers,
285 },
286 })
287​
288/**
289 * Changelog feed (cursor-paginated)
290 *
291 * The polling-friendly alternative to webhooks.
292 */
293export const listChanges = <ThrowOnError extends boolean = false>(
294 options?: Options<ListChangesData, ThrowOnError>,
295): RequestResult<ListChangesResponses, unknown, ThrowOnError> =>
296 (options?.client ?? client).get<ListChangesResponses, unknown, ThrowOnError>({
297 url: '/v1/changes',
298 ...options,
299 })
300​
301/**
302 * Manually trigger a provider spec sync (admin only)
303 */
304export const syncProvider = <ThrowOnError extends boolean = false>(
305 options: Options<SyncProviderData, ThrowOnError>,
306): RequestResult<SyncProviderResponses, SyncProviderErrors, ThrowOnError> =>
307 (options.client ?? client).post<
308 SyncProviderResponses,
309 SyncProviderErrors,
310 ThrowOnError
311 >({
312 security: [{ name: 'X-Admin-Key', type: 'apiKey' }],
313 url: '/v1/admin/sync/{provider}',
314 ...options,
315 })
316​
317/**
318 * Manually trigger the FAL llms.txt rate-card extract (admin only). Spec sync stays on POST /v1/admin/sync/fal.
319 */
320export const extractFalPricing = <ThrowOnError extends boolean = false>(
321 options?: Options<ExtractFalPricingData, ThrowOnError>,
322): RequestResult<
323 ExtractFalPricingResponses,
324 ExtractFalPricingErrors,
325 ThrowOnError
326> =>
327 (options?.client ?? client).post<
328 ExtractFalPricingResponses,
329 ExtractFalPricingErrors,
330 ThrowOnError
331 >({
332 security: [{ name: 'X-Admin-Key', type: 'apiKey' }],
333 url: '/v1/admin/extract/fal',
334 ...options,
335 })
336​
337/**
338 * The whole catalog in one streamed response, for the public git mirror (admin only)
339 *
340 * Returns `latestChange` (the newest change id and createdAt, or null), then `models` (live and deprecated, full rate card), `providers`, and `schemas` (each endpoint with its current input and output versions). Object keys are sorted, and fields that change on every poll (`lastSeenAt`, `lastPolledAt`, `lastSyncedAt`, `_links`) are left out; provenance timestamps such as `factSources.*.fetchedAt` are kept and can move without a value changing. The export is not one snapshot: rows read after `latestChange` may already hold newer changes. To catch up from an earlier export, read every page of GET /v1/changes?since=<its latestChange.createdAt> and skip only its latestChange.id (change ids are random, so do not stop at it). A failure part way breaks the stream, so the body is not valid JSON.
341 */
342export const exportCatalog = <ThrowOnError extends boolean = false>(
343 options?: Options<ExportCatalogData, ThrowOnError>,
344): RequestResult<ExportCatalogResponses, ExportCatalogErrors, ThrowOnError> =>
345 (options?.client ?? client).get<
346 ExportCatalogResponses,
347 ExportCatalogErrors,
348 ThrowOnError
349 >({
350 security: [{ name: 'X-Admin-Key', type: 'apiKey' }],
351 url: '/v1/admin/export',
352 ...options,
353 })