@earendil-works/pi-ai 1.5.0 → 1.5.1
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.
- package/README.md +23 -4
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +224 -17
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/azure-openai-responses.js +1 -1
- package/dist/api/azure-openai-responses.js.map +1 -1
- package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/dist/api/bedrock-converse-stream.js +4 -2
- package/dist/api/bedrock-converse-stream.js.map +1 -1
- package/dist/api/bedrock-converse-stream.lazy.d.ts +7 -0
- package/dist/api/bedrock-converse-stream.lazy.d.ts.map +1 -1
- package/dist/api/bedrock-converse-stream.lazy.js +18 -5
- package/dist/api/bedrock-converse-stream.lazy.js.map +1 -1
- package/dist/api/constrained-sampling.d.ts +0 -2
- package/dist/api/constrained-sampling.d.ts.map +1 -1
- package/dist/api/constrained-sampling.js +0 -13
- package/dist/api/constrained-sampling.js.map +1 -1
- package/dist/api/lazy.d.ts +1 -1
- package/dist/api/lazy.d.ts.map +1 -1
- package/dist/api/lazy.js +9 -8
- package/dist/api/lazy.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +7 -3
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/openai-completions.d.ts +2 -1
- package/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/api/openai-completions.js +13 -5
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +4 -2
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/api/simple-options.d.ts +1 -0
- package/dist/api/simple-options.d.ts.map +1 -1
- package/dist/api/simple-options.js +16 -2
- package/dist/api/simple-options.js.map +1 -1
- package/dist/api/strict-tool-limits.d.ts +13 -0
- package/dist/api/strict-tool-limits.d.ts.map +1 -0
- package/dist/api/strict-tool-limits.js +50 -0
- package/dist/api/strict-tool-limits.js.map +1 -0
- package/dist/auth/oauth/load.d.ts.map +1 -1
- package/dist/auth/oauth/load.js +5 -2
- package/dist/auth/oauth/load.js.map +1 -1
- package/dist/cache-warming.d.ts +53 -0
- package/dist/cache-warming.d.ts.map +1 -0
- package/dist/cache-warming.js +82 -0
- package/dist/cache-warming.js.map +1 -0
- package/dist/env-api-keys.d.ts.map +1 -1
- package/dist/env-api-keys.js +1 -0
- package/dist/env-api-keys.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lazy-bedrock-provider.d.ts +10 -0
- package/dist/lazy-bedrock-provider.d.ts.map +1 -0
- package/dist/lazy-bedrock-provider.js +13 -0
- package/dist/lazy-bedrock-provider.js.map +1 -0
- package/dist/lazy-oauth.d.ts +10 -0
- package/dist/lazy-oauth.d.ts.map +1 -0
- package/dist/lazy-oauth.js +23 -0
- package/dist/lazy-oauth.js.map +1 -0
- package/dist/models.d.ts +7 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.generated.d.ts +4 -0
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +4 -0
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +19 -11
- package/dist/models.js.map +1 -1
- package/dist/providers/all.d.ts.map +1 -1
- package/dist/providers/all.js +2 -0
- package/dist/providers/all.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +16 -0
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +22 -1
- package/dist/providers/compat-schema.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/azure.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/google.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
- package/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/providers/data/radius.json +1 -1
- package/dist/providers/data/together.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/github-copilot.d.ts +3 -1
- package/dist/providers/github-copilot.d.ts.map +1 -1
- package/dist/providers/github-copilot.js +13 -2
- package/dist/providers/github-copilot.js.map +1 -1
- package/dist/providers/openai-codex.js +1 -1
- package/dist/providers/openai-codex.js.map +1 -1
- package/dist/providers/qwen-token-plan-individual-cn.d.ts +3 -0
- package/dist/providers/qwen-token-plan-individual-cn.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.js +15 -0
- package/dist/providers/qwen-token-plan-individual-cn.js.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.d.ts +6 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.js +8 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.js.map +1 -0
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/error-body.d.ts +8 -0
- package/dist/utils/error-body.d.ts.map +1 -1
- package/dist/utils/error-body.js +28 -1
- package/dist/utils/error-body.js.map +1 -1
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +3 -0
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/package.json +11 -3
|
@@ -69,6 +69,8 @@ export declare const OpenAICompletionsCompatSchema: import("@earendil-works/pi-s
|
|
|
69
69
|
maxTokensField?: "max_completion_tokens" | "max_tokens" | undefined;
|
|
70
70
|
requiresToolResultName?: boolean | undefined;
|
|
71
71
|
requiresAssistantAfterToolResult?: boolean | undefined;
|
|
72
|
+
requiresNonNullAssistantContent?: boolean | undefined;
|
|
73
|
+
requiresToolsWithToolHistory?: boolean | undefined;
|
|
72
74
|
requiresThinkingAsText?: boolean | undefined;
|
|
73
75
|
requiresReasoningContentOnAssistantMessages?: boolean | undefined;
|
|
74
76
|
thinkingFormat?: "ant-ling" | "baseten" | "chat-template" | "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "string-thinking" | "together" | "zai" | undefined;
|
|
@@ -128,6 +130,7 @@ export declare const OpenAICompletionsCompatSchema: import("@earendil-works/pi-s
|
|
|
128
130
|
cacheControlFormat?: "anthropic" | undefined;
|
|
129
131
|
sendSessionAffinityHeaders?: boolean | undefined;
|
|
130
132
|
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter" | undefined;
|
|
133
|
+
promptCacheKeyMode?: "auto" | "disabled" | "enabled" | undefined;
|
|
131
134
|
supportsLongCacheRetention?: boolean | undefined;
|
|
132
135
|
vllmPriority?: number | undefined;
|
|
133
136
|
}>;
|
|
@@ -135,6 +138,7 @@ export declare const OpenAIResponsesCompatSchema: import("@earendil-works/pi-sch
|
|
|
135
138
|
supportsDeveloperRole?: boolean | undefined;
|
|
136
139
|
supportsMidConvoSystemMessages?: boolean | undefined;
|
|
137
140
|
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter" | undefined;
|
|
141
|
+
promptCacheKeyMode?: "auto" | "disabled" | "enabled" | undefined;
|
|
138
142
|
supportsLongCacheRetention?: boolean | undefined;
|
|
139
143
|
supportsStrictMode?: boolean | undefined;
|
|
140
144
|
supportsOpenAIGrammarTools?: boolean | undefined;
|
|
@@ -157,6 +161,7 @@ export declare const AnthropicMessagesCompatSchema: import("@earendil-works/pi-s
|
|
|
157
161
|
supportsMidConvoEffort?: boolean | undefined;
|
|
158
162
|
supportsMidConvoSystemMessages?: boolean | undefined;
|
|
159
163
|
supportsMidConvoToolChanges?: boolean | undefined;
|
|
164
|
+
supportsMessageThreads?: boolean | undefined;
|
|
160
165
|
allowedFallbackModels?: {
|
|
161
166
|
provider: string;
|
|
162
167
|
model: string;
|
|
@@ -196,6 +201,8 @@ export declare const CompatSchemasByApi: {
|
|
|
196
201
|
maxTokensField?: "max_completion_tokens" | "max_tokens" | undefined;
|
|
197
202
|
requiresToolResultName?: boolean | undefined;
|
|
198
203
|
requiresAssistantAfterToolResult?: boolean | undefined;
|
|
204
|
+
requiresNonNullAssistantContent?: boolean | undefined;
|
|
205
|
+
requiresToolsWithToolHistory?: boolean | undefined;
|
|
199
206
|
requiresThinkingAsText?: boolean | undefined;
|
|
200
207
|
requiresReasoningContentOnAssistantMessages?: boolean | undefined;
|
|
201
208
|
thinkingFormat?: "ant-ling" | "baseten" | "chat-template" | "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "string-thinking" | "together" | "zai" | undefined;
|
|
@@ -255,6 +262,7 @@ export declare const CompatSchemasByApi: {
|
|
|
255
262
|
cacheControlFormat?: "anthropic" | undefined;
|
|
256
263
|
sendSessionAffinityHeaders?: boolean | undefined;
|
|
257
264
|
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter" | undefined;
|
|
265
|
+
promptCacheKeyMode?: "auto" | "disabled" | "enabled" | undefined;
|
|
258
266
|
supportsLongCacheRetention?: boolean | undefined;
|
|
259
267
|
vllmPriority?: number | undefined;
|
|
260
268
|
}>;
|
|
@@ -262,6 +270,7 @@ export declare const CompatSchemasByApi: {
|
|
|
262
270
|
supportsDeveloperRole?: boolean | undefined;
|
|
263
271
|
supportsMidConvoSystemMessages?: boolean | undefined;
|
|
264
272
|
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter" | undefined;
|
|
273
|
+
promptCacheKeyMode?: "auto" | "disabled" | "enabled" | undefined;
|
|
265
274
|
supportsLongCacheRetention?: boolean | undefined;
|
|
266
275
|
supportsStrictMode?: boolean | undefined;
|
|
267
276
|
supportsOpenAIGrammarTools?: boolean | undefined;
|
|
@@ -275,6 +284,7 @@ export declare const CompatSchemasByApi: {
|
|
|
275
284
|
supportsDeveloperRole?: boolean | undefined;
|
|
276
285
|
supportsMidConvoSystemMessages?: boolean | undefined;
|
|
277
286
|
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter" | undefined;
|
|
287
|
+
promptCacheKeyMode?: "auto" | "disabled" | "enabled" | undefined;
|
|
278
288
|
supportsLongCacheRetention?: boolean | undefined;
|
|
279
289
|
supportsStrictMode?: boolean | undefined;
|
|
280
290
|
supportsOpenAIGrammarTools?: boolean | undefined;
|
|
@@ -288,6 +298,7 @@ export declare const CompatSchemasByApi: {
|
|
|
288
298
|
supportsDeveloperRole?: boolean | undefined;
|
|
289
299
|
supportsMidConvoSystemMessages?: boolean | undefined;
|
|
290
300
|
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter" | undefined;
|
|
301
|
+
promptCacheKeyMode?: "auto" | "disabled" | "enabled" | undefined;
|
|
291
302
|
supportsLongCacheRetention?: boolean | undefined;
|
|
292
303
|
supportsStrictMode?: boolean | undefined;
|
|
293
304
|
supportsOpenAIGrammarTools?: boolean | undefined;
|
|
@@ -310,6 +321,7 @@ export declare const CompatSchemasByApi: {
|
|
|
310
321
|
supportsMidConvoEffort?: boolean | undefined;
|
|
311
322
|
supportsMidConvoSystemMessages?: boolean | undefined;
|
|
312
323
|
supportsMidConvoToolChanges?: boolean | undefined;
|
|
324
|
+
supportsMessageThreads?: boolean | undefined;
|
|
313
325
|
allowedFallbackModels?: {
|
|
314
326
|
provider: string;
|
|
315
327
|
model: string;
|
|
@@ -351,6 +363,8 @@ export declare const ProviderCompatSchema: import("@earendil-works/pi-schema").S
|
|
|
351
363
|
maxTokensField?: "max_completion_tokens" | "max_tokens" | undefined;
|
|
352
364
|
requiresToolResultName?: boolean | undefined;
|
|
353
365
|
requiresAssistantAfterToolResult?: boolean | undefined;
|
|
366
|
+
requiresNonNullAssistantContent?: boolean | undefined;
|
|
367
|
+
requiresToolsWithToolHistory?: boolean | undefined;
|
|
354
368
|
requiresThinkingAsText?: boolean | undefined;
|
|
355
369
|
requiresReasoningContentOnAssistantMessages?: boolean | undefined;
|
|
356
370
|
thinkingFormat?: "ant-ling" | "baseten" | "chat-template" | "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "string-thinking" | "together" | "zai" | undefined;
|
|
@@ -417,6 +431,7 @@ export declare const ProviderCompatSchema: import("@earendil-works/pi-schema").S
|
|
|
417
431
|
allowEmptySignature?: boolean | undefined;
|
|
418
432
|
supportsStrictTools?: boolean | undefined;
|
|
419
433
|
supportsMidConvoToolChanges?: boolean | undefined;
|
|
434
|
+
supportsMessageThreads?: boolean | undefined;
|
|
420
435
|
allowedFallbackModels?: {
|
|
421
436
|
provider: string;
|
|
422
437
|
model: string;
|
|
@@ -439,6 +454,7 @@ export declare const ProviderCompatSchema: import("@earendil-works/pi-schema").S
|
|
|
439
454
|
supportsDeveloperRole?: boolean | undefined;
|
|
440
455
|
supportsMidConvoSystemMessages?: boolean | undefined;
|
|
441
456
|
sessionAffinityFormat?: "openai" | "openai-nosession" | "openrouter" | undefined;
|
|
457
|
+
promptCacheKeyMode?: "auto" | "disabled" | "enabled" | undefined;
|
|
442
458
|
supportsMidConvoEffort?: boolean | undefined;
|
|
443
459
|
supportsLongCacheRetention?: boolean | undefined;
|
|
444
460
|
supportsStrictMode?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat-schema.d.ts","sourceRoot":"","sources":["../../src/providers/compat-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,KAAK,MAAM,EAGX,MAAM,2BAA2B,CAAC;AAQnC,eAAO,MAAM,2BAA2B,0FAEtC,CAAC;AAeH,eAAO,MAAM,8BAA8B,oHAGzC,CAAC;AAEH,eAAO,MAAM,4BAA4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,mBAAmB,CAAC;CAAG;AAC5E,uDAAuD;AACvD,MAAM,WAAW,0BAA2B,SAAQ,MAAM,CAAC,OAAO,gCAAgC,CAAC;CAAG;AACtG,6DAA6D;AAC7D,MAAM,WAAW,eAAgB,SAAQ,MAAM,CAAC,OAAO,qBAAqB,CAAC;CAAG"}
|
|
@@ -110,6 +110,9 @@ function optionalCompatBoolean(options) {
|
|
|
110
110
|
function optionalSessionAffinityFormat(options) {
|
|
111
111
|
return opt(sessionAffinityFormat(options));
|
|
112
112
|
}
|
|
113
|
+
function optionalPromptCacheKeyMode(options) {
|
|
114
|
+
return opt(union([stringLiteral("auto"), stringLiteral("enabled"), stringLiteral("disabled")], options));
|
|
115
|
+
}
|
|
113
116
|
const OpenAICompletionsCompatProperties = {
|
|
114
117
|
supportsStore: opt(bool({
|
|
115
118
|
description: "Whether the provider supports the store field. Default: auto-detected from URL.",
|
|
@@ -135,6 +138,12 @@ const OpenAICompletionsCompatProperties = {
|
|
|
135
138
|
requiresAssistantAfterToolResult: opt(bool({
|
|
136
139
|
description: "Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL.",
|
|
137
140
|
})),
|
|
141
|
+
requiresNonNullAssistantContent: opt(bool({
|
|
142
|
+
description: 'Whether replayed assistant messages with no text (e.g. tool-call-only messages) must send "" instead of null content. Default: false.',
|
|
143
|
+
})),
|
|
144
|
+
requiresToolsWithToolHistory: opt(bool({
|
|
145
|
+
description: 'Whether requests without tools must send "tools": [] when the conversation contains tool calls or tool results. Needed by some proxies in front of Anthropic, such as older LiteLLM versions. Default: false, the field is omitted.',
|
|
146
|
+
})),
|
|
138
147
|
requiresThinkingAsText: opt(bool({
|
|
139
148
|
description: "Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL.",
|
|
140
149
|
})),
|
|
@@ -200,6 +209,9 @@ const OpenAICompletionsCompatProperties = {
|
|
|
200
209
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
201
210
|
description: "Session-affinity header format. openai sends session_id, x-client-request-id, and x-session-affinity; openai-nosession sends x-client-request-id and x-session-affinity; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected.",
|
|
202
211
|
}),
|
|
212
|
+
promptCacheKeyMode: optionalPromptCacheKeyMode({
|
|
213
|
+
description: "Controls the prompt_cache_key request field. auto sends it to api.openai.com, or with long cache retention when supportsLongCacheRetention is true; enabled sends it whenever caching is active, for compatible proxies; disabled never sends it. Default: auto.",
|
|
214
|
+
}),
|
|
203
215
|
supportsLongCacheRetention: optionalCompatBoolean({
|
|
204
216
|
description: 'Whether the provider supports long prompt cache retention (prompt_cache_retention: "24h" or Anthropic-style cache_control.ttl: "1h", depending on format). Default: auto-detected from provider and URL.',
|
|
205
217
|
}),
|
|
@@ -221,7 +233,10 @@ const OpenAIResponsesCompatProperties = {
|
|
|
221
233
|
default: false,
|
|
222
234
|
}),
|
|
223
235
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
224
|
-
description: "Session-affinity header format. openai sends
|
|
236
|
+
description: "Session-affinity header format. openai sends session-id and x-client-request-id; openai-nosession sends x-client-request-id; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected.",
|
|
237
|
+
}),
|
|
238
|
+
promptCacheKeyMode: optionalPromptCacheKeyMode({
|
|
239
|
+
description: "Controls the prompt_cache_key request field. auto and enabled send it whenever caching is active; disabled never sends it, for compatible proxies that reject it. Default: auto.",
|
|
225
240
|
}),
|
|
226
241
|
supportsLongCacheRetention: optionalCompatBoolean({
|
|
227
242
|
description: 'Whether the provider supports long prompt cache retention. This uses prompt_cache_options.ttl: "30m" on GPT-5.6+ and prompt_cache_retention: "24h" on earlier models.',
|
|
@@ -306,6 +321,9 @@ const AnthropicMessagesCompatProperties = {
|
|
|
306
321
|
description: "Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages.",
|
|
307
322
|
default: false,
|
|
308
323
|
})),
|
|
324
|
+
supportsMessageThreads: optionalCompatBoolean({
|
|
325
|
+
description: "Whether the endpoint supports Anthropic message threads, which let a request with a session id send only the new messages and continue from the previous reply. Default: true for provider anthropic with a baseUrl on api.anthropic.com, false otherwise. Set true for gateways that forward the thread request field.",
|
|
326
|
+
}),
|
|
309
327
|
allowedFallbackModels: opt(arr(AnthropicAllowedFallbackModelSchema, {
|
|
310
328
|
maxItems: 3,
|
|
311
329
|
description: "Models Anthropic accepts for server-side refusal fallback, with local pricing metadata for returned fallback responses. When absent or empty, callers must omit fallbacks; Anthropic rejects the field for models with no permitted fallback targets.",
|
|
@@ -358,6 +376,9 @@ const ProviderCompatPropertyOverrides = {
|
|
|
358
376
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
359
377
|
description: "Session-affinity header format. Defaults are API-specific or auto-detected.",
|
|
360
378
|
}),
|
|
379
|
+
promptCacheKeyMode: optionalPromptCacheKeyMode({
|
|
380
|
+
description: "Controls the prompt_cache_key request field for openai-completions and openai-responses: auto keeps each API's default, enabled sends it whenever caching is active, disabled never sends it. Default: auto.",
|
|
381
|
+
}),
|
|
361
382
|
supportsMidConvoEffort: optionalCompatBoolean({
|
|
362
383
|
description: "Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages and openai-responses APIs.",
|
|
363
384
|
default: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat-schema.js","sourceRoot":"","sources":["../../src/providers/compat-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,GAAG,EACH,IAAI,EACJ,GAAG,EACH,GAAG,EACH,GAAG,EAGH,GAAG,EACH,KAAK,GACL,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE/E,SAAS,qBAAqB,CAAC,OAAmE;IACjG,OAAO,KAAK,CAAC,CAAC,aAAa,CAAC,QA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AoB,GAAG,UAAU,CAAC,wBAAwB,EAAE;IACxE,WAAW,EAAE,6CAA6C;IAC1D,oBAAoB,EAAE,IAAI;CAC1B,CAAC,CAAC","sourcesContent":["import {\n\ttype Annotations,\n\tarr,\n\tbool,\n\tnul,\n\tnum,\n\topt,\n\ttype Properties,\n\ttype Static,\n\tstr,\n\tunion,\n} from \"@earendil-works/pi-schema\";\nimport { ModelCostSchema } from \"./model-schema.ts\";\nimport { openObject, stringLiteral, stringRecord } from \"./schema-builders.ts\";\n\nfunction sessionAffinityFormat(options?: Annotations<\"openai\" | \"openai-nosession\" | \"openrouter\">) {\n\treturn union([stringLiteral(\"openai\"), stringLiteral(\"openai-nosession\"), stringLiteral(\"openrouter\")], options);\n}\n\nexport const SessionAffinityFormatSchema = sessionAffinityFormat({\n\tdescription: \"Session-affinity header format used to route related requests consistently.\",\n});\n\nfunction thinkingTokenBudgetField(\n\toptions?: Annotations<\"thinking_token_budget\" | \"thinking_budget\" | \"thinking_budget_tokens\">,\n) {\n\treturn union(\n\t\t[\n\t\t\tstringLiteral(\"thinking_token_budget\"),\n\t\t\tstringLiteral(\"thinking_budget\"),\n\t\t\tstringLiteral(\"thinking_budget_tokens\"),\n\t\t],\n\t\toptions,\n\t);\n}\n\nexport const ThinkingTokenBudgetFieldSchema = thinkingTokenBudgetField({\n\tdescription:\n\t\t'Top-level request field name used by OpenAI-compatible endpoints to cap reasoning tokens. \"thinking_token_budget\" is used by vLLM, \"thinking_budget\" by Qwen, DashScope, or SGLang, and \"thinking_budget_tokens\" by llama.cpp.',\n});\n\nexport const ChatTemplateKwargValueSchema = union([\n\tstr(),\n\tnum(),\n\tbool(),\n\tnul(),\n\topenObject({\n\t\t$var: union([\n\t\t\tstringLiteral(\"thinking.enabled\"),\n\t\t\tstringLiteral(\"thinking.effort\"),\n\t\t\tstringLiteral(\"thinking.budget\"),\n\t\t]),\n\t\tomitWhenOff: opt(bool()),\n\t}),\n]);\n\nfunction percentileCutoffs(metric: string) {\n\treturn openObject({\n\t\tp50: opt(num({ description: `${metric} at the 50th percentile.` })),\n\t\tp75: opt(num({ description: `${metric} at the 75th percentile.` })),\n\t\tp90: opt(num({ description: `${metric} at the 90th percentile.` })),\n\t\tp99: opt(num({ description: `${metric} at the 99th percentile.` })),\n\t});\n}\n\nexport const OpenRouterRoutingSchema = openObject(\n\t{\n\t\tallow_fallbacks: opt(\n\t\t\tbool({ description: \"Whether to allow backup providers to serve requests.\", default: true }),\n\t\t),\n\t\trequire_parameters: opt(\n\t\t\tbool({\n\t\t\t\tdescription: \"Whether to filter providers to only those that support all parameters in the request.\",\n\t\t\t\tdefault: false,\n\t\t\t}),\n\t\t),\n\t\tdata_collection: opt(\n\t\t\tunion([stringLiteral(\"deny\"), stringLiteral(\"allow\")], {\n\t\t\t\tdescription:\n\t\t\t\t\t'Data collection setting. \"allow\": allow providers that may store or train on data. \"deny\": only use providers that do not collect user data.',\n\t\t\t\tdefault: \"allow\",\n\t\t\t}),\n\t\t),\n\t\tzdr: opt(bool({ description: \"Whether to restrict routing to only ZDR (Zero Data Retention) endpoints.\" })),\n\t\tenforce_distillable_text: opt(\n\t\t\tbool({ description: \"Whether to restrict routing to only models that allow text distillation.\" }),\n\t\t),\n\t\torder: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"An ordered list of provider names or slugs to try in sequence, falling back to the next if unavailable.\",\n\t\t\t}),\n\t\t),\n\t\tonly: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription: \"List of provider names or slugs to exclusively allow for this request.\",\n\t\t\t}),\n\t\t),\n\t\tignore: opt(arr(str(), { description: \"List of provider names or slugs to skip for this request.\" })),\n\t\tquantizations: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription:\n\t\t\t\t\t'A list of quantization levels to filter providers by, for example [\"fp16\", \"bf16\", \"fp8\", \"fp6\", \"int8\", \"int4\", \"fp4\", \"fp32\"].',\n\t\t\t}),\n\t\t),\n\t\tsort: opt(\n\t\t\tunion(\n\t\t\t\t[\n\t\t\t\t\tstr(),\n\t\t\t\t\topenObject({\n\t\t\t\t\t\tby: opt(str({ description: 'The sorting metric, such as \"price\", \"throughput\", or \"latency\".' })),\n\t\t\t\t\t\tpartition: opt(\n\t\t\t\t\t\t\tunion([str(), nul()], {\n\t\t\t\t\t\t\t\tdescription: 'Partitioning strategy: \"model\" or \"none\".',\n\t\t\t\t\t\t\t\tdefault: \"model\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\t{\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Sorting strategy. Can be a string such as \"price\", \"throughput\", or \"latency\", or an object.',\n\t\t\t\t},\n\t\t\t),\n\t\t),\n\t\tmax_price: opt(\n\t\t\topenObject(\n\t\t\t\t{\n\t\t\t\t\tprompt: opt(union([num(), str()], { description: \"Price per million prompt tokens.\" })),\n\t\t\t\t\tcompletion: opt(union([num(), str()], { description: \"Price per million completion tokens.\" })),\n\t\t\t\t\timage: opt(union([num(), str()], { description: \"Price per image.\" })),\n\t\t\t\t\taudio: opt(union([num(), str()], { description: \"Price per audio unit.\" })),\n\t\t\t\t\trequest: opt(union([num(), str()], { description: \"Price per request.\" })),\n\t\t\t\t},\n\t\t\t\t{ description: \"Maximum price per million tokens in USD.\" },\n\t\t\t),\n\t\t),\n\t\tpreferred_min_throughput: opt(\n\t\t\tunion([num(), percentileCutoffs(\"Minimum tokens per second\")], {\n\t\t\t\tdescription: \"Preferred minimum throughput in tokens per second. A number applies to p50.\",\n\t\t\t}),\n\t\t),\n\t\tpreferred_max_latency: opt(\n\t\t\tunion([num(), percentileCutoffs(\"Maximum latency in seconds\")], {\n\t\t\t\tdescription: \"Preferred maximum latency in seconds. A number applies to p50.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{\n\t\tdescription:\n\t\t\t\"OpenRouter provider routing preferences. Controls which upstream providers OpenRouter routes requests to. Sent as the provider field in the OpenRouter API request body. See https://openrouter.ai/docs/guides/routing/provider-selection.\",\n\t},\n);\n\nexport const VercelGatewayRoutingSchema = openObject(\n\t{\n\t\tonly: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription:\n\t\t\t\t\t'List of provider slugs to exclusively use for this request, for example [\"bedrock\", \"anthropic\"].',\n\t\t\t}),\n\t\t),\n\t\torder: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription: 'List of provider slugs to try in order, for example [\"anthropic\", \"openai\"].',\n\t\t\t}),\n\t\t),\n\t},\n\t{\n\t\tdescription:\n\t\t\t\"Vercel AI Gateway routing preferences. Controls which upstream providers the gateway routes requests to. See https://vercel.com/docs/ai-gateway/models-and-providers/provider-options.\",\n\t},\n);\n\nexport const AnthropicAllowedFallbackModelSchema = openObject(\n\t{\n\t\tprovider: str({ minLength: 1 }),\n\t\tmodel: str({ minLength: 1 }),\n\t\tcost: ModelCostSchema,\n\t},\n\t{ description: \"An Anthropic server-side refusal fallback model with local pricing metadata.\" },\n);\n\nfunction optionalCompatBoolean(options?: Annotations<boolean>) {\n\treturn opt(bool(options));\n}\n\nfunction optionalSessionAffinityFormat(options?: Annotations<\"openai\" | \"openai-nosession\" | \"openrouter\">) {\n\treturn opt(sessionAffinityFormat(options));\n}\n\nconst OpenAICompletionsCompatProperties = {\n\tsupportsStore: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the provider supports the store field. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\tsupportsDeveloperRole: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports the developer role instead of system. Default: auto-detected from URL.\",\n\t}),\n\tsupportsReasoningEffort: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the provider supports reasoning_effort. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\tsupportsUsageInStreaming: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider supports stream_options.include_usage for token usage in streaming responses.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tsupportsFinishReason: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether streamed responses include finish_reason. When false, pi infers stop or toolUse when the stream ends.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tmaxTokensField: opt(\n\t\tunion([stringLiteral(\"max_completion_tokens\"), stringLiteral(\"max_tokens\")], {\n\t\t\tdescription: \"Which field to use for max tokens. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\trequiresToolResultName: opt(\n\t\tbool({ description: \"Whether tool results require the name field. Default: auto-detected from URL.\" }),\n\t),\n\trequiresAssistantAfterToolResult: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\trequiresThinkingAsText: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\trequiresReasoningContentOnAssistantMessages: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\tthinkingFormat: opt(\n\t\tunion(\n\t\t\t[\n\t\t\t\tstringLiteral(\"openai\"),\n\t\t\t\tstringLiteral(\"openrouter\"),\n\t\t\t\tstringLiteral(\"deepseek\"),\n\t\t\t\tstringLiteral(\"together\"),\n\t\t\t\tstringLiteral(\"baseten\"),\n\t\t\t\tstringLiteral(\"zai\"),\n\t\t\t\tstringLiteral(\"qwen\"),\n\t\t\t\tstringLiteral(\"chat-template\"),\n\t\t\t\tstringLiteral(\"qwen-chat-template\"),\n\t\t\t\tstringLiteral(\"string-thinking\"),\n\t\t\t\tstringLiteral(\"ant-ling\"),\n\t\t\t],\n\t\t\t{\n\t\t\t\tdescription:\n\t\t\t\t\t'Format for reasoning or thinking parameters. When omitted, Pi auto-detects the format from the provider URL. \"openai\" uses reasoning_effort, \"openrouter\" uses reasoning.effort, \"deepseek\" uses thinking.type plus reasoning_effort when supported, \"together\" uses reasoning.enabled plus reasoning_effort when supported, \"baseten\" uses configurable chat_template_args plus reasoning_effort when supported, \"zai\" uses thinking.type, \"qwen\" uses top-level enable_thinking, \"qwen-chat-template\" uses chat_template_kwargs.enable_thinking and preserve_thinking, \"chat-template\" uses configurable chat_template_kwargs, \"string-thinking\" uses top-level thinking, and \"ant-ling\" uses reasoning.effort only when the mapped effort is non-null.',\n\t\t\t},\n\t\t),\n\t),\n\tchatTemplateKwargs: opt(\n\t\tstringRecord(ChatTemplateKwargValueSchema, {\n\t\t\tdescription:\n\t\t\t\t'Kwargs sent as chat_template_kwargs when thinkingFormat is \"chat-template\". Use $var with \"thinking.enabled\", \"thinking.effort\", or \"thinking.budget\" for pi-controlled values.',\n\t\t}),\n\t),\n\tchatTemplateArgs: opt(\n\t\tstringRecord(ChatTemplateKwargValueSchema, {\n\t\t\tdescription:\n\t\t\t\t'Arguments sent as chat_template_args when thinkingFormat is \"baseten\". Use $var with \"thinking.enabled\", \"thinking.effort\", or \"thinking.budget\" for pi-controlled values.',\n\t\t}),\n\t),\n\topenRouterRouting: opt(OpenRouterRoutingSchema),\n\tvercelGatewayRouting: opt(VercelGatewayRoutingSchema),\n\tzaiToolStream: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether z.ai supports top-level tool_stream for streaming tool call deltas.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tthinkingTokenBudgetField: opt(\n\t\tthinkingTokenBudgetField({\n\t\t\tdescription:\n\t\t\t\t'Top-level request field used to cap reasoning tokens from thinkingBudgets. Reasoning and the answer share max_tokens on these endpoints. \"thinking_token_budget\" is vLLM, \"thinking_budget\" is Qwen, DashScope, or SGLang, and \"thinking_budget_tokens\" is llama.cpp. Off by default and not set on the generated catalog.',\n\t\t}),\n\t),\n\tsupportsThinkingTokenBudget: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t'Alias for thinkingTokenBudgetField: \"thinking_token_budget\" (vLLM). Prefer thinkingTokenBudgetField.',\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsOpenAIGrammarTools: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models.\",\n\t\tdefault: false,\n\t}),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system or developer messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models.\",\n\t\tdefault: false,\n\t}),\n\tsupportsMidConvoToolAdditions: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether system messages can introduce additional tools mid-conversation. Requires supportsMidConvoSystemMessages. The generated catalog enables this for capable models.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports the strict field in tool definitions. Generated capable models enable it explicitly.\",\n\t\tdefault: false,\n\t}),\n\tcacheControlFormat: opt(\n\t\tstringLiteral(\"anthropic\", {\n\t\t\tdescription:\n\t\t\t\t\"Cache control convention for prompt caching. Anthropic applies cache_control markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content.\",\n\t\t}),\n\t),\n\tsendSessionAffinityHeaders: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether to send session-affinity data from options.sessionId. Default: true for OpenRouter endpoints, false otherwise.\",\n\t}),\n\tsessionAffinityFormat: optionalSessionAffinityFormat({\n\t\tdescription:\n\t\t\t\"Session-affinity header format. openai sends session_id, x-client-request-id, and x-session-affinity; openai-nosession sends x-client-request-id and x-session-affinity; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected.\",\n\t}),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t'Whether the provider supports long prompt cache retention (prompt_cache_retention: \"24h\" or Anthropic-style cache_control.ttl: \"1h\", depending on format). Default: auto-detected from provider and URL.',\n\t}),\n\tvllmPriority: opt(\n\t\tnum({\n\t\t\tdescription:\n\t\t\t\t\"vLLM scheduler priority sent as the top-level priority request field. Lower values are handled earlier and the server default is 0. Only meaningful with --scheduling-policy priority. Off by default and not set on the generated catalog.\",\n\t\t}),\n\t),\n};\n\nexport const OpenAICompletionsCompatSchema = openObject(OpenAICompletionsCompatProperties, {\n\tdescription:\n\t\t\"Compatibility settings for OpenAI-compatible completions APIs. Use this to override URL-based auto-detection for custom providers.\",\n\tadditionalProperties: true,\n});\n\nconst OpenAIResponsesCompatProperties = {\n\tsupportsDeveloperRole: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports the developer role instead of system.\",\n\t\tdefault: true,\n\t}),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts developer or system messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models.\",\n\t\tdefault: false,\n\t}),\n\tsessionAffinityFormat: optionalSessionAffinityFormat({\n\t\tdescription:\n\t\t\t\"Session-affinity header format. openai sends session_id and x-client-request-id; openai-nosession sends x-client-request-id; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected.\",\n\t}),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t'Whether the provider supports long prompt cache retention. This uses prompt_cache_options.ttl: \"30m\" on GPT-5.6+ and prompt_cache_retention: \"24h\" on earlier models.',\n\t\tdefault: true,\n\t}),\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports strict JSON-schema function tools. Defaults are API-specific; generated OpenAI models enable it explicitly.\",\n\t}),\n\tsupportsOpenAIGrammarTools: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether to emit OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models.\",\n\t\tdefault: false,\n\t}),\n\tsupportsAdditionalTools: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the model supports message-anchored additional_tools input items.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsToolSearch: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the model supports client-executed tool search for transcript-anchored additions.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsExplicitPromptCacheMode: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the model accepts prompt_cache_options. Older OpenAI models reject the parameter.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMidConvoEffort: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Only used by the openai-responses API, and ignored with Sign in with ChatGPT on the openai provider.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMaxOutputTokens: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the provider accepts max_output_tokens. Some Codex-protocol gateways reject it.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n};\n\nexport const OpenAIResponsesCompatSchema = openObject(OpenAIResponsesCompatProperties, {\n\tdescription: \"Compatibility settings for OpenAI Responses APIs.\",\n\tadditionalProperties: true,\n});\n\nconst AnthropicMessagesCompatProperties = {\n\tsupportsEagerToolInputStreaming: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider accepts per-tool eager_input_streaming. When false, the Anthropic provider omits tools[].eager_input_streaming and sends the legacy fine-grained-tool-streaming-2025-05-14 beta header for tool-enabled requests.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports Anthropic long cache retention through cache_control.ttl.\",\n\t\tdefault: true,\n\t}),\n\tsendSessionAffinityHeaders: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether to send x-session-affinity from options.sessionId when caching is enabled. Required for providers like Fireworks that use session affinity for prompt cache routing; requests to the same replica maximize cache hits. Default: true for OpenRouter endpoints, false otherwise.\",\n\t}),\n\tsessionAffinityFormat: opt(\n\t\tstringLiteral(\"openrouter\", {\n\t\t\tdescription: \"Session-affinity format. openrouter sends x-session-id; when unset, sends x-session-affinity.\",\n\t\t}),\n\t),\n\tsupportsCacheControlOnTools: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider supports Anthropic-style cache_control markers on tool definitions. When false, cache_control is omitted from tool parameters. Some Anthropic-compatible providers, such as Fireworks, do not support this field on tools and may reject or ignore it.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tsupportsTemperature: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the model accepts the Anthropic temperature request field. Claude Opus 4.7+ rejects non-default values.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tforceAdaptiveThinking: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether to force adaptive thinking (thinking.type: adaptive plus output_config.effort) regardless of model ID. Built-in models that require adaptive thinking set this in generated metadata. Custom Anthropic-compatible providers can set this to true for any model whose upstream requires the adaptive format. Set false to opt out on overridden built-in models.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tallowEmptySignature: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether to replay empty thinking signatures instead of converting thinking to text.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsStrictTools: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider supports Anthropic strict tool schemas. Generated Anthropic models enable it explicitly.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMidConvoEffort: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the exact model transport supports effort-only system messages and thinking binding controls.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system-role messages inside the conversation. When false, later system messages are folded into the top-level system prompt.\",\n\t\tdefault: false,\n\t}),\n\tsupportsMidConvoToolChanges: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tallowedFallbackModels: opt(\n\t\tarr(AnthropicAllowedFallbackModelSchema, {\n\t\t\tmaxItems: 3,\n\t\t\tdescription:\n\t\t\t\t\"Models Anthropic accepts for server-side refusal fallback, with local pricing metadata for returned fallback responses. When absent or empty, callers must omit fallbacks; Anthropic rejects the field for models with no permitted fallback targets.\",\n\t\t}),\n\t),\n};\n\nexport const AnthropicMessagesCompatSchema = openObject(AnthropicMessagesCompatProperties, {\n\tdescription: \"Compatibility settings for Anthropic Messages-compatible APIs.\",\n\tadditionalProperties: true,\n});\n\nconst BedrockCompatProperties = {\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription: \"Whether the model supports Bedrock strict tool schemas.\",\n\t\tdefault: false,\n\t}),\n};\n\nexport const BedrockCompatSchema = openObject(BedrockCompatProperties, {\n\tdescription: \"Compatibility settings for Amazon Bedrock models.\",\n\tadditionalProperties: true,\n});\n\nconst MistralConversationsCompatProperties = {\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message.\",\n\t\tdefault: false,\n\t}),\n};\n\nexport const MistralConversationsCompatSchema = openObject(MistralConversationsCompatProperties, {\n\tdescription: \"Compatibility settings for the Mistral chat API.\",\n\tadditionalProperties: true,\n});\n\nconst SystemOneCompatProperties = {\n\timageInput: opt(\n\t\tunion([stringLiteral(\"assets\"), stringLiteral(\"images\"), stringLiteral(\"state-image-urls\")], {\n\t\t\tdescription:\n\t\t\t\t'How the service takes classifier images. \"assets\" sends TypeSafe\\'s assets map (PNG and JPEG) and references the images from the state, as TypeSafe and Jev on Workers AI expect. \"images\" sends Clef\\'s images list of data URLs (PNG, JPEG, and WebP, at most four), as Clef on Workers AI expects. \"state-image-urls\" places image_url parts before the state, as OpenRouter expects; OpenRouter drops assets without an error. Auto-detected from the provider, baseUrl, and model ID. Classifier models read it from the provider-level compat; models and modelOverrides entries apply to chat models only.',\n\t\t}),\n\t),\n\tsendImageOptInHeader: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether requests with images send the TypeSafe-Danger-Zone-Images: true header, which TypeSafe's own API requires for its experimental image input. Defaults to true for the typesafe-system-one API unless the model is detected as OpenRouter.\",\n\t}),\n};\n\nexport const SystemOneCompatSchema = openObject(SystemOneCompatProperties, {\n\tdescription: \"Compatibility settings for System One classifier APIs.\",\n\tadditionalProperties: true,\n});\n\nconst ProviderCompatPropertyOverrides = {\n\tsupportsDeveloperRole: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports the developer role instead of system. Defaults are API-specific.\",\n\t}),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system or developer messages after the conversation has started. When false, later system messages are folded into the leading system message.\",\n\t\tdefault: false,\n\t}),\n\tsessionAffinityFormat: optionalSessionAffinityFormat({\n\t\tdescription: \"Session-affinity header format. Defaults are API-specific or auto-detected.\",\n\t}),\n\tsupportsMidConvoEffort: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages and openai-responses APIs.\",\n\t\tdefault: false,\n\t}),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports long prompt cache retention. Defaults are API-specific or auto-detected.\",\n\t}),\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports strict tool schemas. Defaults are API-specific.\",\n\t}),\n\tsupportsOpenAIGrammarTools: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools.\",\n\t\tdefault: false,\n\t}),\n\tsendSessionAffinityHeaders: optionalCompatBoolean({\n\t\tdescription: \"Whether to send session-affinity data from options.sessionId. Defaults are API-specific.\",\n\t}),\n} satisfies Properties;\n\ntype UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (\n\tvalue: infer Intersection,\n) => void\n\t? Intersection\n\t: never;\n\ntype MergedCompatProperties<PropertyGroups extends readonly Properties[], Overrides extends Properties> = Omit<\n\tUnionToIntersection<PropertyGroups[number]>,\n\tkeyof Overrides\n> &\n\tOverrides;\n\n/**\n * Provider-level models.json compatibility is API-agnostic, so it needs one superset. Every\n * duplicate property requires explicit generic metadata, while API-specific schemas retain their\n * own defaults and descriptions.\n */\nfunction mergeCompatProperties<const PropertyGroups extends readonly Properties[], const Overrides extends Properties>(\n\tpropertyGroups: PropertyGroups,\n\toverrides: Overrides,\n): MergedCompatProperties<PropertyGroups, Overrides> {\n\tconst merged: Record<string, Properties[string]> = {};\n\tconst duplicateNames = new Set<string>();\n\n\tfor (const properties of propertyGroups) {\n\t\tfor (const [name, schema] of Object.entries(properties)) {\n\t\t\tif (merged[name] !== undefined) {\n\t\t\t\tduplicateNames.add(name);\n\t\t\t\tif (!(name in overrides)) {\n\t\t\t\t\tthrow new Error(`Duplicate compatibility schema property requires an override: ${name}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmerged[name] = schema;\n\t\t}\n\t}\n\n\tfor (const name of Object.keys(overrides)) {\n\t\tif (!duplicateNames.has(name)) {\n\t\t\tthrow new Error(`Compatibility schema override does not resolve a duplicate property: ${name}`);\n\t\t}\n\t}\n\n\treturn { ...merged, ...overrides } as MergedCompatProperties<PropertyGroups, Overrides>;\n}\n\n/** Compatibility schema for each API whose models accept compat. Mirrors the compat type of Model. */\nexport const CompatSchemasByApi = {\n\t\"openai-completions\": OpenAICompletionsCompatSchema,\n\t\"openai-responses\": OpenAIResponsesCompatSchema,\n\t\"azure-openai-responses\": OpenAIResponsesCompatSchema,\n\t\"openai-codex-responses\": OpenAIResponsesCompatSchema,\n\t\"anthropic-messages\": AnthropicMessagesCompatSchema,\n\t\"bedrock-converse-stream\": BedrockCompatSchema,\n\t\"mistral-conversations\": MistralConversationsCompatSchema,\n\t\"typesafe-system-one\": SystemOneCompatSchema,\n\t\"cloudflare-workers-ai-system-one\": SystemOneCompatSchema,\n} as const;\n\nconst ProviderCompatProperties = mergeCompatProperties(\n\t[\n\t\tOpenAICompletionsCompatProperties,\n\t\tOpenAIResponsesCompatProperties,\n\t\tAnthropicMessagesCompatProperties,\n\t\tBedrockCompatProperties,\n\t\tMistralConversationsCompatProperties,\n\t\tSystemOneCompatProperties,\n\t],\n\tProviderCompatPropertyOverrides,\n);\n\nexport const ProviderCompatSchema = openObject(ProviderCompatProperties, {\n\tdescription: \"Provider and model compatibility overrides.\",\n\tadditionalProperties: true,\n});\n\nexport type ChatTemplateKwargValue = Static<typeof ChatTemplateKwargValueSchema>;\n/** Provider and model compatibility overrides in models.json: every API's compat fields. */\nexport type ProviderCompat = Static<typeof ProviderCompatSchema>;\n/** Top-level request field used to cap reasoning tokens on OpenAI-compatible servers. */\nexport type ThinkingTokenBudgetField = Static<typeof ThinkingTokenBudgetFieldSchema>;\nexport type SessionAffinityFormat = Static<typeof SessionAffinityFormatSchema>;\n/** OpenRouter provider routing preferences. */\nexport interface OpenRouterRouting extends Static<typeof OpenRouterRoutingSchema> {}\n/** Vercel AI Gateway routing preferences. */\nexport interface VercelGatewayRouting extends Static<typeof VercelGatewayRoutingSchema> {}\n/** An Anthropic server-side refusal fallback model with local pricing metadata. */\nexport interface AnthropicAllowedFallbackModel extends Static<typeof AnthropicAllowedFallbackModelSchema> {}\n\n/** Compatibility settings for OpenAI-compatible completions APIs. */\nexport interface OpenAICompletionsCompat extends Static<typeof OpenAICompletionsCompatSchema> {}\n/** Compatibility settings for OpenAI Responses APIs. */\nexport interface OpenAIResponsesCompat extends Static<typeof OpenAIResponsesCompatSchema> {}\n/** Compatibility settings for Anthropic Messages-compatible APIs. */\nexport interface AnthropicMessagesCompat extends Static<typeof AnthropicMessagesCompatSchema> {}\n/** Compatibility settings for Amazon Bedrock models. */\nexport interface BedrockCompat extends Static<typeof BedrockCompatSchema> {}\n/** Compatibility settings for the Mistral chat API. */\nexport interface MistralConversationsCompat extends Static<typeof MistralConversationsCompatSchema> {}\n/** Compatibility settings for System One classifier APIs. */\nexport interface SystemOneCompat extends Static<typeof SystemOneCompatSchema> {}\n"]}
|
|
1
|
+
{"version":3,"file":"compat-schema.js","sourceRoot":"","sources":["../../src/providers/compat-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,GAAG,EACH,IAAI,EACJ,GAAG,EACH,GAAG,EACH,GAAG,EAGH,GAAG,EACH,KAAK,GACL,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE/E,SAAS,qBAAqB,CAAC,OAAmE;IACjG,OAAO,KAAK,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAClH,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAAqB,CAAC;IAChE,WAAW,EAAE,6EAA6E;CAC1F,CAAC,CAAC;AAEH,SAAS,wBAAwB,CAChC,OAA6F;IAE7F,OAAO,KAAK,CACX;QACC,aAAa,CAAC,uBAAuB,CAAC;QACtC,aAAa,CAAC,iBAAiB,CAAC;QAChC,aAAa,CAAC,wBAAwB,CAAC;KACvC,EACD,OAAO,CACP,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,8BA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E,qBAAqB;IAC5C,kCAAkC,EAAE,qBAAqB;CAChD,CAAC;AAEX,MAAM,wBAAwB,GAAG,qBAAqB,CACrD;IACC,iCAAiC;IACjC,+BAA+B;IAC/B,iCAAiC;IACjC,uBAAuB;IACvB,oCAAoC;IACpC,yBAAyB;CACzB,EACD,+BAA+B,CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC,wBAAwB,EAAE;IACxE,WAAW,EAAE,6CAA6C;IAC1D,oBAAoB,EAAE,IAAI;CAC1B,CAAC,CAAC","sourcesContent":["import {\n\ttype Annotations,\n\tarr,\n\tbool,\n\tnul,\n\tnum,\n\topt,\n\ttype Properties,\n\ttype Static,\n\tstr,\n\tunion,\n} from \"@earendil-works/pi-schema\";\nimport { ModelCostSchema } from \"./model-schema.ts\";\nimport { openObject, stringLiteral, stringRecord } from \"./schema-builders.ts\";\n\nfunction sessionAffinityFormat(options?: Annotations<\"openai\" | \"openai-nosession\" | \"openrouter\">) {\n\treturn union([stringLiteral(\"openai\"), stringLiteral(\"openai-nosession\"), stringLiteral(\"openrouter\")], options);\n}\n\nexport const SessionAffinityFormatSchema = sessionAffinityFormat({\n\tdescription: \"Session-affinity header format used to route related requests consistently.\",\n});\n\nfunction thinkingTokenBudgetField(\n\toptions?: Annotations<\"thinking_token_budget\" | \"thinking_budget\" | \"thinking_budget_tokens\">,\n) {\n\treturn union(\n\t\t[\n\t\t\tstringLiteral(\"thinking_token_budget\"),\n\t\t\tstringLiteral(\"thinking_budget\"),\n\t\t\tstringLiteral(\"thinking_budget_tokens\"),\n\t\t],\n\t\toptions,\n\t);\n}\n\nexport const ThinkingTokenBudgetFieldSchema = thinkingTokenBudgetField({\n\tdescription:\n\t\t'Top-level request field name used by OpenAI-compatible endpoints to cap reasoning tokens. \"thinking_token_budget\" is used by vLLM, \"thinking_budget\" by Qwen, DashScope, or SGLang, and \"thinking_budget_tokens\" by llama.cpp.',\n});\n\nexport const ChatTemplateKwargValueSchema = union([\n\tstr(),\n\tnum(),\n\tbool(),\n\tnul(),\n\topenObject({\n\t\t$var: union([\n\t\t\tstringLiteral(\"thinking.enabled\"),\n\t\t\tstringLiteral(\"thinking.effort\"),\n\t\t\tstringLiteral(\"thinking.budget\"),\n\t\t]),\n\t\tomitWhenOff: opt(bool()),\n\t}),\n]);\n\nfunction percentileCutoffs(metric: string) {\n\treturn openObject({\n\t\tp50: opt(num({ description: `${metric} at the 50th percentile.` })),\n\t\tp75: opt(num({ description: `${metric} at the 75th percentile.` })),\n\t\tp90: opt(num({ description: `${metric} at the 90th percentile.` })),\n\t\tp99: opt(num({ description: `${metric} at the 99th percentile.` })),\n\t});\n}\n\nexport const OpenRouterRoutingSchema = openObject(\n\t{\n\t\tallow_fallbacks: opt(\n\t\t\tbool({ description: \"Whether to allow backup providers to serve requests.\", default: true }),\n\t\t),\n\t\trequire_parameters: opt(\n\t\t\tbool({\n\t\t\t\tdescription: \"Whether to filter providers to only those that support all parameters in the request.\",\n\t\t\t\tdefault: false,\n\t\t\t}),\n\t\t),\n\t\tdata_collection: opt(\n\t\t\tunion([stringLiteral(\"deny\"), stringLiteral(\"allow\")], {\n\t\t\t\tdescription:\n\t\t\t\t\t'Data collection setting. \"allow\": allow providers that may store or train on data. \"deny\": only use providers that do not collect user data.',\n\t\t\t\tdefault: \"allow\",\n\t\t\t}),\n\t\t),\n\t\tzdr: opt(bool({ description: \"Whether to restrict routing to only ZDR (Zero Data Retention) endpoints.\" })),\n\t\tenforce_distillable_text: opt(\n\t\t\tbool({ description: \"Whether to restrict routing to only models that allow text distillation.\" }),\n\t\t),\n\t\torder: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"An ordered list of provider names or slugs to try in sequence, falling back to the next if unavailable.\",\n\t\t\t}),\n\t\t),\n\t\tonly: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription: \"List of provider names or slugs to exclusively allow for this request.\",\n\t\t\t}),\n\t\t),\n\t\tignore: opt(arr(str(), { description: \"List of provider names or slugs to skip for this request.\" })),\n\t\tquantizations: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription:\n\t\t\t\t\t'A list of quantization levels to filter providers by, for example [\"fp16\", \"bf16\", \"fp8\", \"fp6\", \"int8\", \"int4\", \"fp4\", \"fp32\"].',\n\t\t\t}),\n\t\t),\n\t\tsort: opt(\n\t\t\tunion(\n\t\t\t\t[\n\t\t\t\t\tstr(),\n\t\t\t\t\topenObject({\n\t\t\t\t\t\tby: opt(str({ description: 'The sorting metric, such as \"price\", \"throughput\", or \"latency\".' })),\n\t\t\t\t\t\tpartition: opt(\n\t\t\t\t\t\t\tunion([str(), nul()], {\n\t\t\t\t\t\t\t\tdescription: 'Partitioning strategy: \"model\" or \"none\".',\n\t\t\t\t\t\t\t\tdefault: \"model\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\t{\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Sorting strategy. Can be a string such as \"price\", \"throughput\", or \"latency\", or an object.',\n\t\t\t\t},\n\t\t\t),\n\t\t),\n\t\tmax_price: opt(\n\t\t\topenObject(\n\t\t\t\t{\n\t\t\t\t\tprompt: opt(union([num(), str()], { description: \"Price per million prompt tokens.\" })),\n\t\t\t\t\tcompletion: opt(union([num(), str()], { description: \"Price per million completion tokens.\" })),\n\t\t\t\t\timage: opt(union([num(), str()], { description: \"Price per image.\" })),\n\t\t\t\t\taudio: opt(union([num(), str()], { description: \"Price per audio unit.\" })),\n\t\t\t\t\trequest: opt(union([num(), str()], { description: \"Price per request.\" })),\n\t\t\t\t},\n\t\t\t\t{ description: \"Maximum price per million tokens in USD.\" },\n\t\t\t),\n\t\t),\n\t\tpreferred_min_throughput: opt(\n\t\t\tunion([num(), percentileCutoffs(\"Minimum tokens per second\")], {\n\t\t\t\tdescription: \"Preferred minimum throughput in tokens per second. A number applies to p50.\",\n\t\t\t}),\n\t\t),\n\t\tpreferred_max_latency: opt(\n\t\t\tunion([num(), percentileCutoffs(\"Maximum latency in seconds\")], {\n\t\t\t\tdescription: \"Preferred maximum latency in seconds. A number applies to p50.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{\n\t\tdescription:\n\t\t\t\"OpenRouter provider routing preferences. Controls which upstream providers OpenRouter routes requests to. Sent as the provider field in the OpenRouter API request body. See https://openrouter.ai/docs/guides/routing/provider-selection.\",\n\t},\n);\n\nexport const VercelGatewayRoutingSchema = openObject(\n\t{\n\t\tonly: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription:\n\t\t\t\t\t'List of provider slugs to exclusively use for this request, for example [\"bedrock\", \"anthropic\"].',\n\t\t\t}),\n\t\t),\n\t\torder: opt(\n\t\t\tarr(str(), {\n\t\t\t\tdescription: 'List of provider slugs to try in order, for example [\"anthropic\", \"openai\"].',\n\t\t\t}),\n\t\t),\n\t},\n\t{\n\t\tdescription:\n\t\t\t\"Vercel AI Gateway routing preferences. Controls which upstream providers the gateway routes requests to. See https://vercel.com/docs/ai-gateway/models-and-providers/provider-options.\",\n\t},\n);\n\nexport const AnthropicAllowedFallbackModelSchema = openObject(\n\t{\n\t\tprovider: str({ minLength: 1 }),\n\t\tmodel: str({ minLength: 1 }),\n\t\tcost: ModelCostSchema,\n\t},\n\t{ description: \"An Anthropic server-side refusal fallback model with local pricing metadata.\" },\n);\n\nfunction optionalCompatBoolean(options?: Annotations<boolean>) {\n\treturn opt(bool(options));\n}\n\nfunction optionalSessionAffinityFormat(options?: Annotations<\"openai\" | \"openai-nosession\" | \"openrouter\">) {\n\treturn opt(sessionAffinityFormat(options));\n}\n\nfunction optionalPromptCacheKeyMode(options?: Annotations<\"auto\" | \"enabled\" | \"disabled\">) {\n\treturn opt(union([stringLiteral(\"auto\"), stringLiteral(\"enabled\"), stringLiteral(\"disabled\")], options));\n}\n\nconst OpenAICompletionsCompatProperties = {\n\tsupportsStore: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the provider supports the store field. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\tsupportsDeveloperRole: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports the developer role instead of system. Default: auto-detected from URL.\",\n\t}),\n\tsupportsReasoningEffort: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the provider supports reasoning_effort. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\tsupportsUsageInStreaming: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider supports stream_options.include_usage for token usage in streaming responses.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tsupportsFinishReason: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether streamed responses include finish_reason. When false, pi infers stop or toolUse when the stream ends.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tmaxTokensField: opt(\n\t\tunion([stringLiteral(\"max_completion_tokens\"), stringLiteral(\"max_tokens\")], {\n\t\t\tdescription: \"Which field to use for max tokens. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\trequiresToolResultName: opt(\n\t\tbool({ description: \"Whether tool results require the name field. Default: auto-detected from URL.\" }),\n\t),\n\trequiresAssistantAfterToolResult: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\trequiresNonNullAssistantContent: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t'Whether replayed assistant messages with no text (e.g. tool-call-only messages) must send \"\" instead of null content. Default: false.',\n\t\t}),\n\t),\n\trequiresToolsWithToolHistory: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t'Whether requests without tools must send \"tools\": [] when the conversation contains tool calls or tool results. Needed by some proxies in front of Anthropic, such as older LiteLLM versions. Default: false, the field is omitted.',\n\t\t}),\n\t),\n\trequiresThinkingAsText: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\trequiresReasoningContentOnAssistantMessages: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL.\",\n\t\t}),\n\t),\n\tthinkingFormat: opt(\n\t\tunion(\n\t\t\t[\n\t\t\t\tstringLiteral(\"openai\"),\n\t\t\t\tstringLiteral(\"openrouter\"),\n\t\t\t\tstringLiteral(\"deepseek\"),\n\t\t\t\tstringLiteral(\"together\"),\n\t\t\t\tstringLiteral(\"baseten\"),\n\t\t\t\tstringLiteral(\"zai\"),\n\t\t\t\tstringLiteral(\"qwen\"),\n\t\t\t\tstringLiteral(\"chat-template\"),\n\t\t\t\tstringLiteral(\"qwen-chat-template\"),\n\t\t\t\tstringLiteral(\"string-thinking\"),\n\t\t\t\tstringLiteral(\"ant-ling\"),\n\t\t\t],\n\t\t\t{\n\t\t\t\tdescription:\n\t\t\t\t\t'Format for reasoning or thinking parameters. When omitted, Pi auto-detects the format from the provider URL. \"openai\" uses reasoning_effort, \"openrouter\" uses reasoning.effort, \"deepseek\" uses thinking.type plus reasoning_effort when supported, \"together\" uses reasoning.enabled plus reasoning_effort when supported, \"baseten\" uses configurable chat_template_args plus reasoning_effort when supported, \"zai\" uses thinking.type, \"qwen\" uses top-level enable_thinking, \"qwen-chat-template\" uses chat_template_kwargs.enable_thinking and preserve_thinking, \"chat-template\" uses configurable chat_template_kwargs, \"string-thinking\" uses top-level thinking, and \"ant-ling\" uses reasoning.effort only when the mapped effort is non-null.',\n\t\t\t},\n\t\t),\n\t),\n\tchatTemplateKwargs: opt(\n\t\tstringRecord(ChatTemplateKwargValueSchema, {\n\t\t\tdescription:\n\t\t\t\t'Kwargs sent as chat_template_kwargs when thinkingFormat is \"chat-template\". Use $var with \"thinking.enabled\", \"thinking.effort\", or \"thinking.budget\" for pi-controlled values.',\n\t\t}),\n\t),\n\tchatTemplateArgs: opt(\n\t\tstringRecord(ChatTemplateKwargValueSchema, {\n\t\t\tdescription:\n\t\t\t\t'Arguments sent as chat_template_args when thinkingFormat is \"baseten\". Use $var with \"thinking.enabled\", \"thinking.effort\", or \"thinking.budget\" for pi-controlled values.',\n\t\t}),\n\t),\n\topenRouterRouting: opt(OpenRouterRoutingSchema),\n\tvercelGatewayRouting: opt(VercelGatewayRoutingSchema),\n\tzaiToolStream: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether z.ai supports top-level tool_stream for streaming tool call deltas.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tthinkingTokenBudgetField: opt(\n\t\tthinkingTokenBudgetField({\n\t\t\tdescription:\n\t\t\t\t'Top-level request field used to cap reasoning tokens from thinkingBudgets. Reasoning and the answer share max_tokens on these endpoints. \"thinking_token_budget\" is vLLM, \"thinking_budget\" is Qwen, DashScope, or SGLang, and \"thinking_budget_tokens\" is llama.cpp. Off by default and not set on the generated catalog.',\n\t\t}),\n\t),\n\tsupportsThinkingTokenBudget: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t'Alias for thinkingTokenBudgetField: \"thinking_token_budget\" (vLLM). Prefer thinkingTokenBudgetField.',\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsOpenAIGrammarTools: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models.\",\n\t\tdefault: false,\n\t}),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system or developer messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models.\",\n\t\tdefault: false,\n\t}),\n\tsupportsMidConvoToolAdditions: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether system messages can introduce additional tools mid-conversation. Requires supportsMidConvoSystemMessages. The generated catalog enables this for capable models.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports the strict field in tool definitions. Generated capable models enable it explicitly.\",\n\t\tdefault: false,\n\t}),\n\tcacheControlFormat: opt(\n\t\tstringLiteral(\"anthropic\", {\n\t\t\tdescription:\n\t\t\t\t\"Cache control convention for prompt caching. Anthropic applies cache_control markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content.\",\n\t\t}),\n\t),\n\tsendSessionAffinityHeaders: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether to send session-affinity data from options.sessionId. Default: true for OpenRouter endpoints, false otherwise.\",\n\t}),\n\tsessionAffinityFormat: optionalSessionAffinityFormat({\n\t\tdescription:\n\t\t\t\"Session-affinity header format. openai sends session_id, x-client-request-id, and x-session-affinity; openai-nosession sends x-client-request-id and x-session-affinity; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected.\",\n\t}),\n\tpromptCacheKeyMode: optionalPromptCacheKeyMode({\n\t\tdescription:\n\t\t\t\"Controls the prompt_cache_key request field. auto sends it to api.openai.com, or with long cache retention when supportsLongCacheRetention is true; enabled sends it whenever caching is active, for compatible proxies; disabled never sends it. Default: auto.\",\n\t}),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t'Whether the provider supports long prompt cache retention (prompt_cache_retention: \"24h\" or Anthropic-style cache_control.ttl: \"1h\", depending on format). Default: auto-detected from provider and URL.',\n\t}),\n\tvllmPriority: opt(\n\t\tnum({\n\t\t\tdescription:\n\t\t\t\t\"vLLM scheduler priority sent as the top-level priority request field. Lower values are handled earlier and the server default is 0. Only meaningful with --scheduling-policy priority. Off by default and not set on the generated catalog.\",\n\t\t}),\n\t),\n};\n\nexport const OpenAICompletionsCompatSchema = openObject(OpenAICompletionsCompatProperties, {\n\tdescription:\n\t\t\"Compatibility settings for OpenAI-compatible completions APIs. Use this to override URL-based auto-detection for custom providers.\",\n\tadditionalProperties: true,\n});\n\nconst OpenAIResponsesCompatProperties = {\n\tsupportsDeveloperRole: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports the developer role instead of system.\",\n\t\tdefault: true,\n\t}),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts developer or system messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models.\",\n\t\tdefault: false,\n\t}),\n\tsessionAffinityFormat: optionalSessionAffinityFormat({\n\t\tdescription:\n\t\t\t\"Session-affinity header format. openai sends session-id and x-client-request-id; openai-nosession sends x-client-request-id; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected.\",\n\t}),\n\tpromptCacheKeyMode: optionalPromptCacheKeyMode({\n\t\tdescription:\n\t\t\t\"Controls the prompt_cache_key request field. auto and enabled send it whenever caching is active; disabled never sends it, for compatible proxies that reject it. Default: auto.\",\n\t}),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t'Whether the provider supports long prompt cache retention. This uses prompt_cache_options.ttl: \"30m\" on GPT-5.6+ and prompt_cache_retention: \"24h\" on earlier models.',\n\t\tdefault: true,\n\t}),\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports strict JSON-schema function tools. Defaults are API-specific; generated OpenAI models enable it explicitly.\",\n\t}),\n\tsupportsOpenAIGrammarTools: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether to emit OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models.\",\n\t\tdefault: false,\n\t}),\n\tsupportsAdditionalTools: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the model supports message-anchored additional_tools input items.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsToolSearch: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the model supports client-executed tool search for transcript-anchored additions.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsExplicitPromptCacheMode: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the model accepts prompt_cache_options. Older OpenAI models reject the parameter.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMidConvoEffort: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Only used by the openai-responses API, and ignored with Sign in with ChatGPT on the openai provider.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMaxOutputTokens: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether the provider accepts max_output_tokens. Some Codex-protocol gateways reject it.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n};\n\nexport const OpenAIResponsesCompatSchema = openObject(OpenAIResponsesCompatProperties, {\n\tdescription: \"Compatibility settings for OpenAI Responses APIs.\",\n\tadditionalProperties: true,\n});\n\nconst AnthropicMessagesCompatProperties = {\n\tsupportsEagerToolInputStreaming: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider accepts per-tool eager_input_streaming. When false, the Anthropic provider omits tools[].eager_input_streaming and sends the legacy fine-grained-tool-streaming-2025-05-14 beta header for tool-enabled requests.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports Anthropic long cache retention through cache_control.ttl.\",\n\t\tdefault: true,\n\t}),\n\tsendSessionAffinityHeaders: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether to send x-session-affinity from options.sessionId when caching is enabled. Required for providers like Fireworks that use session affinity for prompt cache routing; requests to the same replica maximize cache hits. Default: true for OpenRouter endpoints, false otherwise.\",\n\t}),\n\tsessionAffinityFormat: opt(\n\t\tstringLiteral(\"openrouter\", {\n\t\t\tdescription: \"Session-affinity format. openrouter sends x-session-id; when unset, sends x-session-affinity.\",\n\t\t}),\n\t),\n\tsupportsCacheControlOnTools: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider supports Anthropic-style cache_control markers on tool definitions. When false, cache_control is omitted from tool parameters. Some Anthropic-compatible providers, such as Fireworks, do not support this field on tools and may reject or ignore it.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tsupportsTemperature: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the model accepts the Anthropic temperature request field. Claude Opus 4.7+ rejects non-default values.\",\n\t\t\tdefault: true,\n\t\t}),\n\t),\n\tforceAdaptiveThinking: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether to force adaptive thinking (thinking.type: adaptive plus output_config.effort) regardless of model ID. Built-in models that require adaptive thinking set this in generated metadata. Custom Anthropic-compatible providers can set this to true for any model whose upstream requires the adaptive format. Set false to opt out on overridden built-in models.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tallowEmptySignature: opt(\n\t\tbool({\n\t\t\tdescription: \"Whether to replay empty thinking signatures instead of converting thinking to text.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsStrictTools: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the provider supports Anthropic strict tool schemas. Generated Anthropic models enable it explicitly.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMidConvoEffort: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the exact model transport supports effort-only system messages and thinking binding controls.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system-role messages inside the conversation. When false, later system messages are folded into the top-level system prompt.\",\n\t\tdefault: false,\n\t}),\n\tsupportsMidConvoToolChanges: opt(\n\t\tbool({\n\t\t\tdescription:\n\t\t\t\t\"Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages.\",\n\t\t\tdefault: false,\n\t\t}),\n\t),\n\tsupportsMessageThreads: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the endpoint supports Anthropic message threads, which let a request with a session id send only the new messages and continue from the previous reply. Default: true for provider anthropic with a baseUrl on api.anthropic.com, false otherwise. Set true for gateways that forward the thread request field.\",\n\t}),\n\tallowedFallbackModels: opt(\n\t\tarr(AnthropicAllowedFallbackModelSchema, {\n\t\t\tmaxItems: 3,\n\t\t\tdescription:\n\t\t\t\t\"Models Anthropic accepts for server-side refusal fallback, with local pricing metadata for returned fallback responses. When absent or empty, callers must omit fallbacks; Anthropic rejects the field for models with no permitted fallback targets.\",\n\t\t}),\n\t),\n};\n\nexport const AnthropicMessagesCompatSchema = openObject(AnthropicMessagesCompatProperties, {\n\tdescription: \"Compatibility settings for Anthropic Messages-compatible APIs.\",\n\tadditionalProperties: true,\n});\n\nconst BedrockCompatProperties = {\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription: \"Whether the model supports Bedrock strict tool schemas.\",\n\t\tdefault: false,\n\t}),\n};\n\nexport const BedrockCompatSchema = openObject(BedrockCompatProperties, {\n\tdescription: \"Compatibility settings for Amazon Bedrock models.\",\n\tadditionalProperties: true,\n});\n\nconst MistralConversationsCompatProperties = {\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message.\",\n\t\tdefault: false,\n\t}),\n};\n\nexport const MistralConversationsCompatSchema = openObject(MistralConversationsCompatProperties, {\n\tdescription: \"Compatibility settings for the Mistral chat API.\",\n\tadditionalProperties: true,\n});\n\nconst SystemOneCompatProperties = {\n\timageInput: opt(\n\t\tunion([stringLiteral(\"assets\"), stringLiteral(\"images\"), stringLiteral(\"state-image-urls\")], {\n\t\t\tdescription:\n\t\t\t\t'How the service takes classifier images. \"assets\" sends TypeSafe\\'s assets map (PNG and JPEG) and references the images from the state, as TypeSafe and Jev on Workers AI expect. \"images\" sends Clef\\'s images list of data URLs (PNG, JPEG, and WebP, at most four), as Clef on Workers AI expects. \"state-image-urls\" places image_url parts before the state, as OpenRouter expects; OpenRouter drops assets without an error. Auto-detected from the provider, baseUrl, and model ID. Classifier models read it from the provider-level compat; models and modelOverrides entries apply to chat models only.',\n\t\t}),\n\t),\n\tsendImageOptInHeader: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether requests with images send the TypeSafe-Danger-Zone-Images: true header, which TypeSafe's own API requires for its experimental image input. Defaults to true for the typesafe-system-one API unless the model is detected as OpenRouter.\",\n\t}),\n};\n\nexport const SystemOneCompatSchema = openObject(SystemOneCompatProperties, {\n\tdescription: \"Compatibility settings for System One classifier APIs.\",\n\tadditionalProperties: true,\n});\n\nconst ProviderCompatPropertyOverrides = {\n\tsupportsDeveloperRole: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports the developer role instead of system. Defaults are API-specific.\",\n\t}),\n\tsupportsMidConvoSystemMessages: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the exact model accepts system or developer messages after the conversation has started. When false, later system messages are folded into the leading system message.\",\n\t\tdefault: false,\n\t}),\n\tsessionAffinityFormat: optionalSessionAffinityFormat({\n\t\tdescription: \"Session-affinity header format. Defaults are API-specific or auto-detected.\",\n\t}),\n\tpromptCacheKeyMode: optionalPromptCacheKeyMode({\n\t\tdescription:\n\t\t\t\"Controls the prompt_cache_key request field for openai-completions and openai-responses: auto keeps each API's default, enabled sends it whenever caching is active, disabled never sends it. Default: auto.\",\n\t}),\n\tsupportsMidConvoEffort: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages and openai-responses APIs.\",\n\t\tdefault: false,\n\t}),\n\tsupportsLongCacheRetention: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports long prompt cache retention. Defaults are API-specific or auto-detected.\",\n\t}),\n\tsupportsStrictMode: optionalCompatBoolean({\n\t\tdescription: \"Whether the provider supports strict tool schemas. Defaults are API-specific.\",\n\t}),\n\tsupportsOpenAIGrammarTools: optionalCompatBoolean({\n\t\tdescription:\n\t\t\t\"Whether the provider supports OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools.\",\n\t\tdefault: false,\n\t}),\n\tsendSessionAffinityHeaders: optionalCompatBoolean({\n\t\tdescription: \"Whether to send session-affinity data from options.sessionId. Defaults are API-specific.\",\n\t}),\n} satisfies Properties;\n\ntype UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (\n\tvalue: infer Intersection,\n) => void\n\t? Intersection\n\t: never;\n\ntype MergedCompatProperties<PropertyGroups extends readonly Properties[], Overrides extends Properties> = Omit<\n\tUnionToIntersection<PropertyGroups[number]>,\n\tkeyof Overrides\n> &\n\tOverrides;\n\n/**\n * Provider-level models.json compatibility is API-agnostic, so it needs one superset. Every\n * duplicate property requires explicit generic metadata, while API-specific schemas retain their\n * own defaults and descriptions.\n */\nfunction mergeCompatProperties<const PropertyGroups extends readonly Properties[], const Overrides extends Properties>(\n\tpropertyGroups: PropertyGroups,\n\toverrides: Overrides,\n): MergedCompatProperties<PropertyGroups, Overrides> {\n\tconst merged: Record<string, Properties[string]> = {};\n\tconst duplicateNames = new Set<string>();\n\n\tfor (const properties of propertyGroups) {\n\t\tfor (const [name, schema] of Object.entries(properties)) {\n\t\t\tif (merged[name] !== undefined) {\n\t\t\t\tduplicateNames.add(name);\n\t\t\t\tif (!(name in overrides)) {\n\t\t\t\t\tthrow new Error(`Duplicate compatibility schema property requires an override: ${name}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmerged[name] = schema;\n\t\t}\n\t}\n\n\tfor (const name of Object.keys(overrides)) {\n\t\tif (!duplicateNames.has(name)) {\n\t\t\tthrow new Error(`Compatibility schema override does not resolve a duplicate property: ${name}`);\n\t\t}\n\t}\n\n\treturn { ...merged, ...overrides } as MergedCompatProperties<PropertyGroups, Overrides>;\n}\n\n/** Compatibility schema for each API whose models accept compat. Mirrors the compat type of Model. */\nexport const CompatSchemasByApi = {\n\t\"openai-completions\": OpenAICompletionsCompatSchema,\n\t\"openai-responses\": OpenAIResponsesCompatSchema,\n\t\"azure-openai-responses\": OpenAIResponsesCompatSchema,\n\t\"openai-codex-responses\": OpenAIResponsesCompatSchema,\n\t\"anthropic-messages\": AnthropicMessagesCompatSchema,\n\t\"bedrock-converse-stream\": BedrockCompatSchema,\n\t\"mistral-conversations\": MistralConversationsCompatSchema,\n\t\"typesafe-system-one\": SystemOneCompatSchema,\n\t\"cloudflare-workers-ai-system-one\": SystemOneCompatSchema,\n} as const;\n\nconst ProviderCompatProperties = mergeCompatProperties(\n\t[\n\t\tOpenAICompletionsCompatProperties,\n\t\tOpenAIResponsesCompatProperties,\n\t\tAnthropicMessagesCompatProperties,\n\t\tBedrockCompatProperties,\n\t\tMistralConversationsCompatProperties,\n\t\tSystemOneCompatProperties,\n\t],\n\tProviderCompatPropertyOverrides,\n);\n\nexport const ProviderCompatSchema = openObject(ProviderCompatProperties, {\n\tdescription: \"Provider and model compatibility overrides.\",\n\tadditionalProperties: true,\n});\n\nexport type ChatTemplateKwargValue = Static<typeof ChatTemplateKwargValueSchema>;\n/** Provider and model compatibility overrides in models.json: every API's compat fields. */\nexport type ProviderCompat = Static<typeof ProviderCompatSchema>;\n/** Top-level request field used to cap reasoning tokens on OpenAI-compatible servers. */\nexport type ThinkingTokenBudgetField = Static<typeof ThinkingTokenBudgetFieldSchema>;\nexport type SessionAffinityFormat = Static<typeof SessionAffinityFormatSchema>;\n/** OpenRouter provider routing preferences. */\nexport interface OpenRouterRouting extends Static<typeof OpenRouterRoutingSchema> {}\n/** Vercel AI Gateway routing preferences. */\nexport interface VercelGatewayRouting extends Static<typeof VercelGatewayRoutingSchema> {}\n/** An Anthropic server-side refusal fallback model with local pricing metadata. */\nexport interface AnthropicAllowedFallbackModel extends Static<typeof AnthropicAllowedFallbackModelSchema> {}\n\n/** Compatibility settings for OpenAI-compatible completions APIs. */\nexport interface OpenAICompletionsCompat extends Static<typeof OpenAICompletionsCompatSchema> {}\n/** Compatibility settings for OpenAI Responses APIs. */\nexport interface OpenAIResponsesCompat extends Static<typeof OpenAIResponsesCompatSchema> {}\n/** Compatibility settings for Anthropic Messages-compatible APIs. */\nexport interface AnthropicMessagesCompat extends Static<typeof AnthropicMessagesCompatSchema> {}\n/** Compatibility settings for Amazon Bedrock models. */\nexport interface BedrockCompat extends Static<typeof BedrockCompatSchema> {}\n/** Compatibility settings for the Mistral chat API. */\nexport interface MistralConversationsCompat extends Static<typeof MistralConversationsCompatSchema> {}\n/** Compatibility settings for System One classifier APIs. */\nexport interface SystemOneCompat extends Static<typeof SystemOneCompatSchema> {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":6,"generatedAt":"2026-11-
|
|
1
|
+
{"schemaVersion":6,"generatedAt":"2026-11-09T23:25:56.588Z","structureHash":"41a915f23fa68b19c1c217002ee1a5042f9ef456c69dc92d67248a3b8c5d988e","files":{"amazon-bedrock.json":"18a99dd3faf5b38a1b1a781676a5b9c76c90c8547ffe6c2637d2d65eaef34e45","ant-ling.json":"628feab3ef6c7d80ce96f75999804e1d9f05fec3851e5302e30fff3b69db90f6","anthropic.json":"ebd207ed51603e2060b870bef72c86e9de02d3a14f78bd9813f2de0db27dbdef","azure.json":"7a427b902bafd502dd52442768ad1f41fa9cdfe0bc1f136eae53029816390a24","baseten.json":"a233b3a38939358b3268ebde5bafa16da0e5d5393209e36ce2dc539e38dde546","cerebras.json":"2eb969b2956844f9a641d3de52c19f1791293c58f607282fb3b0ebfe85ff66f8","cloudflare-ai-gateway.json":"fabc979d62c7c8503d5b186e5fb7267e3d008d7b5a3091d62c3decd6baa8972b","cloudflare-workers-ai.json":"0dc5eda87ff6de3ee75ee6d547a60162319bb2d51ed09b1e7d47d8ae9ef8548e","deepseek.json":"10a296fb3e898f7715c80890c8af0af4f5fd58f22dbcd6612fdc5d762157ccdc","fireworks.json":"d955cb73bb7fbab137f9d5532cf865999484b7a43d0e06cdc4561c90e9048476","github-copilot.json":"075f19a4019990cd22b3439730638b7944db696d528f59e3dbee280a0de50401","google-vertex.json":"bc32e24bfd8ab0caedda4c11a7527a1dcc7f783ff5326ce4c72a13bd7ab47d9b","google.json":"32b760a0b75e98208ba633456234f3cf733331e4b7b7f1d756d4341917d287f9","groq.json":"087df37206e9eed8b10f1e558e4c496289bef60074b7e8afba4f20fb102b4ec2","huggingface.json":"cf34e226723c542afc4d024a1b1270b911738410dc5cf706fef5d9d4a0e08171","kimi-coding.json":"04e7914391e8e986d04b5cc8f84c49267d148a53a2d92bf968b7570dd8ff09b9","meta.json":"563f5ec07973f52ab8c3eb26ef91a36ad8a79e950b37174935666cdcb624bf35","minimax-cn.json":"fa15d1f67a07046d38e191af9bd97ed922ba45a99a11af4ad281151cc6b762aa","minimax.json":"1e0459dda3858ea24151182106fc4179b95f43a0a8dffc1c3d2e7db4c2d9206e","mistral.json":"013b34618e8f9a3968e0442e7e1339cc2a1bbad467f04bab0b8589a9c451b780","moonshotai-cn.json":"1a15468b1edf9205956e4c5ea41fc4cacc14eabf00523b9143e23a38264f57f7","moonshotai.json":"f31cdf2e6c81a403c4cb0e6b7e759ceff2820f966b08dbec80cfafa3f80dfc63","nvidia.json":"2a6a5fa3c0e256ce19878daf4f0ba1166dbd4ab418d9e2d1076d23ab8996a3b7","openai-codex.json":"dd30453068f310317abf35d9adc6d841339a1351f0c6925a6aff45d975e0257c","openai.json":"df2fe1f312051bbe29801ef903ab370c701a74a680f1370e96eb465eacd1d82d","opencode-go.json":"2e8f20182913cec36586a84ea6392f998e4f5897e1a824a36b3ea8a943d21639","opencode.json":"666c091a5f6910a3ca954259ad051ef18d587164e26e23a95474a1861f913909","openrouter.json":"a4c430cdde3802b5d503314ee60d5c5b43b8aceededa083e93ac9a376c13f1bb","qwen-token-plan-cn.json":"80824536f0c3cd83ab27424df2d664738cbe3f971b4e568a625432288fa53229","qwen-token-plan-individual-cn.json":"fb74899c770572efbb27eb8d3398a07edaa4d62229655f9a0702ae01af22ac95","qwen-token-plan-individual.json":"f83c5ae4dce709924ad03a10c5f9c09a42b3670cb6ee2ed32590b9e0fcbaf8a9","qwen-token-plan.json":"0630bf7fea9d8579c7ac990e32c40c3685f9db20b6dbfaf745b361fe5203113c","radius.json":"1fc91013e9f45ecffc6f0ad8a7e339263561c7be671c27a12f78c0daf56111d1","together.json":"e421d8042975509d5b73eb3bb8f1612b9ee6b7c3764a3a6aa4866bc1ba661bd0","typesafe.json":"631b03f70597ad656e8f45a393ab46bd4137459b9b499708ac3d5d9d9decd3f2","vercel-ai-gateway.json":"a90d060732f3eb184aaabce38de955898782d2d2c6a28ece404c5544131d6ce7","xai.json":"db408985a02980ba9d30f359b4f394a7d088cc75e26bd4bef30aecb43077771b","xiaomi-token-plan-ams.json":"34fe47b0a79fec7843a01d542cb64b736e651a3e6691cc851183e5ce3eae0118","xiaomi-token-plan-cn.json":"e69f9704b450dbb34b6db61a7b224dab5e5a91a39af3e505ecca4db8bfdc04f0","xiaomi-token-plan-sgp.json":"fd28cc293208617127ff888873772b7b52160538caa07ca3af641f3208d3ad20","xiaomi.json":"65bc04b2ab6c9e97594de34bcea4ef7e45befd87901b4208d1ea4142b93f0561","zai-coding-cn.json":"b335901611ad018680e5bb7fe7ba12a9f1be28e9d1530c783cbd6f4567a29a92","zai.json":"08b29b02416c26f0c1a219492fa7f9b23bdb90ef4e9f7693800b9e670dcc5860"}}
|