@fractaal/pi-ai 1.4.1 → 1.6.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.
- package/README.md +50 -34
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +224 -27
- 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 +54 -25
- 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 +4 -0
- package/dist/api/constrained-sampling.d.ts.map +1 -1
- package/dist/api/constrained-sampling.js +18 -0
- 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 +10 -3
- 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/pi-messages.d.ts.map +1 -1
- package/dist/api/pi-messages.js +9 -0
- package/dist/api/pi-messages.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/auth/oauth/github-copilot.d.ts.map +1 -1
- package/dist/auth/oauth/github-copilot.js +4 -11
- package/dist/auth/oauth/github-copilot.js.map +1 -1
- package/dist/auth/oauth/kimi-coding.d.ts.map +1 -1
- package/dist/auth/oauth/kimi-coding.js +4 -22
- package/dist/auth/oauth/kimi-coding.js.map +1 -1
- 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/auth/oauth/meta.d.ts.map +1 -1
- package/dist/auth/oauth/meta.js +1 -14
- package/dist/auth/oauth/meta.js.map +1 -1
- package/dist/auth/oauth/radius.d.ts.map +1 -1
- package/dist/auth/oauth/radius.js +9 -3
- package/dist/auth/oauth/radius.js.map +1 -1
- package/dist/auth/oauth/trusted-url.d.ts +7 -0
- package/dist/auth/oauth/trusted-url.d.ts.map +1 -0
- package/dist/auth/oauth/trusted-url.js +12 -0
- package/dist/auth/oauth/trusted-url.js.map +1 -0
- package/dist/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- 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 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- 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.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 +5 -1
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +8 -8
- 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/amazon-bedrock.models.js +1 -1
- package/dist/providers/amazon-bedrock.models.js.map +1 -1
- package/dist/providers/ant-ling.models.js +1 -1
- package/dist/providers/ant-ling.models.js.map +1 -1
- package/dist/providers/anthropic.models.js +1 -1
- package/dist/providers/anthropic.models.js.map +1 -1
- package/dist/providers/azure.models.js +1 -1
- package/dist/providers/azure.models.js.map +1 -1
- package/dist/providers/baseten.models.js +1 -1
- package/dist/providers/baseten.models.js.map +1 -1
- package/dist/providers/cerebras.models.js +1 -1
- package/dist/providers/cerebras.models.js.map +1 -1
- package/dist/providers/cloudflare-ai-gateway.models.js +1 -1
- package/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
- package/dist/providers/cloudflare-workers-ai.models.js +1 -1
- package/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +441 -456
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +163 -112
- 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/cloudflare-workers-ai.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-vertex.json +1 -1
- package/dist/providers/data/google.json +1 -1
- package/dist/providers/data/huggingface.json +1 -1
- package/dist/providers/data/kimi-coding.json +1 -1
- package/dist/providers/data/mistral.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/openai-codex.json +1 -1
- package/dist/providers/data/openai.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-cn.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/qwen-token-plan.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/data/xai.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/providers/data/xiaomi.json +1 -1
- package/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/providers/data/zai.json +1 -1
- package/dist/providers/deepseek.models.js +1 -1
- package/dist/providers/deepseek.models.js.map +1 -1
- package/dist/providers/fireworks.models.js +1 -1
- package/dist/providers/fireworks.models.js.map +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/github-copilot.models.js +1 -1
- package/dist/providers/github-copilot.models.js.map +1 -1
- package/dist/providers/google-vertex.models.js +1 -1
- package/dist/providers/google-vertex.models.js.map +1 -1
- package/dist/providers/google.models.js +1 -1
- package/dist/providers/google.models.js.map +1 -1
- package/dist/providers/groq.models.js +1 -1
- package/dist/providers/groq.models.js.map +1 -1
- package/dist/providers/huggingface.models.js +1 -1
- package/dist/providers/huggingface.models.js.map +1 -1
- package/dist/providers/kimi-coding.models.js +1 -1
- package/dist/providers/kimi-coding.models.js.map +1 -1
- package/dist/providers/meta.models.js +1 -1
- package/dist/providers/meta.models.js.map +1 -1
- package/dist/providers/minimax-cn.models.js +1 -1
- package/dist/providers/minimax-cn.models.js.map +1 -1
- package/dist/providers/minimax.models.js +1 -1
- package/dist/providers/minimax.models.js.map +1 -1
- package/dist/providers/mistral.models.js +1 -1
- package/dist/providers/mistral.models.js.map +1 -1
- package/dist/providers/model-schema.d.ts +65 -65
- package/dist/providers/model-schema.d.ts.map +1 -1
- package/dist/providers/model-schema.js +41 -30
- package/dist/providers/model-schema.js.map +1 -1
- package/dist/providers/moonshotai-cn.models.js +1 -1
- package/dist/providers/moonshotai-cn.models.js.map +1 -1
- package/dist/providers/moonshotai.models.js +1 -1
- package/dist/providers/moonshotai.models.js.map +1 -1
- package/dist/providers/nvidia.models.js +1 -1
- package/dist/providers/nvidia.models.js.map +1 -1
- package/dist/providers/openai-codex-catalog.d.ts.map +1 -1
- package/dist/providers/openai-codex-catalog.js +44 -44
- package/dist/providers/openai-codex-catalog.js.map +1 -1
- package/dist/providers/openai-codex.models.js +1 -1
- package/dist/providers/openai-codex.models.js.map +1 -1
- package/dist/providers/openai.models.js +1 -1
- package/dist/providers/openai.models.js.map +1 -1
- package/dist/providers/opencode-go.models.js +1 -1
- package/dist/providers/opencode-go.models.js.map +1 -1
- package/dist/providers/opencode.js +1 -1
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/opencode.models.js +1 -1
- package/dist/providers/opencode.models.js.map +1 -1
- package/dist/providers/openrouter.models.js +1 -1
- package/dist/providers/openrouter.models.js.map +1 -1
- package/dist/providers/qwen-token-plan-cn.models.js +1 -1
- package/dist/providers/qwen-token-plan-cn.models.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/providers/qwen-token-plan-individual.models.js +1 -1
- package/dist/providers/qwen-token-plan-individual.models.js.map +1 -1
- package/dist/providers/qwen-token-plan.models.js +1 -1
- package/dist/providers/qwen-token-plan.models.js.map +1 -1
- package/dist/providers/radius.models.js +1 -1
- package/dist/providers/radius.models.js.map +1 -1
- package/dist/providers/schema-builders.d.ts +10 -0
- package/dist/providers/schema-builders.d.ts.map +1 -0
- package/dist/providers/schema-builders.js +18 -0
- package/dist/providers/schema-builders.js.map +1 -0
- package/dist/providers/together.models.js +1 -1
- package/dist/providers/together.models.js.map +1 -1
- package/dist/providers/typesafe.models.js +1 -1
- package/dist/providers/typesafe.models.js.map +1 -1
- package/dist/providers/vercel-ai-gateway.models.js +1 -1
- package/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/dist/providers/xai.models.js +1 -1
- package/dist/providers/xai.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-ams.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-cn.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
- package/dist/providers/xiaomi.models.js +1 -1
- package/dist/providers/xiaomi.models.js.map +1 -1
- package/dist/providers/zai-coding-cn.models.js +1 -1
- package/dist/providers/zai-coding-cn.models.js.map +1 -1
- package/dist/providers/zai.models.js +1 -1
- package/dist/providers/zai.models.js.map +1 -1
- package/dist/types.d.ts +13 -3
- 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/overflow.d.ts.map +1 -1
- package/dist/utils/overflow.js +2 -0
- package/dist/utils/overflow.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/{typebox-helpers.d.ts → string-enum.d.ts} +5 -5
- package/dist/utils/string-enum.d.ts.map +1 -0
- package/dist/utils/{typebox-helpers.js → string-enum.js} +5 -6
- package/dist/utils/string-enum.js.map +1 -0
- package/dist/utils/transcript.d.ts +1 -1
- package/dist/utils/transcript.js +1 -1
- package/dist/utils/transcript.js.map +1 -1
- package/dist/utils/validation.d.ts +5 -3
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +25 -446
- package/dist/utils/validation.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 +18 -9
- package/dist/utils/typebox-helpers.d.ts.map +0 -1
- package/dist/utils/typebox-helpers.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat-schema.d.ts","sourceRoot":"","sources":["../../src/providers/compat-schema.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,4BAA4B;;;SAavC,CAAC;AAWH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuFnC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;EAkBtC,CAAC;AAEF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;EAO/C,CAAC;AAqLF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIxC,CAAC;AAmEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;EAGtC,CAAC;AAyFH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGxC,CAAC;AASH,eAAO,MAAM,mBAAmB;;EAG9B,CAAC;AAUH,eAAO,MAAM,gCAAgC;;EAG3C,CAAC;AAeH,eAAO,MAAM,qBAAqB;;;EAGhC,CAAC;AAqFH,sGAAsG;AACtG,eAAO,MAAM,kBAAkB;aAC9B,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACpB,kBAAkB;;;;;;;;;;;;;;aAClB,wBAAwB;;;;;;;;;;;;;;aACxB,wBAAwB;;;;;;;;;;;;;;aACxB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACpB,yBAAyB;;;aACzB,uBAAuB;;;aACvB,qBAAqB;;;;aACrB,kCAAkC;;;;CACzB,CAAC;AAcX,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG/B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACjF,4FAA4F;AAC5F,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACjE,yFAAyF;AACzF,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACrF,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAC/E,+CAA+C;AAC/C,MAAM,WAAW,iBAAkB,SAAQ,MAAM,CAAC,OAAO,uBAAuB,CAAC;CAAG;AACpF,6CAA6C;AAC7C,MAAM,WAAW,oBAAqB,SAAQ,MAAM,CAAC,OAAO,0BAA0B,CAAC;CAAG;AAC1F,mFAAmF;AACnF,MAAM,WAAW,6BAA8B,SAAQ,MAAM,CAAC,OAAO,mCAAmC,CAAC;CAAG;AAE5G,qEAAqE;AACrE,MAAM,WAAW,uBAAwB,SAAQ,MAAM,CAAC,OAAO,6BAA6B,CAAC;CAAG;AAChG,wDAAwD;AACxD,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,OAAO,2BAA2B,CAAC;CAAG;AAC5F,qEAAqE;AACrE,MAAM,WAAW,uBAAwB,SAAQ,MAAM,CAAC,OAAO,6BAA6B,CAAC;CAAG;AAChG,wDAAwD;AACxD,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,OAAO,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"}
|
|
@@ -1,66 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { arr, bool, nul, num, opt, str, union, } from "@earendil-works/pi-schema";
|
|
2
2
|
import { ModelCostSchema } from "./model-schema.js";
|
|
3
|
+
import { openObject, stringLiteral, stringRecord } from "./schema-builders.js";
|
|
3
4
|
function sessionAffinityFormat(options) {
|
|
4
|
-
return
|
|
5
|
+
return union([stringLiteral("openai"), stringLiteral("openai-nosession"), stringLiteral("openrouter")], options);
|
|
5
6
|
}
|
|
6
7
|
export const SessionAffinityFormatSchema = sessionAffinityFormat({
|
|
7
8
|
description: "Session-affinity header format used to route related requests consistently.",
|
|
8
9
|
});
|
|
9
10
|
function thinkingTokenBudgetField(options) {
|
|
10
|
-
return
|
|
11
|
+
return union([
|
|
12
|
+
stringLiteral("thinking_token_budget"),
|
|
13
|
+
stringLiteral("thinking_budget"),
|
|
14
|
+
stringLiteral("thinking_budget_tokens"),
|
|
15
|
+
], options);
|
|
11
16
|
}
|
|
12
17
|
export const ThinkingTokenBudgetFieldSchema = thinkingTokenBudgetField({
|
|
13
18
|
description: '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.',
|
|
14
19
|
});
|
|
15
|
-
export const ChatTemplateKwargValueSchema =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
$var:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
export const ChatTemplateKwargValueSchema = union([
|
|
21
|
+
str(),
|
|
22
|
+
num(),
|
|
23
|
+
bool(),
|
|
24
|
+
nul(),
|
|
25
|
+
openObject({
|
|
26
|
+
$var: union([
|
|
27
|
+
stringLiteral("thinking.enabled"),
|
|
28
|
+
stringLiteral("thinking.effort"),
|
|
29
|
+
stringLiteral("thinking.budget"),
|
|
25
30
|
]),
|
|
26
|
-
omitWhenOff:
|
|
31
|
+
omitWhenOff: opt(bool()),
|
|
27
32
|
}),
|
|
28
33
|
]);
|
|
29
34
|
function percentileCutoffs(metric) {
|
|
30
|
-
return
|
|
31
|
-
p50:
|
|
32
|
-
p75:
|
|
33
|
-
p90:
|
|
34
|
-
p99:
|
|
35
|
+
return openObject({
|
|
36
|
+
p50: opt(num({ description: `${metric} at the 50th percentile.` })),
|
|
37
|
+
p75: opt(num({ description: `${metric} at the 75th percentile.` })),
|
|
38
|
+
p90: opt(num({ description: `${metric} at the 90th percentile.` })),
|
|
39
|
+
p99: opt(num({ description: `${metric} at the 99th percentile.` })),
|
|
35
40
|
});
|
|
36
41
|
}
|
|
37
|
-
export const OpenRouterRoutingSchema =
|
|
38
|
-
allow_fallbacks:
|
|
39
|
-
require_parameters:
|
|
42
|
+
export const OpenRouterRoutingSchema = openObject({
|
|
43
|
+
allow_fallbacks: opt(bool({ description: "Whether to allow backup providers to serve requests.", default: true })),
|
|
44
|
+
require_parameters: opt(bool({
|
|
40
45
|
description: "Whether to filter providers to only those that support all parameters in the request.",
|
|
41
46
|
default: false,
|
|
42
47
|
})),
|
|
43
|
-
data_collection:
|
|
48
|
+
data_collection: opt(union([stringLiteral("deny"), stringLiteral("allow")], {
|
|
44
49
|
description: 'Data collection setting. "allow": allow providers that may store or train on data. "deny": only use providers that do not collect user data.',
|
|
45
50
|
default: "allow",
|
|
46
51
|
})),
|
|
47
|
-
zdr:
|
|
48
|
-
enforce_distillable_text:
|
|
49
|
-
order:
|
|
52
|
+
zdr: opt(bool({ description: "Whether to restrict routing to only ZDR (Zero Data Retention) endpoints." })),
|
|
53
|
+
enforce_distillable_text: opt(bool({ description: "Whether to restrict routing to only models that allow text distillation." })),
|
|
54
|
+
order: opt(arr(str(), {
|
|
50
55
|
description: "An ordered list of provider names or slugs to try in sequence, falling back to the next if unavailable.",
|
|
51
56
|
})),
|
|
52
|
-
only:
|
|
57
|
+
only: opt(arr(str(), {
|
|
53
58
|
description: "List of provider names or slugs to exclusively allow for this request.",
|
|
54
59
|
})),
|
|
55
|
-
ignore:
|
|
56
|
-
quantizations:
|
|
60
|
+
ignore: opt(arr(str(), { description: "List of provider names or slugs to skip for this request." })),
|
|
61
|
+
quantizations: opt(arr(str(), {
|
|
57
62
|
description: 'A list of quantization levels to filter providers by, for example ["fp16", "bf16", "fp8", "fp6", "int8", "int4", "fp4", "fp32"].',
|
|
58
63
|
})),
|
|
59
|
-
sort:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
by:
|
|
63
|
-
partition:
|
|
64
|
+
sort: opt(union([
|
|
65
|
+
str(),
|
|
66
|
+
openObject({
|
|
67
|
+
by: opt(str({ description: 'The sorting metric, such as "price", "throughput", or "latency".' })),
|
|
68
|
+
partition: opt(union([str(), nul()], {
|
|
64
69
|
description: 'Partitioning strategy: "model" or "none".',
|
|
65
70
|
default: "model",
|
|
66
71
|
})),
|
|
@@ -68,105 +73,111 @@ export const OpenRouterRoutingSchema = Type.Object({
|
|
|
68
73
|
], {
|
|
69
74
|
description: 'Sorting strategy. Can be a string such as "price", "throughput", or "latency", or an object.',
|
|
70
75
|
})),
|
|
71
|
-
max_price:
|
|
72
|
-
prompt:
|
|
73
|
-
completion:
|
|
74
|
-
image:
|
|
75
|
-
audio:
|
|
76
|
-
request:
|
|
76
|
+
max_price: opt(openObject({
|
|
77
|
+
prompt: opt(union([num(), str()], { description: "Price per million prompt tokens." })),
|
|
78
|
+
completion: opt(union([num(), str()], { description: "Price per million completion tokens." })),
|
|
79
|
+
image: opt(union([num(), str()], { description: "Price per image." })),
|
|
80
|
+
audio: opt(union([num(), str()], { description: "Price per audio unit." })),
|
|
81
|
+
request: opt(union([num(), str()], { description: "Price per request." })),
|
|
77
82
|
}, { description: "Maximum price per million tokens in USD." })),
|
|
78
|
-
preferred_min_throughput:
|
|
83
|
+
preferred_min_throughput: opt(union([num(), percentileCutoffs("Minimum tokens per second")], {
|
|
79
84
|
description: "Preferred minimum throughput in tokens per second. A number applies to p50.",
|
|
80
85
|
})),
|
|
81
|
-
preferred_max_latency:
|
|
86
|
+
preferred_max_latency: opt(union([num(), percentileCutoffs("Maximum latency in seconds")], {
|
|
82
87
|
description: "Preferred maximum latency in seconds. A number applies to p50.",
|
|
83
88
|
})),
|
|
84
89
|
}, {
|
|
85
90
|
description: "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.",
|
|
86
91
|
});
|
|
87
|
-
export const VercelGatewayRoutingSchema =
|
|
88
|
-
only:
|
|
92
|
+
export const VercelGatewayRoutingSchema = openObject({
|
|
93
|
+
only: opt(arr(str(), {
|
|
89
94
|
description: 'List of provider slugs to exclusively use for this request, for example ["bedrock", "anthropic"].',
|
|
90
95
|
})),
|
|
91
|
-
order:
|
|
96
|
+
order: opt(arr(str(), {
|
|
92
97
|
description: 'List of provider slugs to try in order, for example ["anthropic", "openai"].',
|
|
93
98
|
})),
|
|
94
99
|
}, {
|
|
95
100
|
description: "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.",
|
|
96
101
|
});
|
|
97
|
-
export const AnthropicAllowedFallbackModelSchema =
|
|
98
|
-
provider:
|
|
99
|
-
model:
|
|
102
|
+
export const AnthropicAllowedFallbackModelSchema = openObject({
|
|
103
|
+
provider: str({ minLength: 1 }),
|
|
104
|
+
model: str({ minLength: 1 }),
|
|
100
105
|
cost: ModelCostSchema,
|
|
101
106
|
}, { description: "An Anthropic server-side refusal fallback model with local pricing metadata." });
|
|
102
107
|
function optionalCompatBoolean(options) {
|
|
103
|
-
return
|
|
108
|
+
return opt(bool(options));
|
|
104
109
|
}
|
|
105
110
|
function optionalSessionAffinityFormat(options) {
|
|
106
|
-
return
|
|
111
|
+
return opt(sessionAffinityFormat(options));
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
function optionalPromptCacheKeyMode(options) {
|
|
114
|
+
return opt(union([stringLiteral("auto"), stringLiteral("enabled"), stringLiteral("disabled")], options));
|
|
115
|
+
}
|
|
116
|
+
const OpenAICompletionsCompatProperties = {
|
|
117
|
+
supportsStore: opt(bool({
|
|
110
118
|
description: "Whether the provider supports the store field. Default: auto-detected from URL.",
|
|
111
119
|
})),
|
|
112
120
|
supportsDeveloperRole: optionalCompatBoolean({
|
|
113
121
|
description: "Whether the provider supports the developer role instead of system. Default: auto-detected from URL.",
|
|
114
122
|
}),
|
|
115
|
-
supportsReasoningEffort:
|
|
123
|
+
supportsReasoningEffort: opt(bool({
|
|
116
124
|
description: "Whether the provider supports reasoning_effort. Default: auto-detected from URL.",
|
|
117
125
|
})),
|
|
118
|
-
supportsUsageInStreaming:
|
|
126
|
+
supportsUsageInStreaming: opt(bool({
|
|
119
127
|
description: "Whether the provider supports stream_options.include_usage for token usage in streaming responses.",
|
|
120
128
|
default: true,
|
|
121
129
|
})),
|
|
122
|
-
supportsFinishReason:
|
|
130
|
+
supportsFinishReason: opt(bool({
|
|
123
131
|
description: "Whether streamed responses include finish_reason. When false, pi infers stop or toolUse when the stream ends.",
|
|
124
132
|
default: true,
|
|
125
133
|
})),
|
|
126
|
-
maxTokensField:
|
|
134
|
+
maxTokensField: opt(union([stringLiteral("max_completion_tokens"), stringLiteral("max_tokens")], {
|
|
127
135
|
description: "Which field to use for max tokens. Default: auto-detected from URL.",
|
|
128
136
|
})),
|
|
129
|
-
requiresToolResultName:
|
|
130
|
-
requiresAssistantAfterToolResult:
|
|
137
|
+
requiresToolResultName: opt(bool({ description: "Whether tool results require the name field. Default: auto-detected from URL." })),
|
|
138
|
+
requiresAssistantAfterToolResult: opt(bool({
|
|
131
139
|
description: "Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL.",
|
|
132
140
|
})),
|
|
133
|
-
|
|
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
|
+
requiresThinkingAsText: opt(bool({
|
|
134
145
|
description: "Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL.",
|
|
135
146
|
})),
|
|
136
|
-
requiresReasoningContentOnAssistantMessages:
|
|
147
|
+
requiresReasoningContentOnAssistantMessages: opt(bool({
|
|
137
148
|
description: "Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL.",
|
|
138
149
|
})),
|
|
139
|
-
thinkingFormat:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
thinkingFormat: opt(union([
|
|
151
|
+
stringLiteral("openai"),
|
|
152
|
+
stringLiteral("openrouter"),
|
|
153
|
+
stringLiteral("deepseek"),
|
|
154
|
+
stringLiteral("together"),
|
|
155
|
+
stringLiteral("baseten"),
|
|
156
|
+
stringLiteral("zai"),
|
|
157
|
+
stringLiteral("qwen"),
|
|
158
|
+
stringLiteral("chat-template"),
|
|
159
|
+
stringLiteral("qwen-chat-template"),
|
|
160
|
+
stringLiteral("string-thinking"),
|
|
161
|
+
stringLiteral("ant-ling"),
|
|
151
162
|
], {
|
|
152
163
|
description: '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.',
|
|
153
164
|
})),
|
|
154
|
-
chatTemplateKwargs:
|
|
165
|
+
chatTemplateKwargs: opt(stringRecord(ChatTemplateKwargValueSchema, {
|
|
155
166
|
description: '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.',
|
|
156
167
|
})),
|
|
157
|
-
chatTemplateArgs:
|
|
168
|
+
chatTemplateArgs: opt(stringRecord(ChatTemplateKwargValueSchema, {
|
|
158
169
|
description: 'Arguments sent as chat_template_args when thinkingFormat is "baseten". Use $var with "thinking.enabled", "thinking.effort", or "thinking.budget" for pi-controlled values.',
|
|
159
170
|
})),
|
|
160
|
-
openRouterRouting:
|
|
161
|
-
vercelGatewayRouting:
|
|
162
|
-
zaiToolStream:
|
|
171
|
+
openRouterRouting: opt(OpenRouterRoutingSchema),
|
|
172
|
+
vercelGatewayRouting: opt(VercelGatewayRoutingSchema),
|
|
173
|
+
zaiToolStream: opt(bool({
|
|
163
174
|
description: "Whether z.ai supports top-level tool_stream for streaming tool call deltas.",
|
|
164
175
|
default: false,
|
|
165
176
|
})),
|
|
166
|
-
thinkingTokenBudgetField:
|
|
177
|
+
thinkingTokenBudgetField: opt(thinkingTokenBudgetField({
|
|
167
178
|
description: '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.',
|
|
168
179
|
})),
|
|
169
|
-
supportsThinkingTokenBudget:
|
|
180
|
+
supportsThinkingTokenBudget: opt(bool({
|
|
170
181
|
description: 'Alias for thinkingTokenBudgetField: "thinking_token_budget" (vLLM). Prefer thinkingTokenBudgetField.',
|
|
171
182
|
default: false,
|
|
172
183
|
})),
|
|
@@ -178,7 +189,7 @@ export const OpenAICompletionsCompatSchema = Type.Object({
|
|
|
178
189
|
description: "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.",
|
|
179
190
|
default: false,
|
|
180
191
|
}),
|
|
181
|
-
supportsMidConvoToolAdditions:
|
|
192
|
+
supportsMidConvoToolAdditions: opt(bool({
|
|
182
193
|
description: "Whether system messages can introduce additional tools mid-conversation. Requires supportsMidConvoSystemMessages. The generated catalog enables this for capable models.",
|
|
183
194
|
default: false,
|
|
184
195
|
})),
|
|
@@ -186,7 +197,7 @@ export const OpenAICompletionsCompatSchema = Type.Object({
|
|
|
186
197
|
description: "Whether the provider supports the strict field in tool definitions. Generated capable models enable it explicitly.",
|
|
187
198
|
default: false,
|
|
188
199
|
}),
|
|
189
|
-
cacheControlFormat:
|
|
200
|
+
cacheControlFormat: opt(stringLiteral("anthropic", {
|
|
190
201
|
description: "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.",
|
|
191
202
|
})),
|
|
192
203
|
sendSessionAffinityHeaders: optionalCompatBoolean({
|
|
@@ -195,17 +206,21 @@ export const OpenAICompletionsCompatSchema = Type.Object({
|
|
|
195
206
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
196
207
|
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.",
|
|
197
208
|
}),
|
|
209
|
+
promptCacheKeyMode: optionalPromptCacheKeyMode({
|
|
210
|
+
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.",
|
|
211
|
+
}),
|
|
198
212
|
supportsLongCacheRetention: optionalCompatBoolean({
|
|
199
213
|
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.',
|
|
200
214
|
}),
|
|
201
|
-
vllmPriority:
|
|
215
|
+
vllmPriority: opt(num({
|
|
202
216
|
description: "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.",
|
|
203
217
|
})),
|
|
204
|
-
}
|
|
218
|
+
};
|
|
219
|
+
export const OpenAICompletionsCompatSchema = openObject(OpenAICompletionsCompatProperties, {
|
|
205
220
|
description: "Compatibility settings for OpenAI-compatible completions APIs. Use this to override URL-based auto-detection for custom providers.",
|
|
206
221
|
additionalProperties: true,
|
|
207
222
|
});
|
|
208
|
-
|
|
223
|
+
const OpenAIResponsesCompatProperties = {
|
|
209
224
|
supportsDeveloperRole: optionalCompatBoolean({
|
|
210
225
|
description: "Whether the provider supports the developer role instead of system.",
|
|
211
226
|
default: true,
|
|
@@ -215,7 +230,10 @@ export const OpenAIResponsesCompatSchema = Type.Object({
|
|
|
215
230
|
default: false,
|
|
216
231
|
}),
|
|
217
232
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
218
|
-
description: "Session-affinity header format. openai sends
|
|
233
|
+
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.",
|
|
234
|
+
}),
|
|
235
|
+
promptCacheKeyMode: optionalPromptCacheKeyMode({
|
|
236
|
+
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.",
|
|
219
237
|
}),
|
|
220
238
|
supportsLongCacheRetention: optionalCompatBoolean({
|
|
221
239
|
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.',
|
|
@@ -228,29 +246,33 @@ export const OpenAIResponsesCompatSchema = Type.Object({
|
|
|
228
246
|
description: "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.",
|
|
229
247
|
default: false,
|
|
230
248
|
}),
|
|
231
|
-
supportsAdditionalTools:
|
|
249
|
+
supportsAdditionalTools: opt(bool({
|
|
232
250
|
description: "Whether the model supports message-anchored additional_tools input items.",
|
|
233
251
|
default: false,
|
|
234
252
|
})),
|
|
235
|
-
supportsToolSearch:
|
|
253
|
+
supportsToolSearch: opt(bool({
|
|
236
254
|
description: "Whether the model supports client-executed tool search for transcript-anchored additions.",
|
|
237
255
|
default: false,
|
|
238
256
|
})),
|
|
239
|
-
supportsExplicitPromptCacheMode:
|
|
257
|
+
supportsExplicitPromptCacheMode: opt(bool({
|
|
240
258
|
description: "Whether the model accepts prompt_cache_options. Older OpenAI models reject the parameter.",
|
|
241
259
|
default: false,
|
|
242
260
|
})),
|
|
243
|
-
supportsMidConvoEffort:
|
|
261
|
+
supportsMidConvoEffort: opt(bool({
|
|
244
262
|
description: "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.",
|
|
245
263
|
default: false,
|
|
246
264
|
})),
|
|
247
|
-
supportsMaxOutputTokens:
|
|
265
|
+
supportsMaxOutputTokens: opt(bool({
|
|
248
266
|
description: "Whether the provider accepts max_output_tokens. Some Codex-protocol gateways reject it.",
|
|
249
267
|
default: true,
|
|
250
268
|
})),
|
|
251
|
-
}
|
|
252
|
-
export const
|
|
253
|
-
|
|
269
|
+
};
|
|
270
|
+
export const OpenAIResponsesCompatSchema = openObject(OpenAIResponsesCompatProperties, {
|
|
271
|
+
description: "Compatibility settings for OpenAI Responses APIs.",
|
|
272
|
+
additionalProperties: true,
|
|
273
|
+
});
|
|
274
|
+
const AnthropicMessagesCompatProperties = {
|
|
275
|
+
supportsEagerToolInputStreaming: opt(bool({
|
|
254
276
|
description: "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.",
|
|
255
277
|
default: true,
|
|
256
278
|
})),
|
|
@@ -261,30 +283,30 @@ export const AnthropicMessagesCompatSchema = Type.Object({
|
|
|
261
283
|
sendSessionAffinityHeaders: optionalCompatBoolean({
|
|
262
284
|
description: "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.",
|
|
263
285
|
}),
|
|
264
|
-
sessionAffinityFormat:
|
|
286
|
+
sessionAffinityFormat: opt(stringLiteral("openrouter", {
|
|
265
287
|
description: "Session-affinity format. openrouter sends x-session-id; when unset, sends x-session-affinity.",
|
|
266
288
|
})),
|
|
267
|
-
supportsCacheControlOnTools:
|
|
289
|
+
supportsCacheControlOnTools: opt(bool({
|
|
268
290
|
description: "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.",
|
|
269
291
|
default: true,
|
|
270
292
|
})),
|
|
271
|
-
supportsTemperature:
|
|
293
|
+
supportsTemperature: opt(bool({
|
|
272
294
|
description: "Whether the model accepts the Anthropic temperature request field. Claude Opus 4.7+ rejects non-default values.",
|
|
273
295
|
default: true,
|
|
274
296
|
})),
|
|
275
|
-
forceAdaptiveThinking:
|
|
297
|
+
forceAdaptiveThinking: opt(bool({
|
|
276
298
|
description: "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.",
|
|
277
299
|
default: false,
|
|
278
300
|
})),
|
|
279
|
-
allowEmptySignature:
|
|
301
|
+
allowEmptySignature: opt(bool({
|
|
280
302
|
description: "Whether to replay empty thinking signatures instead of converting thinking to text.",
|
|
281
303
|
default: false,
|
|
282
304
|
})),
|
|
283
|
-
supportsStrictTools:
|
|
305
|
+
supportsStrictTools: opt(bool({
|
|
284
306
|
description: "Whether the provider supports Anthropic strict tool schemas. Generated Anthropic models enable it explicitly.",
|
|
285
307
|
default: false,
|
|
286
308
|
})),
|
|
287
|
-
supportsMidConvoEffort:
|
|
309
|
+
supportsMidConvoEffort: opt(bool({
|
|
288
310
|
description: "Whether the exact model transport supports effort-only system messages and thinking binding controls.",
|
|
289
311
|
default: false,
|
|
290
312
|
})),
|
|
@@ -292,35 +314,54 @@ export const AnthropicMessagesCompatSchema = Type.Object({
|
|
|
292
314
|
description: "Whether the exact model accepts system-role messages inside the conversation. When false, later system messages are folded into the top-level system prompt.",
|
|
293
315
|
default: false,
|
|
294
316
|
}),
|
|
295
|
-
supportsMidConvoToolChanges:
|
|
317
|
+
supportsMidConvoToolChanges: opt(bool({
|
|
296
318
|
description: "Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages.",
|
|
297
319
|
default: false,
|
|
298
320
|
})),
|
|
299
|
-
|
|
321
|
+
supportsMessageThreads: optionalCompatBoolean({
|
|
322
|
+
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.",
|
|
323
|
+
}),
|
|
324
|
+
allowedFallbackModels: opt(arr(AnthropicAllowedFallbackModelSchema, {
|
|
300
325
|
maxItems: 3,
|
|
301
326
|
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.",
|
|
302
327
|
})),
|
|
303
|
-
}
|
|
304
|
-
export const
|
|
328
|
+
};
|
|
329
|
+
export const AnthropicMessagesCompatSchema = openObject(AnthropicMessagesCompatProperties, {
|
|
330
|
+
description: "Compatibility settings for Anthropic Messages-compatible APIs.",
|
|
331
|
+
additionalProperties: true,
|
|
332
|
+
});
|
|
333
|
+
const BedrockCompatProperties = {
|
|
305
334
|
supportsStrictMode: optionalCompatBoolean({
|
|
306
335
|
description: "Whether the model supports Bedrock strict tool schemas.",
|
|
307
336
|
default: false,
|
|
308
337
|
}),
|
|
309
|
-
}
|
|
310
|
-
export const
|
|
338
|
+
};
|
|
339
|
+
export const BedrockCompatSchema = openObject(BedrockCompatProperties, {
|
|
340
|
+
description: "Compatibility settings for Amazon Bedrock models.",
|
|
341
|
+
additionalProperties: true,
|
|
342
|
+
});
|
|
343
|
+
const MistralConversationsCompatProperties = {
|
|
311
344
|
supportsMidConvoSystemMessages: optionalCompatBoolean({
|
|
312
345
|
description: "Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message.",
|
|
313
346
|
default: false,
|
|
314
347
|
}),
|
|
315
|
-
}
|
|
316
|
-
export const
|
|
317
|
-
|
|
348
|
+
};
|
|
349
|
+
export const MistralConversationsCompatSchema = openObject(MistralConversationsCompatProperties, {
|
|
350
|
+
description: "Compatibility settings for the Mistral chat API.",
|
|
351
|
+
additionalProperties: true,
|
|
352
|
+
});
|
|
353
|
+
const SystemOneCompatProperties = {
|
|
354
|
+
imageInput: opt(union([stringLiteral("assets"), stringLiteral("images"), stringLiteral("state-image-urls")], {
|
|
318
355
|
description: '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.',
|
|
319
356
|
})),
|
|
320
357
|
sendImageOptInHeader: optionalCompatBoolean({
|
|
321
358
|
description: "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.",
|
|
322
359
|
}),
|
|
323
|
-
}
|
|
360
|
+
};
|
|
361
|
+
export const SystemOneCompatSchema = openObject(SystemOneCompatProperties, {
|
|
362
|
+
description: "Compatibility settings for System One classifier APIs.",
|
|
363
|
+
additionalProperties: true,
|
|
364
|
+
});
|
|
324
365
|
const ProviderCompatPropertyOverrides = {
|
|
325
366
|
supportsDeveloperRole: optionalCompatBoolean({
|
|
326
367
|
description: "Whether the provider supports the developer role instead of system. Defaults are API-specific.",
|
|
@@ -332,6 +373,9 @@ const ProviderCompatPropertyOverrides = {
|
|
|
332
373
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
333
374
|
description: "Session-affinity header format. Defaults are API-specific or auto-detected.",
|
|
334
375
|
}),
|
|
376
|
+
promptCacheKeyMode: optionalPromptCacheKeyMode({
|
|
377
|
+
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.",
|
|
378
|
+
}),
|
|
335
379
|
supportsMidConvoEffort: optionalCompatBoolean({
|
|
336
380
|
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.",
|
|
337
381
|
default: false,
|
|
@@ -388,8 +432,15 @@ export const CompatSchemasByApi = {
|
|
|
388
432
|
"typesafe-system-one": SystemOneCompatSchema,
|
|
389
433
|
"cloudflare-workers-ai-system-one": SystemOneCompatSchema,
|
|
390
434
|
};
|
|
391
|
-
const ProviderCompatProperties = mergeCompatProperties([
|
|
392
|
-
|
|
435
|
+
const ProviderCompatProperties = mergeCompatProperties([
|
|
436
|
+
OpenAICompletionsCompatProperties,
|
|
437
|
+
OpenAIResponsesCompatProperties,
|
|
438
|
+
AnthropicMessagesCompatProperties,
|
|
439
|
+
BedrockCompatProperties,
|
|
440
|
+
MistralConversationsCompatProperties,
|
|
441
|
+
SystemOneCompatProperties,
|
|
442
|
+
], ProviderCompatPropertyOverrides);
|
|
443
|
+
export const ProviderCompatSchema = openObject(ProviderCompatProperties, {
|
|
393
444
|
description: "Provider and model compatibility overrides.",
|
|
394
445
|
additionalProperties: true,
|
|
395
446
|
});
|