@game-infra/ai-schemas 0.3.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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/dist/catalog.d.ts +137 -0
  4. package/dist/catalog.d.ts.map +1 -0
  5. package/dist/catalog.js +209 -0
  6. package/dist/catalog.js.map +1 -0
  7. package/dist/contracts.d.ts +1073 -0
  8. package/dist/contracts.d.ts.map +1 -0
  9. package/dist/contracts.js +243 -0
  10. package/dist/contracts.js.map +1 -0
  11. package/dist/featuredModels.d.ts +95 -0
  12. package/dist/featuredModels.d.ts.map +1 -0
  13. package/dist/featuredModels.js +189 -0
  14. package/dist/featuredModels.js.map +1 -0
  15. package/dist/index.d.ts +35 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +39 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/inference.d.ts +323 -0
  20. package/dist/inference.d.ts.map +1 -0
  21. package/dist/inference.js +162 -0
  22. package/dist/inference.js.map +1 -0
  23. package/dist/preference.d.ts +49 -0
  24. package/dist/preference.d.ts.map +1 -0
  25. package/dist/preference.js +74 -0
  26. package/dist/preference.js.map +1 -0
  27. package/dist/preset.d.ts +422 -0
  28. package/dist/preset.d.ts.map +1 -0
  29. package/dist/preset.js +212 -0
  30. package/dist/preset.js.map +1 -0
  31. package/dist/provider.d.ts +487 -0
  32. package/dist/provider.d.ts.map +1 -0
  33. package/dist/provider.js +224 -0
  34. package/dist/provider.js.map +1 -0
  35. package/dist/schemaRegistry.d.ts +71 -0
  36. package/dist/schemaRegistry.d.ts.map +1 -0
  37. package/dist/schemaRegistry.js +35 -0
  38. package/dist/schemaRegistry.js.map +1 -0
  39. package/dist/service.d.ts +143 -0
  40. package/dist/service.d.ts.map +1 -0
  41. package/dist/service.js +103 -0
  42. package/dist/service.js.map +1 -0
  43. package/dist/subscription.d.ts +275 -0
  44. package/dist/subscription.d.ts.map +1 -0
  45. package/dist/subscription.js +198 -0
  46. package/dist/subscription.js.map +1 -0
  47. package/package.json +50 -0
@@ -0,0 +1,487 @@
1
+ import { type InferOutput } from "valibot";
2
+ /**
3
+ * How ai-service names the ways a model can be reached.
4
+ *
5
+ * The distinction that matters is not the vendor but who pays and how, because
6
+ * that is what routing preference is expressed in: a flat-rate coding-plan
7
+ * subscription is already paid for, a direct API key is metered by the vendor
8
+ * that trained the model, an umbrella gateway resells other vendors' models at
9
+ * a markup, and a local server costs whatever the operator's hardware costs.
10
+ * Preference is declared over these tiers rather than over provider ids, so a
11
+ * deployment that adds a second gateway does not have to restate its policy.
12
+ */
13
+ export declare const PROVIDER_TIERS: readonly ["subscription", "direct", "local", "umbrella"];
14
+ export declare const ProviderTierSchema: import("valibot").PicklistSchema<readonly ["subscription", "direct", "local", "umbrella"], undefined>;
15
+ export type ProviderTier = InferOutput<typeof ProviderTierSchema>;
16
+ /**
17
+ * The default order tiers are tried in.
18
+ *
19
+ * Subscription first because its quota is already bought and spending metered
20
+ * tokens beside it is waste; then the model's own vendor, which is the cheapest
21
+ * metered route and the one whose behaviour the model was documented against;
22
+ * then a local server, which costs nothing per token but is only as available
23
+ * as the machine it runs on; and finally an umbrella gateway, which can serve
24
+ * almost anything but at a resale price.
25
+ *
26
+ * A preset reorders this list. It never filters: a tier left out of a preset's
27
+ * preference is appended in this order rather than dropped, so a preference
28
+ * written before a tier existed cannot silently make that tier unreachable.
29
+ */
30
+ export declare const DEFAULT_TIER_PREFERENCE: readonly ProviderTier[];
31
+ /**
32
+ * How a provider is authenticated, which decides what the credential routes
33
+ * expect and whether a call needs a manual unlock.
34
+ *
35
+ * - `api-key` — one key held by the deployment, sealed under `ENCRYPTION_KEY`
36
+ * and usable by any call this service serves.
37
+ * - `subscription` — a personal coding-plan credential (Claude Code, Codex, and
38
+ * the Anthropic-compatible plans) that its owner sealed under a password only
39
+ * they know. It is unusable until a request carries that password.
40
+ * - `none` — nothing to store. Either an endpoint that takes no credential at
41
+ * all, which is the normal shape of an Ollama or vLLM server on a trusted
42
+ * network, or one reached through a Worker binding, where the platform
43
+ * authorises the call and there is no key for this service to hold.
44
+ */
45
+ export declare const CREDENTIAL_KINDS: readonly ["api-key", "subscription", "none"];
46
+ export declare const CredentialKindSchema: import("valibot").PicklistSchema<readonly ["api-key", "subscription", "none"], undefined>;
47
+ export type CredentialKind = InferOutput<typeof CredentialKindSchema>;
48
+ /**
49
+ * The wire dialect a provider speaks, which is what decides the SDK client
50
+ * ai-service builds for it.
51
+ *
52
+ * Nearly everything is `openai-compatible`: the OpenAI `/chat/completions`
53
+ * shape is what the gateways, the local runners and most direct vendors expose,
54
+ * so one client covers them. `openai` and `anthropic` are the two first-party
55
+ * dialects worth using natively, because their own SDKs carry the structured
56
+ * output and prompt-caching features the compatible shape flattens away.
57
+ *
58
+ * `workers-ai` is the one that is not HTTP at all. It reaches Cloudflare's
59
+ * hosted models through the Worker's own `AI` binding, so the call never leaves
60
+ * the runtime: no account id in a URL, no API token to seal, rotate or leak,
61
+ * and no egress hop. That is why it is a dialect rather than a base URL — what
62
+ * differs is the transport, not the wire format — and why a provider on it
63
+ * needs neither `baseUrl` nor a credential.
64
+ */
65
+ export declare const PROVIDER_DIALECTS: readonly ["openai", "anthropic", "openai-compatible", "workers-ai"];
66
+ export declare const ProviderDialectSchema: import("valibot").PicklistSchema<readonly ["openai", "anthropic", "openai-compatible", "workers-ai"], undefined>;
67
+ export type ProviderDialect = InferOutput<typeof ProviderDialectSchema>;
68
+ /** Lowercase, dash-separated identifier a provider is referred to by. */
69
+ export declare const ProviderIdSchema: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 64, undefined>, import("valibot").RegexAction<string, "must be lowercase words separated by single dashes">]>;
70
+ /**
71
+ * One model this provider serves, and the id it serves it under.
72
+ *
73
+ * The pair is the whole point. A caller asks for a canonical model
74
+ * (`claude-sonnet-4-5`); OpenRouter serves that same model as
75
+ * `anthropic/claude-sonnet-4.5` and a self-hosted vLLM serves it under whatever
76
+ * the operator named the weights. Nothing can derive one from the other, so the
77
+ * mapping is configuration rather than a guess, and a canonical id no
78
+ * configured provider maps is simply a model this deployment cannot route.
79
+ */
80
+ export declare const ProviderModelRouteSchema: import("valibot").ObjectSchema<{
81
+ /** Canonical model id, the name a caller asks for. */
82
+ readonly model: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 160, undefined>]>;
83
+ /** The id this provider serves that model under. */
84
+ readonly providerModelId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>;
85
+ /**
86
+ * Cost per million input tokens, in whatever currency the operator is
87
+ * budgeting in. Advisory: shown beside a route so the person ordering the
88
+ * preference can see what the fallback costs, never used to reorder anything
89
+ * on its own.
90
+ */
91
+ readonly inputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
92
+ /** Cost per million output tokens, on the same terms. */
93
+ readonly outputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
94
+ /**
95
+ * Whether this route accepts image parts. Absent means nobody has said, which
96
+ * is not the same as "no": a request carrying images skips a route declared
97
+ * `false` and reports `model_no_image_input`, and skips an undeclared one
98
+ * reporting `unknown_model_image_input`, which is the difference between
99
+ * "this cannot work" and "declare it and it will".
100
+ */
101
+ readonly acceptsImages: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
102
+ /**
103
+ * Whether this route supports provider-native structured output. Absent means
104
+ * undeclared and is treated as capable, because every dialect ai-service
105
+ * speaks has a structured-output path; set it to `false` for a local server
106
+ * whose runtime does not implement one, so `/generate/object` routes past it
107
+ * instead of failing on it.
108
+ */
109
+ readonly supportsStructuredOutput: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
110
+ }, undefined>;
111
+ export type ProviderModelRoute = InferOutput<typeof ProviderModelRouteSchema>;
112
+ /**
113
+ * A configured way to reach models.
114
+ *
115
+ * The record never carries the credential itself. `credentialConfigured` and
116
+ * `credentialHint` are what the console renders, and they are all the API will
117
+ * ever say about a stored key: the ciphertext is opened in memory at call time
118
+ * and nothing reads it back out over HTTP.
119
+ */
120
+ export declare const ProviderSchema: import("valibot").ObjectSchema<{
121
+ readonly id: import("valibot").StringSchema<undefined>;
122
+ /** Stable key used in preset preferences and in a request's `provider` pin. */
123
+ readonly providerId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 64, undefined>, import("valibot").RegexAction<string, "must be lowercase words separated by single dashes">]>;
124
+ /** Display name shown in the console. */
125
+ readonly name: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>]>;
126
+ readonly tier: import("valibot").PicklistSchema<readonly ["subscription", "direct", "local", "umbrella"], undefined>;
127
+ readonly dialect: import("valibot").PicklistSchema<readonly ["openai", "anthropic", "openai-compatible", "workers-ai"], undefined>;
128
+ readonly credentialKind: import("valibot").PicklistSchema<readonly ["api-key", "subscription", "none"], undefined>;
129
+ /**
130
+ * Where this provider lives. Required for `openai-compatible`, which has no
131
+ * default host to fall back on; optional for the two first-party dialects,
132
+ * whose SDKs carry their own and which accept an override so a deployment can
133
+ * point them at a compatible endpoint; ignored for `workers-ai`, which is not
134
+ * reached over HTTP and has no URL to point anywhere.
135
+ */
136
+ readonly baseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, undefined>, import("valibot").MaxLengthAction<string, 400, undefined>]>, undefined>;
137
+ /**
138
+ * Whether routing may pick this provider. A disabled provider keeps its
139
+ * credential and its routes, so taking a gateway out of rotation during an
140
+ * outage is one toggle and putting it back does not mean re-entering a key.
141
+ */
142
+ readonly enabled: import("valibot").BooleanSchema<undefined>;
143
+ /** The canonical models this provider serves, and their ids here. */
144
+ readonly models: import("valibot").ArraySchema<import("valibot").ObjectSchema<{
145
+ /** Canonical model id, the name a caller asks for. */
146
+ readonly model: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 160, undefined>]>;
147
+ /** The id this provider serves that model under. */
148
+ readonly providerModelId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>;
149
+ /**
150
+ * Cost per million input tokens, in whatever currency the operator is
151
+ * budgeting in. Advisory: shown beside a route so the person ordering the
152
+ * preference can see what the fallback costs, never used to reorder anything
153
+ * on its own.
154
+ */
155
+ readonly inputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
156
+ /** Cost per million output tokens, on the same terms. */
157
+ readonly outputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
158
+ /**
159
+ * Whether this route accepts image parts. Absent means nobody has said, which
160
+ * is not the same as "no": a request carrying images skips a route declared
161
+ * `false` and reports `model_no_image_input`, and skips an undeclared one
162
+ * reporting `unknown_model_image_input`, which is the difference between
163
+ * "this cannot work" and "declare it and it will".
164
+ */
165
+ readonly acceptsImages: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
166
+ /**
167
+ * Whether this route supports provider-native structured output. Absent means
168
+ * undeclared and is treated as capable, because every dialect ai-service
169
+ * speaks has a structured-output path; set it to `false` for a local server
170
+ * whose runtime does not implement one, so `/generate/object` routes past it
171
+ * instead of failing on it.
172
+ */
173
+ readonly supportsStructuredOutput: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
174
+ }, undefined>, undefined>;
175
+ /**
176
+ * Extra headers sent with every call. For the gateways that ask for
177
+ * attribution headers (OpenRouter's `HTTP-Referer` / `X-Title`) and for a
178
+ * self-hosted gateway behind a proxy that wants a routing header. Never a
179
+ * place to put a credential: values are stored in the clear.
180
+ */
181
+ readonly headers: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
182
+ readonly name: import("valibot").StringSchema<undefined>;
183
+ readonly value: import("valibot").StringSchema<undefined>;
184
+ }, undefined>, undefined>, undefined>;
185
+ /** Whether a credential is stored for this provider. */
186
+ readonly credentialConfigured: import("valibot").BooleanSchema<undefined>;
187
+ /**
188
+ * The last four characters of the stored key, which is enough to tell two
189
+ * keys apart when someone is deciding whether to rotate one, and not enough
190
+ * to use. Absent for `none` and for a provider with nothing stored yet.
191
+ */
192
+ readonly credentialHint: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
193
+ readonly createdAt: import("valibot").StringSchema<undefined>;
194
+ readonly updatedAt: import("valibot").StringSchema<undefined>;
195
+ }, undefined>;
196
+ export type Provider = InferOutput<typeof ProviderSchema>;
197
+ /** Fields accepted when registering a provider. */
198
+ export declare const CreateProviderRequestSchema: import("valibot").ObjectSchema<{
199
+ readonly providerId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 64, undefined>, import("valibot").RegexAction<string, "must be lowercase words separated by single dashes">]>;
200
+ readonly name: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>]>;
201
+ readonly tier: import("valibot").PicklistSchema<readonly ["subscription", "direct", "local", "umbrella"], undefined>;
202
+ readonly dialect: import("valibot").PicklistSchema<readonly ["openai", "anthropic", "openai-compatible", "workers-ai"], undefined>;
203
+ readonly credentialKind: import("valibot").PicklistSchema<readonly ["api-key", "subscription", "none"], undefined>;
204
+ readonly baseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, undefined>, import("valibot").MaxLengthAction<string, 400, undefined>]>, undefined>;
205
+ readonly enabled: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
206
+ readonly models: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
207
+ /** Canonical model id, the name a caller asks for. */
208
+ readonly model: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 160, undefined>]>;
209
+ /** The id this provider serves that model under. */
210
+ readonly providerModelId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>;
211
+ /**
212
+ * Cost per million input tokens, in whatever currency the operator is
213
+ * budgeting in. Advisory: shown beside a route so the person ordering the
214
+ * preference can see what the fallback costs, never used to reorder anything
215
+ * on its own.
216
+ */
217
+ readonly inputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
218
+ /** Cost per million output tokens, on the same terms. */
219
+ readonly outputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
220
+ /**
221
+ * Whether this route accepts image parts. Absent means nobody has said, which
222
+ * is not the same as "no": a request carrying images skips a route declared
223
+ * `false` and reports `model_no_image_input`, and skips an undeclared one
224
+ * reporting `unknown_model_image_input`, which is the difference between
225
+ * "this cannot work" and "declare it and it will".
226
+ */
227
+ readonly acceptsImages: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
228
+ /**
229
+ * Whether this route supports provider-native structured output. Absent means
230
+ * undeclared and is treated as capable, because every dialect ai-service
231
+ * speaks has a structured-output path; set it to `false` for a local server
232
+ * whose runtime does not implement one, so `/generate/object` routes past it
233
+ * instead of failing on it.
234
+ */
235
+ readonly supportsStructuredOutput: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
236
+ }, undefined>, undefined>, undefined>;
237
+ readonly headers: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
238
+ readonly name: import("valibot").StringSchema<undefined>;
239
+ readonly value: import("valibot").StringSchema<undefined>;
240
+ }, undefined>, undefined>, undefined>;
241
+ /**
242
+ * The API key, supplied at creation so registering a provider is one call.
243
+ * Sealed before it is written and never readable afterwards; replace it
244
+ * through the credential route.
245
+ */
246
+ readonly apiKey: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 4000, undefined>]>, undefined>;
247
+ }, undefined>;
248
+ export type CreateProviderRequest = InferOutput<typeof CreateProviderRequestSchema>;
249
+ /** Fields accepted when updating a provider. Absent means unchanged. */
250
+ export declare const UpdateProviderRequestSchema: import("valibot").ObjectSchema<{
251
+ readonly name: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>]>, undefined>;
252
+ readonly tier: import("valibot").OptionalSchema<import("valibot").PicklistSchema<readonly ["subscription", "direct", "local", "umbrella"], undefined>, undefined>;
253
+ readonly dialect: import("valibot").OptionalSchema<import("valibot").PicklistSchema<readonly ["openai", "anthropic", "openai-compatible", "workers-ai"], undefined>, undefined>;
254
+ readonly baseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, undefined>, import("valibot").MaxLengthAction<string, 400, undefined>]>, undefined>;
255
+ readonly enabled: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
256
+ /** Replaces the whole list. The console edits routes as a table, not row by row. */
257
+ readonly models: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
258
+ /** Canonical model id, the name a caller asks for. */
259
+ readonly model: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 160, undefined>]>;
260
+ /** The id this provider serves that model under. */
261
+ readonly providerModelId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>;
262
+ /**
263
+ * Cost per million input tokens, in whatever currency the operator is
264
+ * budgeting in. Advisory: shown beside a route so the person ordering the
265
+ * preference can see what the fallback costs, never used to reorder anything
266
+ * on its own.
267
+ */
268
+ readonly inputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
269
+ /** Cost per million output tokens, on the same terms. */
270
+ readonly outputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
271
+ /**
272
+ * Whether this route accepts image parts. Absent means nobody has said, which
273
+ * is not the same as "no": a request carrying images skips a route declared
274
+ * `false` and reports `model_no_image_input`, and skips an undeclared one
275
+ * reporting `unknown_model_image_input`, which is the difference between
276
+ * "this cannot work" and "declare it and it will".
277
+ */
278
+ readonly acceptsImages: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
279
+ /**
280
+ * Whether this route supports provider-native structured output. Absent means
281
+ * undeclared and is treated as capable, because every dialect ai-service
282
+ * speaks has a structured-output path; set it to `false` for a local server
283
+ * whose runtime does not implement one, so `/generate/object` routes past it
284
+ * instead of failing on it.
285
+ */
286
+ readonly supportsStructuredOutput: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
287
+ }, undefined>, undefined>, undefined>;
288
+ readonly headers: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
289
+ readonly name: import("valibot").StringSchema<undefined>;
290
+ readonly value: import("valibot").StringSchema<undefined>;
291
+ }, undefined>, undefined>, undefined>;
292
+ }, undefined>;
293
+ export type UpdateProviderRequest = InferOutput<typeof UpdateProviderRequestSchema>;
294
+ /** A key to seal for a provider. */
295
+ export declare const SetProviderCredentialRequestSchema: import("valibot").ObjectSchema<{
296
+ readonly apiKey: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 4000, undefined>]>;
297
+ }, undefined>;
298
+ export type SetProviderCredentialRequest = InferOutput<typeof SetProviderCredentialRequestSchema>;
299
+ /** One provider. */
300
+ export declare const ProviderResponseSchema: import("valibot").ObjectSchema<{
301
+ readonly success: import("valibot").BooleanSchema<undefined>;
302
+ readonly error: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
303
+ } & {
304
+ provider: import("valibot").OptionalSchema<import("valibot").ObjectSchema<{
305
+ readonly id: import("valibot").StringSchema<undefined>;
306
+ /** Stable key used in preset preferences and in a request's `provider` pin. */
307
+ readonly providerId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 64, undefined>, import("valibot").RegexAction<string, "must be lowercase words separated by single dashes">]>;
308
+ /** Display name shown in the console. */
309
+ readonly name: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>]>;
310
+ readonly tier: import("valibot").PicklistSchema<readonly ["subscription", "direct", "local", "umbrella"], undefined>;
311
+ readonly dialect: import("valibot").PicklistSchema<readonly ["openai", "anthropic", "openai-compatible", "workers-ai"], undefined>;
312
+ readonly credentialKind: import("valibot").PicklistSchema<readonly ["api-key", "subscription", "none"], undefined>;
313
+ /**
314
+ * Where this provider lives. Required for `openai-compatible`, which has no
315
+ * default host to fall back on; optional for the two first-party dialects,
316
+ * whose SDKs carry their own and which accept an override so a deployment can
317
+ * point them at a compatible endpoint; ignored for `workers-ai`, which is not
318
+ * reached over HTTP and has no URL to point anywhere.
319
+ */
320
+ readonly baseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, undefined>, import("valibot").MaxLengthAction<string, 400, undefined>]>, undefined>;
321
+ /**
322
+ * Whether routing may pick this provider. A disabled provider keeps its
323
+ * credential and its routes, so taking a gateway out of rotation during an
324
+ * outage is one toggle and putting it back does not mean re-entering a key.
325
+ */
326
+ readonly enabled: import("valibot").BooleanSchema<undefined>;
327
+ /** The canonical models this provider serves, and their ids here. */
328
+ readonly models: import("valibot").ArraySchema<import("valibot").ObjectSchema<{
329
+ /** Canonical model id, the name a caller asks for. */
330
+ readonly model: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 160, undefined>]>;
331
+ /** The id this provider serves that model under. */
332
+ readonly providerModelId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>;
333
+ /**
334
+ * Cost per million input tokens, in whatever currency the operator is
335
+ * budgeting in. Advisory: shown beside a route so the person ordering the
336
+ * preference can see what the fallback costs, never used to reorder anything
337
+ * on its own.
338
+ */
339
+ readonly inputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
340
+ /** Cost per million output tokens, on the same terms. */
341
+ readonly outputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
342
+ /**
343
+ * Whether this route accepts image parts. Absent means nobody has said, which
344
+ * is not the same as "no": a request carrying images skips a route declared
345
+ * `false` and reports `model_no_image_input`, and skips an undeclared one
346
+ * reporting `unknown_model_image_input`, which is the difference between
347
+ * "this cannot work" and "declare it and it will".
348
+ */
349
+ readonly acceptsImages: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
350
+ /**
351
+ * Whether this route supports provider-native structured output. Absent means
352
+ * undeclared and is treated as capable, because every dialect ai-service
353
+ * speaks has a structured-output path; set it to `false` for a local server
354
+ * whose runtime does not implement one, so `/generate/object` routes past it
355
+ * instead of failing on it.
356
+ */
357
+ readonly supportsStructuredOutput: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
358
+ }, undefined>, undefined>;
359
+ /**
360
+ * Extra headers sent with every call. For the gateways that ask for
361
+ * attribution headers (OpenRouter's `HTTP-Referer` / `X-Title`) and for a
362
+ * self-hosted gateway behind a proxy that wants a routing header. Never a
363
+ * place to put a credential: values are stored in the clear.
364
+ */
365
+ readonly headers: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
366
+ readonly name: import("valibot").StringSchema<undefined>;
367
+ readonly value: import("valibot").StringSchema<undefined>;
368
+ }, undefined>, undefined>, undefined>;
369
+ /** Whether a credential is stored for this provider. */
370
+ readonly credentialConfigured: import("valibot").BooleanSchema<undefined>;
371
+ /**
372
+ * The last four characters of the stored key, which is enough to tell two
373
+ * keys apart when someone is deciding whether to rotate one, and not enough
374
+ * to use. Absent for `none` and for a provider with nothing stored yet.
375
+ */
376
+ readonly credentialHint: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
377
+ readonly createdAt: import("valibot").StringSchema<undefined>;
378
+ readonly updatedAt: import("valibot").StringSchema<undefined>;
379
+ }, undefined>, undefined>;
380
+ }, undefined>;
381
+ export type ProviderResponse = InferOutput<typeof ProviderResponseSchema>;
382
+ /** Every configured provider. */
383
+ export declare const ProviderListResponseSchema: import("valibot").ObjectSchema<{
384
+ readonly success: import("valibot").BooleanSchema<undefined>;
385
+ readonly error: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
386
+ } & {
387
+ providers: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
388
+ readonly id: import("valibot").StringSchema<undefined>;
389
+ /** Stable key used in preset preferences and in a request's `provider` pin. */
390
+ readonly providerId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 64, undefined>, import("valibot").RegexAction<string, "must be lowercase words separated by single dashes">]>;
391
+ /** Display name shown in the console. */
392
+ readonly name: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>]>;
393
+ readonly tier: import("valibot").PicklistSchema<readonly ["subscription", "direct", "local", "umbrella"], undefined>;
394
+ readonly dialect: import("valibot").PicklistSchema<readonly ["openai", "anthropic", "openai-compatible", "workers-ai"], undefined>;
395
+ readonly credentialKind: import("valibot").PicklistSchema<readonly ["api-key", "subscription", "none"], undefined>;
396
+ /**
397
+ * Where this provider lives. Required for `openai-compatible`, which has no
398
+ * default host to fall back on; optional for the two first-party dialects,
399
+ * whose SDKs carry their own and which accept an override so a deployment can
400
+ * point them at a compatible endpoint; ignored for `workers-ai`, which is not
401
+ * reached over HTTP and has no URL to point anywhere.
402
+ */
403
+ readonly baseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, undefined>, import("valibot").MaxLengthAction<string, 400, undefined>]>, undefined>;
404
+ /**
405
+ * Whether routing may pick this provider. A disabled provider keeps its
406
+ * credential and its routes, so taking a gateway out of rotation during an
407
+ * outage is one toggle and putting it back does not mean re-entering a key.
408
+ */
409
+ readonly enabled: import("valibot").BooleanSchema<undefined>;
410
+ /** The canonical models this provider serves, and their ids here. */
411
+ readonly models: import("valibot").ArraySchema<import("valibot").ObjectSchema<{
412
+ /** Canonical model id, the name a caller asks for. */
413
+ readonly model: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 160, undefined>]>;
414
+ /** The id this provider serves that model under. */
415
+ readonly providerModelId: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>;
416
+ /**
417
+ * Cost per million input tokens, in whatever currency the operator is
418
+ * budgeting in. Advisory: shown beside a route so the person ordering the
419
+ * preference can see what the fallback costs, never used to reorder anything
420
+ * on its own.
421
+ */
422
+ readonly inputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
423
+ /** Cost per million output tokens, on the same terms. */
424
+ readonly outputCostPerMillion: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
425
+ /**
426
+ * Whether this route accepts image parts. Absent means nobody has said, which
427
+ * is not the same as "no": a request carrying images skips a route declared
428
+ * `false` and reports `model_no_image_input`, and skips an undeclared one
429
+ * reporting `unknown_model_image_input`, which is the difference between
430
+ * "this cannot work" and "declare it and it will".
431
+ */
432
+ readonly acceptsImages: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
433
+ /**
434
+ * Whether this route supports provider-native structured output. Absent means
435
+ * undeclared and is treated as capable, because every dialect ai-service
436
+ * speaks has a structured-output path; set it to `false` for a local server
437
+ * whose runtime does not implement one, so `/generate/object` routes past it
438
+ * instead of failing on it.
439
+ */
440
+ readonly supportsStructuredOutput: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
441
+ }, undefined>, undefined>;
442
+ /**
443
+ * Extra headers sent with every call. For the gateways that ask for
444
+ * attribution headers (OpenRouter's `HTTP-Referer` / `X-Title`) and for a
445
+ * self-hosted gateway behind a proxy that wants a routing header. Never a
446
+ * place to put a credential: values are stored in the clear.
447
+ */
448
+ readonly headers: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").ObjectSchema<{
449
+ readonly name: import("valibot").StringSchema<undefined>;
450
+ readonly value: import("valibot").StringSchema<undefined>;
451
+ }, undefined>, undefined>, undefined>;
452
+ /** Whether a credential is stored for this provider. */
453
+ readonly credentialConfigured: import("valibot").BooleanSchema<undefined>;
454
+ /**
455
+ * The last four characters of the stored key, which is enough to tell two
456
+ * keys apart when someone is deciding whether to rotate one, and not enough
457
+ * to use. Absent for `none` and for a provider with nothing stored yet.
458
+ */
459
+ readonly credentialHint: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
460
+ readonly createdAt: import("valibot").StringSchema<undefined>;
461
+ readonly updatedAt: import("valibot").StringSchema<undefined>;
462
+ }, undefined>, undefined>, undefined>;
463
+ }, undefined>;
464
+ export type ProviderListResponse = InferOutput<typeof ProviderListResponseSchema>;
465
+ /**
466
+ * What a live probe of a provider found.
467
+ *
468
+ * Separate fields rather than one boolean, because "the key is wrong" and "the
469
+ * host did not answer" are fixed in different places, and a caller told only
470
+ * that the provider is unhealthy has to guess which.
471
+ */
472
+ export declare const ProviderProbeResponseSchema: import("valibot").ObjectSchema<{
473
+ readonly success: import("valibot").BooleanSchema<undefined>;
474
+ readonly error: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
475
+ } & {
476
+ providerId: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
477
+ /** Whether the provider answered a real request. */
478
+ reachable: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
479
+ /** The model the probe called, so a failure names something concrete. */
480
+ model: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
481
+ /** Round-trip time of the probe call, in milliseconds. */
482
+ latencyMs: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
483
+ /** Vendor or transport failure, verbatim, when there was one. */
484
+ failure: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
485
+ }, undefined>;
486
+ export type ProviderProbeResponse = InferOutput<typeof ProviderProbeResponseSchema>;
487
+ //# sourceMappingURL=prov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