Open History to see the last commit
1/**
2 * @modelschemas/client — typed fetch client for the modelschemas service.
3 *
4 * Everything under ./generated is produced by @hey-api/openapi-ts from the
5 * service's own openapi.json (bun run generate:client); this file is the
6 * hand-written entry adding pluggable auth and branded model ids.
7 */
8import { createClient, createConfig } from './generated/client'
9
10import type { ClientOptions } from './generated/types.gen'
11
12export {
13 getActivitySchemas,
14 getProviderOpenApi,
15 getSchema,
16 getServiceIndex,
17 getStatus,
18 listAllSchemas,
19 listChanges,
20 listProviders,
21 listProviderSchemas,
22 estimateCost,
23 extractFalPricing,
24 syncProvider,
25 validatePayload,
26} from './generated/index'
27export type * from './generated/index'
28export { createClient, createConfig }
29export {
30 asListedModelId,
31 getModel,
32 listModels,
33 listProviderModels,
34 type ListedModel,
35 type ListedModelId,
36} from './listed-model.ts'
37
38export interface ModelschemasClientOptions {
39 /** Service origin, e.g. https://modelschemas.example.com */
40 baseUrl: string
41 /** API key (POST /v1/agents/register-key) sent as Authorization: Bearer. */
42 apiKey?: string
43 /** Pre-signed agent JWT (agent-auth protocol) — alternative to apiKey. */
44 agentJwt?: string
45 fetch?: typeof globalThis.fetch
46}
47
48/**
49 * Create a configured client instance to pass to any SDK call via the
50 * `client` option:
51 *
52 * ```ts
53 * const client = createModelschemasClient({ baseUrl, apiKey })
54 * const { data } = await listProviders({ client })
55 * ```
56 */
57export function createModelschemasClient(options: ModelschemasClientOptions) {
58 const credential = options.apiKey ?? options.agentJwt
59 return createClient(
60 createConfig<ClientOptions>({
61 baseUrl: options.baseUrl,
62 fetch: options.fetch,
63 headers: credential
64 ? { Authorization: `Bearer ${credential}` }
65 : undefined,
66 }),
67 )
68}