@earendil-works/pi-ai 1.4.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 +58 -39
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +282 -87
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/dist/api/azure-openai-responses.js +1 -7
- 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 +127 -103
- 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 +13 -1
- package/dist/api/constrained-sampling.d.ts.map +1 -1
- package/dist/api/constrained-sampling.js +38 -18
- package/dist/api/constrained-sampling.js.map +1 -1
- package/dist/api/google-generative-ai.d.ts.map +1 -1
- package/dist/api/google-generative-ai.js +0 -6
- package/dist/api/google-generative-ai.js.map +1 -1
- package/dist/api/google-shared.d.ts +2 -1
- package/dist/api/google-shared.d.ts.map +1 -1
- package/dist/api/google-shared.js +57 -2
- package/dist/api/google-shared.js.map +1 -1
- package/dist/api/google-vertex.d.ts.map +1 -1
- package/dist/api/google-vertex.js +0 -6
- package/dist/api/google-vertex.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/mistral-conversations.d.ts.map +1 -1
- package/dist/api/mistral-conversations.js +17 -44
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +7 -8
- 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 +55 -59
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/dist/api/openai-responses-shared.js +58 -57
- package/dist/api/openai-responses-shared.js.map +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +4 -8
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/api/openrouter-images.js +1 -0
- package/dist/api/openrouter-images.js.map +1 -1
- package/dist/api/pi-messages.d.ts +2 -0
- package/dist/api/pi-messages.d.ts.map +1 -1
- package/dist/api/pi-messages.js +24 -9
- 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/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/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/auth/types.d.ts +4 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.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/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/compat/extension-oauth-types.d.ts +4 -0
- package/dist/compat/extension-oauth-types.d.ts.map +1 -1
- package/dist/compat/extension-oauth-types.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 +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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 +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 +5 -1
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +20 -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/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 +444 -456
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +166 -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/moonshotai-cn.json +1 -1
- package/dist/providers/data/moonshotai.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/faux.d.ts.map +1 -1
- package/dist/providers/faux.js +7 -2
- package/dist/providers/faux.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.js +1 -1
- package/dist/providers/openai-codex.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-config.d.ts.map +1 -1
- package/dist/providers/radius-config.js +2 -1
- package/dist/providers/radius-config.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/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +2 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/types.d.ts +20 -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 +30 -2
- package/dist/utils/error-body.js.map +1 -1
- package/dist/utils/openrouter-cost.d.ts +24 -0
- package/dist/utils/openrouter-cost.d.ts.map +1 -0
- package/dist/utils/openrouter-cost.js +34 -0
- package/dist/utils/openrouter-cost.js.map +1 -0
- 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 +6 -0
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/streaming-json.d.ts +84 -0
- package/dist/utils/streaming-json.d.ts.map +1 -0
- package/dist/utils/streaming-json.js +513 -0
- package/dist/utils/streaming-json.js.map +1 -0
- 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/text.d.ts +7 -0
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -1
- 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 +27 -277
- 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 +19 -10
- 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;AA2LF,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,114 @@ 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
|
+
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
|
+
})),
|
|
147
|
+
requiresThinkingAsText: opt(bool({
|
|
134
148
|
description: "Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL.",
|
|
135
149
|
})),
|
|
136
|
-
requiresReasoningContentOnAssistantMessages:
|
|
150
|
+
requiresReasoningContentOnAssistantMessages: opt(bool({
|
|
137
151
|
description: "Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL.",
|
|
138
152
|
})),
|
|
139
|
-
thinkingFormat:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
thinkingFormat: opt(union([
|
|
154
|
+
stringLiteral("openai"),
|
|
155
|
+
stringLiteral("openrouter"),
|
|
156
|
+
stringLiteral("deepseek"),
|
|
157
|
+
stringLiteral("together"),
|
|
158
|
+
stringLiteral("baseten"),
|
|
159
|
+
stringLiteral("zai"),
|
|
160
|
+
stringLiteral("qwen"),
|
|
161
|
+
stringLiteral("chat-template"),
|
|
162
|
+
stringLiteral("qwen-chat-template"),
|
|
163
|
+
stringLiteral("string-thinking"),
|
|
164
|
+
stringLiteral("ant-ling"),
|
|
151
165
|
], {
|
|
152
166
|
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
167
|
})),
|
|
154
|
-
chatTemplateKwargs:
|
|
168
|
+
chatTemplateKwargs: opt(stringRecord(ChatTemplateKwargValueSchema, {
|
|
155
169
|
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
170
|
})),
|
|
157
|
-
chatTemplateArgs:
|
|
171
|
+
chatTemplateArgs: opt(stringRecord(ChatTemplateKwargValueSchema, {
|
|
158
172
|
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
173
|
})),
|
|
160
|
-
openRouterRouting:
|
|
161
|
-
vercelGatewayRouting:
|
|
162
|
-
zaiToolStream:
|
|
174
|
+
openRouterRouting: opt(OpenRouterRoutingSchema),
|
|
175
|
+
vercelGatewayRouting: opt(VercelGatewayRoutingSchema),
|
|
176
|
+
zaiToolStream: opt(bool({
|
|
163
177
|
description: "Whether z.ai supports top-level tool_stream for streaming tool call deltas.",
|
|
164
178
|
default: false,
|
|
165
179
|
})),
|
|
166
|
-
thinkingTokenBudgetField:
|
|
180
|
+
thinkingTokenBudgetField: opt(thinkingTokenBudgetField({
|
|
167
181
|
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
182
|
})),
|
|
169
|
-
supportsThinkingTokenBudget:
|
|
183
|
+
supportsThinkingTokenBudget: opt(bool({
|
|
170
184
|
description: 'Alias for thinkingTokenBudgetField: "thinking_token_budget" (vLLM). Prefer thinkingTokenBudgetField.',
|
|
171
185
|
default: false,
|
|
172
186
|
})),
|
|
@@ -178,7 +192,7 @@ export const OpenAICompletionsCompatSchema = Type.Object({
|
|
|
178
192
|
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
193
|
default: false,
|
|
180
194
|
}),
|
|
181
|
-
supportsMidConvoToolAdditions:
|
|
195
|
+
supportsMidConvoToolAdditions: opt(bool({
|
|
182
196
|
description: "Whether system messages can introduce additional tools mid-conversation. Requires supportsMidConvoSystemMessages. The generated catalog enables this for capable models.",
|
|
183
197
|
default: false,
|
|
184
198
|
})),
|
|
@@ -186,7 +200,7 @@ export const OpenAICompletionsCompatSchema = Type.Object({
|
|
|
186
200
|
description: "Whether the provider supports the strict field in tool definitions. Generated capable models enable it explicitly.",
|
|
187
201
|
default: false,
|
|
188
202
|
}),
|
|
189
|
-
cacheControlFormat:
|
|
203
|
+
cacheControlFormat: opt(stringLiteral("anthropic", {
|
|
190
204
|
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
205
|
})),
|
|
192
206
|
sendSessionAffinityHeaders: optionalCompatBoolean({
|
|
@@ -195,17 +209,21 @@ export const OpenAICompletionsCompatSchema = Type.Object({
|
|
|
195
209
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
196
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.",
|
|
197
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
|
+
}),
|
|
198
215
|
supportsLongCacheRetention: optionalCompatBoolean({
|
|
199
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.',
|
|
200
217
|
}),
|
|
201
|
-
vllmPriority:
|
|
218
|
+
vllmPriority: opt(num({
|
|
202
219
|
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
220
|
})),
|
|
204
|
-
}
|
|
221
|
+
};
|
|
222
|
+
export const OpenAICompletionsCompatSchema = openObject(OpenAICompletionsCompatProperties, {
|
|
205
223
|
description: "Compatibility settings for OpenAI-compatible completions APIs. Use this to override URL-based auto-detection for custom providers.",
|
|
206
224
|
additionalProperties: true,
|
|
207
225
|
});
|
|
208
|
-
|
|
226
|
+
const OpenAIResponsesCompatProperties = {
|
|
209
227
|
supportsDeveloperRole: optionalCompatBoolean({
|
|
210
228
|
description: "Whether the provider supports the developer role instead of system.",
|
|
211
229
|
default: true,
|
|
@@ -215,7 +233,10 @@ export const OpenAIResponsesCompatSchema = Type.Object({
|
|
|
215
233
|
default: false,
|
|
216
234
|
}),
|
|
217
235
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
218
|
-
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.",
|
|
219
240
|
}),
|
|
220
241
|
supportsLongCacheRetention: optionalCompatBoolean({
|
|
221
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.',
|
|
@@ -228,29 +249,33 @@ export const OpenAIResponsesCompatSchema = Type.Object({
|
|
|
228
249
|
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
250
|
default: false,
|
|
230
251
|
}),
|
|
231
|
-
supportsAdditionalTools:
|
|
252
|
+
supportsAdditionalTools: opt(bool({
|
|
232
253
|
description: "Whether the model supports message-anchored additional_tools input items.",
|
|
233
254
|
default: false,
|
|
234
255
|
})),
|
|
235
|
-
supportsToolSearch:
|
|
256
|
+
supportsToolSearch: opt(bool({
|
|
236
257
|
description: "Whether the model supports client-executed tool search for transcript-anchored additions.",
|
|
237
258
|
default: false,
|
|
238
259
|
})),
|
|
239
|
-
supportsExplicitPromptCacheMode:
|
|
260
|
+
supportsExplicitPromptCacheMode: opt(bool({
|
|
240
261
|
description: "Whether the model accepts prompt_cache_options. Older OpenAI models reject the parameter.",
|
|
241
262
|
default: false,
|
|
242
263
|
})),
|
|
243
|
-
supportsMidConvoEffort:
|
|
264
|
+
supportsMidConvoEffort: opt(bool({
|
|
244
265
|
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
266
|
default: false,
|
|
246
267
|
})),
|
|
247
|
-
supportsMaxOutputTokens:
|
|
268
|
+
supportsMaxOutputTokens: opt(bool({
|
|
248
269
|
description: "Whether the provider accepts max_output_tokens. Some Codex-protocol gateways reject it.",
|
|
249
270
|
default: true,
|
|
250
271
|
})),
|
|
251
|
-
}
|
|
252
|
-
export const
|
|
253
|
-
|
|
272
|
+
};
|
|
273
|
+
export const OpenAIResponsesCompatSchema = openObject(OpenAIResponsesCompatProperties, {
|
|
274
|
+
description: "Compatibility settings for OpenAI Responses APIs.",
|
|
275
|
+
additionalProperties: true,
|
|
276
|
+
});
|
|
277
|
+
const AnthropicMessagesCompatProperties = {
|
|
278
|
+
supportsEagerToolInputStreaming: opt(bool({
|
|
254
279
|
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
280
|
default: true,
|
|
256
281
|
})),
|
|
@@ -261,30 +286,30 @@ export const AnthropicMessagesCompatSchema = Type.Object({
|
|
|
261
286
|
sendSessionAffinityHeaders: optionalCompatBoolean({
|
|
262
287
|
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
288
|
}),
|
|
264
|
-
sessionAffinityFormat:
|
|
289
|
+
sessionAffinityFormat: opt(stringLiteral("openrouter", {
|
|
265
290
|
description: "Session-affinity format. openrouter sends x-session-id; when unset, sends x-session-affinity.",
|
|
266
291
|
})),
|
|
267
|
-
supportsCacheControlOnTools:
|
|
292
|
+
supportsCacheControlOnTools: opt(bool({
|
|
268
293
|
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
294
|
default: true,
|
|
270
295
|
})),
|
|
271
|
-
supportsTemperature:
|
|
296
|
+
supportsTemperature: opt(bool({
|
|
272
297
|
description: "Whether the model accepts the Anthropic temperature request field. Claude Opus 4.7+ rejects non-default values.",
|
|
273
298
|
default: true,
|
|
274
299
|
})),
|
|
275
|
-
forceAdaptiveThinking:
|
|
300
|
+
forceAdaptiveThinking: opt(bool({
|
|
276
301
|
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
302
|
default: false,
|
|
278
303
|
})),
|
|
279
|
-
allowEmptySignature:
|
|
304
|
+
allowEmptySignature: opt(bool({
|
|
280
305
|
description: "Whether to replay empty thinking signatures instead of converting thinking to text.",
|
|
281
306
|
default: false,
|
|
282
307
|
})),
|
|
283
|
-
supportsStrictTools:
|
|
308
|
+
supportsStrictTools: opt(bool({
|
|
284
309
|
description: "Whether the provider supports Anthropic strict tool schemas. Generated Anthropic models enable it explicitly.",
|
|
285
310
|
default: false,
|
|
286
311
|
})),
|
|
287
|
-
supportsMidConvoEffort:
|
|
312
|
+
supportsMidConvoEffort: opt(bool({
|
|
288
313
|
description: "Whether the exact model transport supports effort-only system messages and thinking binding controls.",
|
|
289
314
|
default: false,
|
|
290
315
|
})),
|
|
@@ -292,35 +317,54 @@ export const AnthropicMessagesCompatSchema = Type.Object({
|
|
|
292
317
|
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
318
|
default: false,
|
|
294
319
|
}),
|
|
295
|
-
supportsMidConvoToolChanges:
|
|
320
|
+
supportsMidConvoToolChanges: opt(bool({
|
|
296
321
|
description: "Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages.",
|
|
297
322
|
default: false,
|
|
298
323
|
})),
|
|
299
|
-
|
|
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
|
+
}),
|
|
327
|
+
allowedFallbackModels: opt(arr(AnthropicAllowedFallbackModelSchema, {
|
|
300
328
|
maxItems: 3,
|
|
301
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.",
|
|
302
330
|
})),
|
|
303
|
-
}
|
|
304
|
-
export const
|
|
331
|
+
};
|
|
332
|
+
export const AnthropicMessagesCompatSchema = openObject(AnthropicMessagesCompatProperties, {
|
|
333
|
+
description: "Compatibility settings for Anthropic Messages-compatible APIs.",
|
|
334
|
+
additionalProperties: true,
|
|
335
|
+
});
|
|
336
|
+
const BedrockCompatProperties = {
|
|
305
337
|
supportsStrictMode: optionalCompatBoolean({
|
|
306
338
|
description: "Whether the model supports Bedrock strict tool schemas.",
|
|
307
339
|
default: false,
|
|
308
340
|
}),
|
|
309
|
-
}
|
|
310
|
-
export const
|
|
341
|
+
};
|
|
342
|
+
export const BedrockCompatSchema = openObject(BedrockCompatProperties, {
|
|
343
|
+
description: "Compatibility settings for Amazon Bedrock models.",
|
|
344
|
+
additionalProperties: true,
|
|
345
|
+
});
|
|
346
|
+
const MistralConversationsCompatProperties = {
|
|
311
347
|
supportsMidConvoSystemMessages: optionalCompatBoolean({
|
|
312
348
|
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
349
|
default: false,
|
|
314
350
|
}),
|
|
315
|
-
}
|
|
316
|
-
export const
|
|
317
|
-
|
|
351
|
+
};
|
|
352
|
+
export const MistralConversationsCompatSchema = openObject(MistralConversationsCompatProperties, {
|
|
353
|
+
description: "Compatibility settings for the Mistral chat API.",
|
|
354
|
+
additionalProperties: true,
|
|
355
|
+
});
|
|
356
|
+
const SystemOneCompatProperties = {
|
|
357
|
+
imageInput: opt(union([stringLiteral("assets"), stringLiteral("images"), stringLiteral("state-image-urls")], {
|
|
318
358
|
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
359
|
})),
|
|
320
360
|
sendImageOptInHeader: optionalCompatBoolean({
|
|
321
361
|
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
362
|
}),
|
|
323
|
-
}
|
|
363
|
+
};
|
|
364
|
+
export const SystemOneCompatSchema = openObject(SystemOneCompatProperties, {
|
|
365
|
+
description: "Compatibility settings for System One classifier APIs.",
|
|
366
|
+
additionalProperties: true,
|
|
367
|
+
});
|
|
324
368
|
const ProviderCompatPropertyOverrides = {
|
|
325
369
|
supportsDeveloperRole: optionalCompatBoolean({
|
|
326
370
|
description: "Whether the provider supports the developer role instead of system. Defaults are API-specific.",
|
|
@@ -332,6 +376,9 @@ const ProviderCompatPropertyOverrides = {
|
|
|
332
376
|
sessionAffinityFormat: optionalSessionAffinityFormat({
|
|
333
377
|
description: "Session-affinity header format. Defaults are API-specific or auto-detected.",
|
|
334
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
|
+
}),
|
|
335
382
|
supportsMidConvoEffort: optionalCompatBoolean({
|
|
336
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.",
|
|
337
384
|
default: false,
|
|
@@ -388,8 +435,15 @@ export const CompatSchemasByApi = {
|
|
|
388
435
|
"typesafe-system-one": SystemOneCompatSchema,
|
|
389
436
|
"cloudflare-workers-ai-system-one": SystemOneCompatSchema,
|
|
390
437
|
};
|
|
391
|
-
const ProviderCompatProperties = mergeCompatProperties([
|
|
392
|
-
|
|
438
|
+
const ProviderCompatProperties = mergeCompatProperties([
|
|
439
|
+
OpenAICompletionsCompatProperties,
|
|
440
|
+
OpenAIResponsesCompatProperties,
|
|
441
|
+
AnthropicMessagesCompatProperties,
|
|
442
|
+
BedrockCompatProperties,
|
|
443
|
+
MistralConversationsCompatProperties,
|
|
444
|
+
SystemOneCompatProperties,
|
|
445
|
+
], ProviderCompatPropertyOverrides);
|
|
446
|
+
export const ProviderCompatSchema = openObject(ProviderCompatProperties, {
|
|
393
447
|
description: "Provider and model compatibility overrides.",
|
|
394
448
|
additionalProperties: true,
|
|
395
449
|
});
|