@bastani/pi-ai 0.9.29 → 0.9.30-alpha.2
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/CHANGELOG.md +10 -0
- package/dist/api/mistral-conversations.d.ts.map +1 -1
- package/dist/api/mistral-conversations.js +61 -14
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +354 -0
- package/dist/providers/compat-schema.d.ts.map +1 -0
- package/dist/providers/compat-schema.js +411 -0
- package/dist/providers/compat-schema.js.map +1 -0
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/model-schema.d.ts +91 -0
- package/dist/providers/model-schema.d.ts.map +1 -0
- package/dist/providers/model-schema.js +55 -0
- package/dist/providers/model-schema.js.map +1 -0
- package/dist/types.d.ts +5 -369
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
export declare const THINKING_LEVELS: readonly ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
3
|
+
export declare const MODEL_THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
4
|
+
export declare const MODEL_INPUT_MODALITIES: readonly ["text", "image", "pdf"];
|
|
5
|
+
export declare const CACHE_RETENTIONS: readonly ["none", "short", "long"];
|
|
6
|
+
export declare const MODEL_PROMPT_CACHE_RETENTIONS: readonly ["short", "long"];
|
|
7
|
+
export declare const ThinkingLevelSchema: Type.TEnum<["minimal", "low", "medium", "high", "xhigh", "max"]>;
|
|
8
|
+
export declare const ModelThinkingLevelSchema: Type.TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
|
|
9
|
+
export declare const ModelInputModalitySchema: Type.TEnum<["text", "image", "pdf"]>;
|
|
10
|
+
export declare const CacheRetentionSchema: Type.TEnum<["none", "short", "long"]>;
|
|
11
|
+
export declare const ThinkingLevelMapSchema: Type.TObject<{
|
|
12
|
+
high: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
13
|
+
low: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
14
|
+
max: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
15
|
+
medium: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
16
|
+
minimal: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
17
|
+
off: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
18
|
+
xhigh: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const ModelPromptCacheSchema: Type.TObject<{
|
|
21
|
+
long: Type.TOptional<Type.TNumber>;
|
|
22
|
+
short: Type.TOptional<Type.TNumber>;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const ModelCostRatesSchema: Type.TObject<{
|
|
25
|
+
input: Type.TNumber;
|
|
26
|
+
output: Type.TNumber;
|
|
27
|
+
cacheRead: Type.TNumber;
|
|
28
|
+
cacheWrite: Type.TNumber;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const ModelCostTierSchema: Type.TObject<{
|
|
31
|
+
input: Type.TNumber;
|
|
32
|
+
output: Type.TNumber;
|
|
33
|
+
cacheRead: Type.TNumber;
|
|
34
|
+
cacheWrite: Type.TNumber;
|
|
35
|
+
inputTokensAbove: Type.TNumber;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const ModelCostSchema: Type.TObject<{
|
|
38
|
+
input: Type.TNumber;
|
|
39
|
+
output: Type.TNumber;
|
|
40
|
+
cacheRead: Type.TNumber;
|
|
41
|
+
cacheWrite: Type.TNumber;
|
|
42
|
+
tiers: Type.TOptional<Type.TArray<Type.TObject<{
|
|
43
|
+
input: Type.TNumber;
|
|
44
|
+
output: Type.TNumber;
|
|
45
|
+
cacheRead: Type.TNumber;
|
|
46
|
+
cacheWrite: Type.TNumber;
|
|
47
|
+
inputTokensAbove: Type.TNumber;
|
|
48
|
+
}>>>;
|
|
49
|
+
}>;
|
|
50
|
+
export declare const ModelImageResizeOptionsSchema: Type.TObject<{
|
|
51
|
+
maxWidth: Type.TOptional<Type.TInteger>;
|
|
52
|
+
maxHeight: Type.TOptional<Type.TInteger>;
|
|
53
|
+
maxBytes: Type.TOptional<Type.TInteger>;
|
|
54
|
+
jpegQuality: Type.TOptional<Type.TInteger>;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const ModelImageInputLimitsSchema: Type.TObject<{
|
|
57
|
+
resize: Type.TOptional<Type.TObject<{
|
|
58
|
+
maxWidth: Type.TOptional<Type.TInteger>;
|
|
59
|
+
maxHeight: Type.TOptional<Type.TInteger>;
|
|
60
|
+
maxBytes: Type.TOptional<Type.TInteger>;
|
|
61
|
+
jpegQuality: Type.TOptional<Type.TInteger>;
|
|
62
|
+
}>>;
|
|
63
|
+
maxPerMessage: Type.TOptional<Type.TInteger>;
|
|
64
|
+
maxPerRequest: Type.TOptional<Type.TInteger>;
|
|
65
|
+
}>;
|
|
66
|
+
export declare const ModelInputLimitsSchema: Type.TObject<{
|
|
67
|
+
maxRequestBytes: Type.TOptional<Type.TInteger>;
|
|
68
|
+
images: Type.TOptional<Type.TObject<{
|
|
69
|
+
resize: Type.TOptional<Type.TObject<{
|
|
70
|
+
maxWidth: Type.TOptional<Type.TInteger>;
|
|
71
|
+
maxHeight: Type.TOptional<Type.TInteger>;
|
|
72
|
+
maxBytes: Type.TOptional<Type.TInteger>;
|
|
73
|
+
jpegQuality: Type.TOptional<Type.TInteger>;
|
|
74
|
+
}>>;
|
|
75
|
+
maxPerMessage: Type.TOptional<Type.TInteger>;
|
|
76
|
+
maxPerRequest: Type.TOptional<Type.TInteger>;
|
|
77
|
+
}>>;
|
|
78
|
+
}>;
|
|
79
|
+
export type ThinkingLevel = Static<typeof ThinkingLevelSchema>;
|
|
80
|
+
export type ModelThinkingLevel = Static<typeof ModelThinkingLevelSchema>;
|
|
81
|
+
export type ThinkingLevelMap = Static<typeof ThinkingLevelMapSchema>;
|
|
82
|
+
export type ModelInputModality = Static<typeof ModelInputModalitySchema>;
|
|
83
|
+
export type CacheRetention = Static<typeof CacheRetentionSchema>;
|
|
84
|
+
export type ModelPromptCache = Static<typeof ModelPromptCacheSchema>;
|
|
85
|
+
export type ModelCostRates = Static<typeof ModelCostRatesSchema>;
|
|
86
|
+
export type ModelCostTier = Static<typeof ModelCostTierSchema>;
|
|
87
|
+
export type ModelCost = Static<typeof ModelCostSchema>;
|
|
88
|
+
export type ModelImageResizeOptions = Static<typeof ModelImageResizeOptionsSchema>;
|
|
89
|
+
export type ModelImageInputLimits = Static<typeof ModelImageInputLimitsSchema>;
|
|
90
|
+
export type ModelInputLimits = Static<typeof ModelInputLimitsSchema>;
|
|
91
|
+
//# sourceMappingURL=model-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-schema.d.ts","sourceRoot":"","sources":["../../src/providers/model-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAuB,IAAI,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,eAAe,YAAI,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAC7F,eAAO,MAAM,qBAAqB,sEAAuC,CAAC;AAC1E,eAAO,MAAM,sBAAsB,YAAI,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AACxE,eAAO,MAAM,gBAAgB,YAAI,MAAM,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AACnE,eAAO,MAAM,6BAA6B,YAAI,OAAO,EAAE,MAAM,CAAU,CAAC;AAExE,eAAO,MAAM,mBAAmB,kEAA6B,CAAC;AAC9D,eAAO,MAAM,wBAAwB,yEAA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AAC,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
export const THINKING_LEVELS = ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
3
|
+
export const MODEL_THINKING_LEVELS = ["off", ...THINKING_LEVELS];
|
|
4
|
+
export const MODEL_INPUT_MODALITIES = ["text", "image", "pdf"];
|
|
5
|
+
export const CACHE_RETENTIONS = ["none", "short", "long"];
|
|
6
|
+
export const MODEL_PROMPT_CACHE_RETENTIONS = ["short", "long"];
|
|
7
|
+
export const ThinkingLevelSchema = Type.Enum(THINKING_LEVELS);
|
|
8
|
+
export const ModelThinkingLevelSchema = Type.Enum(MODEL_THINKING_LEVELS);
|
|
9
|
+
export const ModelInputModalitySchema = Type.Enum(MODEL_INPUT_MODALITIES);
|
|
10
|
+
export const CacheRetentionSchema = Type.Enum(CACHE_RETENTIONS);
|
|
11
|
+
const ThinkingLevelMapValueSchema = Type.Union([Type.String(), Type.Null()]);
|
|
12
|
+
export const ThinkingLevelMapSchema = Type.Partial(Type.Record(ModelThinkingLevelSchema, ThinkingLevelMapValueSchema));
|
|
13
|
+
export const ModelPromptCacheSchema = Type.Partial(Type.Record(Type.Enum(MODEL_PROMPT_CACHE_RETENTIONS), Type.Number({ exclusiveMinimum: 0 })), {
|
|
14
|
+
description: "Best-effort prompt cache lifetime in seconds for each retention tier. A missing tier means the lifetime is unknown, so Pi does not warm it.",
|
|
15
|
+
});
|
|
16
|
+
const ModelCostRatesProperties = {
|
|
17
|
+
input: Type.Number({ description: "Input cost in USD per million tokens." }),
|
|
18
|
+
output: Type.Number({ description: "Output cost in USD per million tokens." }),
|
|
19
|
+
cacheRead: Type.Number({ description: "Cache-read cost in USD per million tokens." }),
|
|
20
|
+
cacheWrite: Type.Number({ description: "Cache-write cost in USD per million tokens." }),
|
|
21
|
+
};
|
|
22
|
+
export const ModelCostRatesSchema = Type.Object(ModelCostRatesProperties);
|
|
23
|
+
export const ModelCostTierSchema = Type.Object({
|
|
24
|
+
inputTokensAbove: Type.Number({
|
|
25
|
+
description: "Use this tier when total request input exceeds this token count.",
|
|
26
|
+
}),
|
|
27
|
+
...ModelCostRatesProperties,
|
|
28
|
+
});
|
|
29
|
+
export const ModelCostSchema = Type.Object({
|
|
30
|
+
...ModelCostRatesProperties,
|
|
31
|
+
tiers: Type.Optional(Type.Array(ModelCostTierSchema, {
|
|
32
|
+
description: "Request-wide pricing tiers. The highest matching input threshold applies to the full request.",
|
|
33
|
+
})),
|
|
34
|
+
});
|
|
35
|
+
function modelImageResizeOptions(options) {
|
|
36
|
+
return Type.Object({
|
|
37
|
+
maxWidth: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
38
|
+
maxHeight: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
39
|
+
maxBytes: Type.Optional(Type.Integer({ minimum: 1, description: "Maximum base64-encoded payload size in bytes." })),
|
|
40
|
+
jpegQuality: Type.Optional(Type.Integer({ minimum: 1, maximum: 100 })),
|
|
41
|
+
}, options);
|
|
42
|
+
}
|
|
43
|
+
export const ModelImageResizeOptionsSchema = modelImageResizeOptions();
|
|
44
|
+
export const ModelImageInputLimitsSchema = Type.Object({
|
|
45
|
+
resize: Type.Optional(modelImageResizeOptions({
|
|
46
|
+
description: "Cache-safe resize profile applied before a new image enters conversation history.",
|
|
47
|
+
})),
|
|
48
|
+
maxPerMessage: Type.Optional(Type.Integer({ minimum: 1, description: "Maximum images accepted in one provider message." })),
|
|
49
|
+
maxPerRequest: Type.Optional(Type.Integer({ minimum: 1, description: "Maximum images accepted across one provider request." })),
|
|
50
|
+
});
|
|
51
|
+
export const ModelInputLimitsSchema = Type.Object({
|
|
52
|
+
maxRequestBytes: Type.Optional(Type.Integer({ minimum: 1, description: "Maximum serialized provider request size in bytes." })),
|
|
53
|
+
images: Type.Optional(ModelImageInputLimitsSchema),
|
|
54
|
+
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CAAC,2BAA2B,CAAC;CAClD,CAAC,CAAC","sourcesContent":["import { type Static, type TSchemaOptions, Type } from \"typebox\";\n\nexport const THINKING_LEVELS = [\"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nexport const MODEL_THINKING_LEVELS = [\"off\", ...THINKING_LEVELS] as const;\nexport const MODEL_INPUT_MODALITIES = [\"text\", \"image\", \"pdf\"] as const;\nexport const CACHE_RETENTIONS = [\"none\", \"short\", \"long\"] as const;\nexport const MODEL_PROMPT_CACHE_RETENTIONS = [\"short\", \"long\"] as const;\n\nexport const ThinkingLevelSchema = Type.Enum(THINKING_LEVELS);\nexport const ModelThinkingLevelSchema = Type.Enum(MODEL_THINKING_LEVELS);\nexport const ModelInputModalitySchema = Type.Enum(MODEL_INPUT_MODALITIES);\nexport const CacheRetentionSchema = Type.Enum(CACHE_RETENTIONS);\n\nconst ThinkingLevelMapValueSchema = Type.Union([Type.String(), Type.Null()]);\nexport const ThinkingLevelMapSchema = Type.Partial(Type.Record(ModelThinkingLevelSchema, ThinkingLevelMapValueSchema));\n\nexport const ModelPromptCacheSchema = Type.Partial(\n\tType.Record(Type.Enum(MODEL_PROMPT_CACHE_RETENTIONS), Type.Number({ exclusiveMinimum: 0 })),\n\t{\n\t\tdescription:\n\t\t\t\"Best-effort prompt cache lifetime in seconds for each retention tier. A missing tier means the lifetime is unknown, so Pi does not warm it.\",\n\t},\n);\n\nconst ModelCostRatesProperties = {\n\tinput: Type.Number({ description: \"Input cost in USD per million tokens.\" }),\n\toutput: Type.Number({ description: \"Output cost in USD per million tokens.\" }),\n\tcacheRead: Type.Number({ description: \"Cache-read cost in USD per million tokens.\" }),\n\tcacheWrite: Type.Number({ description: \"Cache-write cost in USD per million tokens.\" }),\n};\n\nexport const ModelCostRatesSchema = Type.Object(ModelCostRatesProperties);\nexport const ModelCostTierSchema = Type.Object({\n\tinputTokensAbove: Type.Number({\n\t\tdescription: \"Use this tier when total request input exceeds this token count.\",\n\t}),\n\t...ModelCostRatesProperties,\n});\nexport const ModelCostSchema = Type.Object({\n\t...ModelCostRatesProperties,\n\ttiers: Type.Optional(\n\t\tType.Array(ModelCostTierSchema, {\n\t\t\tdescription: \"Request-wide pricing tiers. The highest matching input threshold applies to the full request.\",\n\t\t}),\n\t),\n});\n\nfunction modelImageResizeOptions(options?: TSchemaOptions) {\n\treturn Type.Object(\n\t\t{\n\t\t\tmaxWidth: Type.Optional(Type.Integer({ minimum: 1 })),\n\t\t\tmaxHeight: Type.Optional(Type.Integer({ minimum: 1 })),\n\t\t\tmaxBytes: Type.Optional(\n\t\t\t\tType.Integer({ minimum: 1, description: \"Maximum base64-encoded payload size in bytes.\" }),\n\t\t\t),\n\t\t\tjpegQuality: Type.Optional(Type.Integer({ minimum: 1, maximum: 100 })),\n\t\t},\n\t\toptions,\n\t);\n}\n\nexport const ModelImageResizeOptionsSchema = modelImageResizeOptions();\n\nexport const ModelImageInputLimitsSchema = Type.Object({\n\tresize: Type.Optional(\n\t\tmodelImageResizeOptions({\n\t\t\tdescription: \"Cache-safe resize profile applied before a new image enters conversation history.\",\n\t\t}),\n\t),\n\tmaxPerMessage: Type.Optional(\n\t\tType.Integer({ minimum: 1, description: \"Maximum images accepted in one provider message.\" }),\n\t),\n\tmaxPerRequest: Type.Optional(\n\t\tType.Integer({ minimum: 1, description: \"Maximum images accepted across one provider request.\" }),\n\t),\n});\n\nexport const ModelInputLimitsSchema = Type.Object({\n\tmaxRequestBytes: Type.Optional(\n\t\tType.Integer({ minimum: 1, description: \"Maximum serialized provider request size in bytes.\" }),\n\t),\n\timages: Type.Optional(ModelImageInputLimitsSchema),\n});\n\nexport type ThinkingLevel = Static<typeof ThinkingLevelSchema>;\nexport type ModelThinkingLevel = Static<typeof ModelThinkingLevelSchema>;\nexport type ThinkingLevelMap = Static<typeof ThinkingLevelMapSchema>;\nexport type ModelInputModality = Static<typeof ModelInputModalitySchema>;\nexport type CacheRetention = Static<typeof CacheRetentionSchema>;\nexport type ModelPromptCache = Static<typeof ModelPromptCacheSchema>;\nexport type ModelCostRates = Static<typeof ModelCostRatesSchema>;\nexport type ModelCostTier = Static<typeof ModelCostTierSchema>;\nexport type ModelCost = Static<typeof ModelCostSchema>;\nexport type ModelImageResizeOptions = Static<typeof ModelImageResizeOptionsSchema>;\nexport type ModelImageInputLimits = Static<typeof ModelImageInputLimitsSchema>;\nexport type ModelInputLimits = Static<typeof ModelInputLimitsSchema>;\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -10,8 +10,12 @@ import type { OpenAICompletionsOptions } from "./api/openai-completions.ts";
|
|
|
10
10
|
import type { OpenAIImagesOptions } from "./api/openai-images.ts";
|
|
11
11
|
import type { OpenAIResponsesOptions } from "./api/openai-responses.ts";
|
|
12
12
|
import type { PiMessagesOptions } from "./api/pi-messages.ts";
|
|
13
|
+
import type { AnthropicMessagesCompat, BedrockCompat, MistralConversationsCompat, OpenAICompletionsCompat, OpenAIResponsesCompat } from "./providers/compat-schema.ts";
|
|
14
|
+
import type { CacheRetention, ModelCost, ModelInputLimits, ModelInputModality, ModelPromptCache, ModelThinkingLevel, ThinkingLevel, ThinkingLevelMap } from "./providers/model-schema.ts";
|
|
13
15
|
import type { AssistantMessageDiagnostic } from "./utils/diagnostics.ts";
|
|
14
16
|
import type { AssistantMessageEventStream } from "./utils/event-stream.ts";
|
|
17
|
+
export type { AnthropicAllowedFallbackModel, AnthropicMessagesCompat, BedrockCompat, ChatTemplateKwargValue, MistralConversationsCompat, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, SessionAffinityFormat, ThinkingTokenBudgetField, VercelGatewayRouting, } from "./providers/compat-schema.ts";
|
|
18
|
+
export type { CacheRetention, ModelCost, ModelCostRates, ModelCostTier, ModelImageInputLimits, ModelImageResizeOptions, ModelInputLimits, ModelInputModality, ModelPromptCache, ModelThinkingLevel, ThinkingLevel, ThinkingLevelMap, } from "./providers/model-schema.ts";
|
|
15
19
|
export type { AssistantMessageEventStream } from "./utils/event-stream.ts";
|
|
16
20
|
export type KnownApi = "openai-completions" | "mistral-conversations" | "openai-responses" | "azure-openai-responses" | "openai-codex-responses" | "anthropic-messages" | "bedrock-converse-stream" | "google-generative-ai" | "google-vertex" | "pi-messages";
|
|
17
21
|
export type Api = KnownApi | (string & {});
|
|
@@ -23,17 +27,8 @@ export type CompactorApi = "morph-compact";
|
|
|
23
27
|
export type KnownProvider = "amazon-bedrock" | "ant-ling" | "anthropic" | "anthropic-api" | "google" | "google-vertex" | "openai" | "openai-api" | "azure" | "azure-openai-responses" | "openai-codex" | "openai-decisions" | "openai-images" | "radius" | "typesafe" | "morph" | "nvidia" | "deepseek" | "github-copilot" | "xai" | "groq" | "cerebras" | "openrouter" | "vercel-ai-gateway" | "zai" | "zai-coding-cn" | "mistral" | "minimax" | "minimax-cn" | "moonshotai" | "moonshotai-cn" | "huggingface" | "fireworks" | "together" | "baseten" | "opencode" | "opencode-go" | "kimi-coding" | "meta" | "cloudflare-workers-ai" | "cloudflare-ai-gateway" | "qwen-token-plan" | "qwen-token-plan-cn" | "qwen-token-plan-individual" | "xiaomi" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-sgp";
|
|
24
28
|
export type ProviderId = KnownProvider | string;
|
|
25
29
|
export type ToolChoice = "auto" | "none";
|
|
26
|
-
export type ThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
27
|
-
export type ModelThinkingLevel = "off" | ThinkingLevel;
|
|
28
|
-
export type ThinkingLevelMap = Partial<Record<ModelThinkingLevel, string | null>>;
|
|
29
30
|
export type SamplingParams = Record<string, unknown>;
|
|
30
31
|
export type SamplingParamsByThinkingLevel = Partial<Record<ModelThinkingLevel, SamplingParams>>;
|
|
31
|
-
export type ChatTemplateKwargValue = string | number | boolean | null | {
|
|
32
|
-
$var: "thinking.enabled" | "thinking.effort" | "thinking.budget";
|
|
33
|
-
omitWhenOff?: boolean;
|
|
34
|
-
};
|
|
35
|
-
/** Top-level request field used to cap reasoning tokens on OpenAI-compatible servers. */
|
|
36
|
-
export type ThinkingTokenBudgetField = "thinking_token_budget" | "thinking_budget" | "thinking_budget_tokens";
|
|
37
32
|
/** Token budgets for each thinking level (token-based providers only) */
|
|
38
33
|
export interface ThinkingBudgets {
|
|
39
34
|
minimal?: number;
|
|
@@ -41,18 +36,11 @@ export interface ThinkingBudgets {
|
|
|
41
36
|
medium?: number;
|
|
42
37
|
high?: number;
|
|
43
38
|
}
|
|
44
|
-
export type CacheRetention = "none" | "short" | "long";
|
|
45
|
-
/**
|
|
46
|
-
* Best-effort prompt cache lifetime in seconds for each retention tier a request can ask for.
|
|
47
|
-
* A missing tier means the lifetime is unknown; pi does not warm such caches.
|
|
48
|
-
*/
|
|
49
|
-
export type ModelPromptCache = Partial<Record<Exclude<CacheRetention, "none">, number>>;
|
|
50
39
|
export type Transport = "sse" | "websocket" | "websocket-cached" | "auto";
|
|
51
40
|
/** Provider-scoped environment overrides. Values take precedence over process.env. */
|
|
52
41
|
export type ProviderEnv = Record<string, string>;
|
|
53
42
|
export type ProviderHeaders = Record<string, string | null>;
|
|
54
43
|
export type FetchFunction = typeof globalThis.fetch;
|
|
55
|
-
export type SessionAffinityFormat = "openai" | "openai-nosession" | "openrouter";
|
|
56
44
|
export interface ProviderResponse {
|
|
57
45
|
status: number;
|
|
58
46
|
headers: Record<string, string>;
|
|
@@ -264,11 +252,6 @@ export interface ImageApiOptionsMap {
|
|
|
264
252
|
* type; custom API strings fall back to the generic shape.
|
|
265
253
|
*/
|
|
266
254
|
export type ImageApiOptions<TApi extends ImageApi> = TApi extends keyof ImageApiOptionsMap ? ImageApiOptionsMap[TApi] : ProviderImagesOptions;
|
|
267
|
-
export interface AnthropicAllowedFallbackModel {
|
|
268
|
-
provider: ProviderId;
|
|
269
|
-
model: string;
|
|
270
|
-
cost: ModelCost;
|
|
271
|
-
}
|
|
272
255
|
export interface SimpleStreamOptions extends StreamOptions {
|
|
273
256
|
/** Provider-neutral tool selection for simple requests. When omitted, adapters use provider-specific behavior. */
|
|
274
257
|
toolChoice?: ToolChoice;
|
|
@@ -692,353 +675,6 @@ export type AssistantMessageEvent = {
|
|
|
692
675
|
reason: Extract<StopReason, "aborted" | "error">;
|
|
693
676
|
error: AssistantMessage;
|
|
694
677
|
};
|
|
695
|
-
/**
|
|
696
|
-
* Compatibility settings for OpenAI-compatible completions APIs.
|
|
697
|
-
* Use this to override URL-based auto-detection for custom providers.
|
|
698
|
-
*/
|
|
699
|
-
export interface OpenAICompletionsCompat {
|
|
700
|
-
/** Whether the provider supports the `store` field. Default: auto-detected from URL. */
|
|
701
|
-
supportsStore?: boolean;
|
|
702
|
-
/** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */
|
|
703
|
-
supportsDeveloperRole?: boolean;
|
|
704
|
-
/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */
|
|
705
|
-
supportsReasoningEffort?: boolean;
|
|
706
|
-
/**
|
|
707
|
-
* Whether the model accepts the `temperature` request field. Claude Fable 5.1 rejects
|
|
708
|
-
* non-default `temperature`, `top_p`, and `top_k` on every request, and OpenRouter's own
|
|
709
|
-
* `supported_parameters` for that model omits `temperature`. When false, the provider
|
|
710
|
-
* omits `temperature` and also strips `temperature`, `top_p`, and `top_k` from
|
|
711
|
-
* `samplingParams`, which is otherwise merged last and would reopen them.
|
|
712
|
-
* Default: true.
|
|
713
|
-
*/
|
|
714
|
-
supportsTemperature?: boolean;
|
|
715
|
-
/**
|
|
716
|
-
* Whether the model accepts forced tool use (`tool_choice` `"required"` or
|
|
717
|
-
* `{ type: "function", ... }`). Claude Fable 5.1 rejects it on every request, whichever
|
|
718
|
-
* platform serves the model. When false, the provider rejects a forced choice with an error
|
|
719
|
-
* rather than sending a request the model cannot honor. `"auto"` and `"none"` are never
|
|
720
|
-
* altered. https://platform.claude.com/docs/en/build-with-claude/thinking
|
|
721
|
-
* Default: true.
|
|
722
|
-
*/
|
|
723
|
-
supportsForcedToolChoice?: boolean;
|
|
724
|
-
/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */
|
|
725
|
-
supportsUsageInStreaming?: boolean;
|
|
726
|
-
/** Whether streamed responses include `finish_reason`. When false, pi infers `stop` or `toolUse` when the stream ends. Default: true. */
|
|
727
|
-
supportsFinishReason?: boolean;
|
|
728
|
-
/** Which field to use for max tokens. Default: auto-detected from URL. */
|
|
729
|
-
maxTokensField?: "max_completion_tokens" | "max_tokens";
|
|
730
|
-
/** Whether tool results require the `name` field. Default: auto-detected from URL. */
|
|
731
|
-
requiresToolResultName?: boolean;
|
|
732
|
-
/** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */
|
|
733
|
-
requiresAssistantAfterToolResult?: boolean;
|
|
734
|
-
/** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */
|
|
735
|
-
requiresThinkingAsText?: boolean;
|
|
736
|
-
/** Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. */
|
|
737
|
-
requiresReasoningContentOnAssistantMessages?: boolean;
|
|
738
|
-
/** Format for reasoning/thinking parameter. "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: boolean, "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: string, and "ant-ling" uses reasoning: { effort } only when the mapped effort is non-null. Default: "openai". */
|
|
739
|
-
thinkingFormat?: "openai" | "openrouter" | "deepseek" | "together" | "baseten" | "zai" | "qwen" | "chat-template" | "qwen-chat-template" | "string-thinking" | "ant-ling";
|
|
740
|
-
/** Kwargs to send as `chat_template_kwargs` when `thinkingFormat` is `chat-template`. Use `{ "$var": "thinking.enabled" }`, `{ "$var": "thinking.effort" }`, or `{ "$var": "thinking.budget" }` for pi-controlled thinking values. */
|
|
741
|
-
chatTemplateKwargs?: Record<string, ChatTemplateKwargValue>;
|
|
742
|
-
/** Arguments to send as `chat_template_args` when `thinkingFormat` is `baseten`. Use `{ "$var": "thinking.enabled" }`, `{ "$var": "thinking.effort" }`, or `{ "$var": "thinking.budget" }` for pi-controlled thinking values. */
|
|
743
|
-
chatTemplateArgs?: Record<string, ChatTemplateKwargValue>;
|
|
744
|
-
/** OpenRouter-compatible routing preferences sent as the `provider` request field. */
|
|
745
|
-
openRouterRouting?: OpenRouterRouting;
|
|
746
|
-
/** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */
|
|
747
|
-
vercelGatewayRouting?: VercelGatewayRouting;
|
|
748
|
-
/** Whether z.ai supports top-level `tool_stream: true` for streaming tool call deltas. Default: false. */
|
|
749
|
-
zaiToolStream?: boolean;
|
|
750
|
-
/**
|
|
751
|
-
* Top-level request field used to cap reasoning tokens from `thinkingBudgets`.
|
|
752
|
-
* Reasoning and the answer share `max_tokens` on these endpoints, so without a budget a
|
|
753
|
-
* reasoning-heavy turn can consume the whole response and emit no answer.
|
|
754
|
-
* `"thinking_token_budget"` is vLLM, `"thinking_budget"` is Qwen/DashScope/SGLang,
|
|
755
|
-
* `"thinking_budget_tokens"` is llama.cpp. Off by default; not set on the generated catalog.
|
|
756
|
-
*/
|
|
757
|
-
thinkingTokenBudgetField?: ThinkingTokenBudgetField;
|
|
758
|
-
/** Alias for `thinkingTokenBudgetField: "thinking_token_budget"` (vLLM). Prefer `thinkingTokenBudgetField`. Default: false. */
|
|
759
|
-
supportsThinkingTokenBudget?: boolean;
|
|
760
|
-
/** Whether the provider supports OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */
|
|
761
|
-
supportsOpenAIGrammarTools?: boolean;
|
|
762
|
-
/** 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. Default: false; the generated model catalog enables it for verified models. */
|
|
763
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
764
|
-
/** Whether system messages can introduce additional tools mid-conversation. Requires `supportsMidConvoSystemMessages`. Default: false; the generated model catalog enables it for capable models. */
|
|
765
|
-
supportsMidConvoToolAdditions?: boolean;
|
|
766
|
-
/** Whether the provider supports the `strict` field in tool definitions. Default: false; generated capable models enable it explicitly. */
|
|
767
|
-
supportsStrictMode?: boolean;
|
|
768
|
-
/** Cache control convention for prompt caching. "anthropic" applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. */
|
|
769
|
-
cacheControlFormat?: "anthropic";
|
|
770
|
-
/** Whether to send session-affinity data from `options.sessionId`. Default: true for OpenRouter endpoints, false otherwise. */
|
|
771
|
-
sendSessionAffinityHeaders?: boolean;
|
|
772
|
-
/** 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 the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */
|
|
773
|
-
sessionAffinityFormat?: SessionAffinityFormat;
|
|
774
|
-
/** Whether the provider supports long prompt cache retention (`prompt_cache_retention: "24h"` or Anthropic-style `cache_control.ttl: "1h"`, depending on format). Default: true. */
|
|
775
|
-
supportsLongCacheRetention?: boolean;
|
|
776
|
-
/**
|
|
777
|
-
* vLLM scheduler priority sent as the top-level `priority` request field (lower values are
|
|
778
|
-
* handled earlier; server default 0). Only meaningful when vLLM runs with
|
|
779
|
-
* `--scheduling-policy priority`; useful for keeping background/batch work from stalling
|
|
780
|
-
* interactive sessions. Off by default; not set on the generated catalog.
|
|
781
|
-
*/
|
|
782
|
-
vllmPriority?: number;
|
|
783
|
-
}
|
|
784
|
-
/** Compatibility settings for OpenAI Responses APIs. */
|
|
785
|
-
export interface OpenAIResponsesCompat {
|
|
786
|
-
/** Whether the provider supports the `developer` role (vs `system`). Default: true. */
|
|
787
|
-
supportsDeveloperRole?: boolean;
|
|
788
|
-
/** Whether the exact model accepts developer or system messages after the conversation has started. When false, later system messages are folded into the leading system message. Default: false; the generated model catalog enables it for verified models. */
|
|
789
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
790
|
-
/** 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 the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */
|
|
791
|
-
sessionAffinityFormat?: SessionAffinityFormat;
|
|
792
|
-
/** 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. Default: true. */
|
|
793
|
-
supportsLongCacheRetention?: boolean;
|
|
794
|
-
/** Whether the provider supports strict JSON-schema function tools. Defaults are API-specific; generated OpenAI models enable it explicitly. */
|
|
795
|
-
supportsStrictMode?: boolean;
|
|
796
|
-
/** Whether to emit OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */
|
|
797
|
-
supportsOpenAIGrammarTools?: boolean;
|
|
798
|
-
/** Whether the model supports message-anchored `additional_tools` input items. Default: false. */
|
|
799
|
-
supportsAdditionalTools?: boolean;
|
|
800
|
-
/** Whether the model supports client-executed tool search for transcript-anchored additions. Default: false. */
|
|
801
|
-
supportsToolSearch?: boolean;
|
|
802
|
-
/** Whether the model accepts `prompt_cache_options` (OpenAI GPT-5.6+ prompt caching). Older OpenAI models reject the parameter. Default: false. */
|
|
803
|
-
supportsExplicitPromptCacheMode?: boolean;
|
|
804
|
-
/** Whether the provider accepts the `max_output_tokens` parameter. Some Codex-protocol gateways reject it. Default: true. */
|
|
805
|
-
supportsMaxOutputTokens?: boolean;
|
|
806
|
-
}
|
|
807
|
-
/** Compatibility settings for Anthropic Messages-compatible APIs. */
|
|
808
|
-
export interface AnthropicMessagesCompat {
|
|
809
|
-
/**
|
|
810
|
-
* Whether the provider accepts per-tool `eager_input_streaming`.
|
|
811
|
-
* When false, the Anthropic provider omits `tools[].eager_input_streaming`
|
|
812
|
-
* and sends the legacy `fine-grained-tool-streaming-2025-05-14` beta header
|
|
813
|
-
* for tool-enabled requests.
|
|
814
|
-
* Default: true.
|
|
815
|
-
*/
|
|
816
|
-
supportsEagerToolInputStreaming?: boolean;
|
|
817
|
-
/** Whether the provider supports Anthropic long cache retention (`cache_control.ttl: "1h"`). Default: true. */
|
|
818
|
-
supportsLongCacheRetention?: boolean;
|
|
819
|
-
/**
|
|
820
|
-
* Whether to send a session-affinity header from `options.sessionId`
|
|
821
|
-
* when caching is enabled. Required for providers like Fireworks that use
|
|
822
|
-
* session affinity for prompt cache routing (requests to the same replica
|
|
823
|
-
* maximize cache hits).
|
|
824
|
-
* Default: true for OpenRouter endpoints, false otherwise.
|
|
825
|
-
*/
|
|
826
|
-
sendSessionAffinityHeaders?: boolean;
|
|
827
|
-
/** Session-affinity format. `"openrouter"` sends `x-session-id`; defaults to that format for OpenRouter endpoints and `x-session-affinity` elsewhere. */
|
|
828
|
-
sessionAffinityFormat?: "openrouter";
|
|
829
|
-
/**
|
|
830
|
-
* Whether the provider supports Anthropic-style `cache_control` markers on
|
|
831
|
-
* tool definitions. When false, `cache_control` is omitted from tool params.
|
|
832
|
-
* Some Anthropic-compatible providers (e.g., Fireworks) do not support this
|
|
833
|
-
* field on tools and may reject or ignore it.
|
|
834
|
-
* Default: true.
|
|
835
|
-
*/
|
|
836
|
-
supportsCacheControlOnTools?: boolean;
|
|
837
|
-
/**
|
|
838
|
-
* Whether the model accepts the Anthropic `temperature` request field.
|
|
839
|
-
* Claude Opus 4.7+ rejects non-default temperature values.
|
|
840
|
-
* Default: true.
|
|
841
|
-
*/
|
|
842
|
-
supportsTemperature?: boolean;
|
|
843
|
-
/**
|
|
844
|
-
* Whether to force adaptive thinking (`thinking.type: "adaptive"` plus
|
|
845
|
-
* `output_config.effort`) regardless of the model id. Built-in models that
|
|
846
|
-
* require adaptive thinking set this in generated metadata. Custom
|
|
847
|
-
* Anthropic-compatible providers can set this to `true` for any model whose
|
|
848
|
-
* upstream requires the adaptive format. Set to `false` to
|
|
849
|
-
* opt out on overridden built-in models.
|
|
850
|
-
* Default: false.
|
|
851
|
-
*/
|
|
852
|
-
forceAdaptiveThinking?: boolean;
|
|
853
|
-
/** Whether to replay empty thinking signatures as `signature: ""` instead of converting thinking to text. Default: false. */
|
|
854
|
-
allowEmptySignature?: boolean;
|
|
855
|
-
/** Whether the provider supports Anthropic strict tool schemas. Default: false; generated Anthropic models enable it explicitly. */
|
|
856
|
-
supportsStrictTools?: boolean;
|
|
857
|
-
/** Whether the exact model transport supports effort-only system messages and thinking binding controls. Default: false. */
|
|
858
|
-
supportsMidConvoEffort?: boolean;
|
|
859
|
-
/** Whether the exact model accepts system-role messages inside the conversation. When false, later system messages are folded into the top-level system prompt. Default: false. */
|
|
860
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
861
|
-
/** Whether the exact model accepts mid-conversation `tool_addition` blocks with inline tool definitions (`inline-tools-2026-09-15`) and `tool_removal` blocks. Requires `supportsMidConvoSystemMessages`. Default: false. */
|
|
862
|
-
supportsMidConvoToolChanges?: boolean;
|
|
863
|
-
/**
|
|
864
|
-
* Models Anthropic accepts in `fallbacks` for server-side refusal fallback,
|
|
865
|
-
* with local pricing metadata for returned fallback responses. When absent or
|
|
866
|
-
* empty, callers must omit `fallbacks`; Anthropic rejects the field for models
|
|
867
|
-
* with no permitted fallback targets.
|
|
868
|
-
*/
|
|
869
|
-
allowedFallbackModels?: AnthropicAllowedFallbackModel[];
|
|
870
|
-
/**
|
|
871
|
-
* Whether the model runs Anthropic's preserved-thinking *conversation* check, which
|
|
872
|
-
* rejects a request whose `system` prompt, `tools`, or earlier messages changed since a
|
|
873
|
-
* replayed thinking block was produced. When true the provider sends the
|
|
874
|
-
* `thinking-binding-controls-2026-08-01` beta header and
|
|
875
|
-
* `thinking.block_binding.prefix_mismatch_behavior: "drop_block"`, so a changed prefix
|
|
876
|
-
* drops the affected thinking blocks instead of failing the request with a 400.
|
|
877
|
-
* Enforced by default for Anthropic accounts created on or after 2026-08-31.
|
|
878
|
-
* Default: false.
|
|
879
|
-
*/
|
|
880
|
-
enforcesPreservedThinkingBinding?: boolean;
|
|
881
|
-
/**
|
|
882
|
-
* Whether the API adjudicates thinking-block *model* binding itself, always dropping a
|
|
883
|
-
* block the target model cannot read. When true, an assistant turn produced by a
|
|
884
|
-
* different model on the same provider and API replays its signed `thinking` and
|
|
885
|
-
* `redacted_thinking` blocks unchanged rather than being rewritten into plain text, so a
|
|
886
|
-
* mid-conversation model switch keeps reasoning the target model is allowed to read.
|
|
887
|
-
* Default: false.
|
|
888
|
-
*/
|
|
889
|
-
delegatesThinkingModelBinding?: boolean;
|
|
890
|
-
/**
|
|
891
|
-
* Whether the model accepts forced tool use (`tool_choice: {"type": "any"}` or
|
|
892
|
-
* `{"type": "tool", ...}`). Claude Fable 5.1 and Claude Mythos 5.1 reject it on every
|
|
893
|
-
* request with a 400; Anthropic's guidance for those models is to use
|
|
894
|
-
* `tool_choice: {"type": "auto"}` with strict tool use or structured outputs instead.
|
|
895
|
-
* When false, the provider rejects a forced choice with an error rather than sending a
|
|
896
|
-
* request the model is guaranteed to refuse, or silently substituting a different one.
|
|
897
|
-
* `auto` and `none` are never altered.
|
|
898
|
-
* https://platform.claude.com/docs/en/build-with-claude/thinking
|
|
899
|
-
* Default: true.
|
|
900
|
-
*/
|
|
901
|
-
supportsForcedToolChoice?: boolean;
|
|
902
|
-
}
|
|
903
|
-
/** Compatibility settings for Amazon Bedrock models. */
|
|
904
|
-
export interface BedrockCompat {
|
|
905
|
-
/** Whether the model supports Bedrock strict tool schemas. Default: false. */
|
|
906
|
-
supportsStrictMode?: boolean;
|
|
907
|
-
/**
|
|
908
|
-
* Whether the model accepts forced tool use (`toolChoice` `"any"` or `{ type: "tool" }`).
|
|
909
|
-
* Claude Fable 5.1 rejects it on every request with a 400, whichever platform serves the
|
|
910
|
-
* model. When false, the provider rejects a forced choice with an error rather than sending
|
|
911
|
-
* a request that is guaranteed to fail. `auto` and `none` are never altered.
|
|
912
|
-
* https://platform.claude.com/docs/en/build-with-claude/thinking
|
|
913
|
-
* Default: true.
|
|
914
|
-
*/
|
|
915
|
-
supportsForcedToolChoice?: boolean;
|
|
916
|
-
/**
|
|
917
|
-
* Whether the model accepts `inferenceConfig.temperature`. Claude Fable 5.1 rejects
|
|
918
|
-
* non-default `temperature`, `top_p`, and `top_k` on every request. When false, the
|
|
919
|
-
* provider omits the field.
|
|
920
|
-
* Default: true.
|
|
921
|
-
*/
|
|
922
|
-
supportsTemperature?: boolean;
|
|
923
|
-
}
|
|
924
|
-
/** Compatibility settings for the Mistral chat API. */
|
|
925
|
-
export interface MistralConversationsCompat {
|
|
926
|
-
/** Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message. Default: false. */
|
|
927
|
-
supportsMidConvoSystemMessages?: boolean;
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* OpenRouter provider routing preferences.
|
|
931
|
-
* Controls which upstream providers OpenRouter routes requests to.
|
|
932
|
-
* Sent as the `provider` field in the OpenRouter API request body.
|
|
933
|
-
* @see https://openrouter.ai/docs/guides/routing/provider-selection
|
|
934
|
-
*/
|
|
935
|
-
export interface OpenRouterRouting {
|
|
936
|
-
/** Whether to allow backup providers to serve requests. Default: true. */
|
|
937
|
-
allow_fallbacks?: boolean;
|
|
938
|
-
/** Whether to filter providers to only those that support all parameters in the request. Default: false. */
|
|
939
|
-
require_parameters?: boolean;
|
|
940
|
-
/** Data collection setting. "allow" (default): allow providers that may store/train on data. "deny": only use providers that don't collect user data. */
|
|
941
|
-
data_collection?: "deny" | "allow";
|
|
942
|
-
/** Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. */
|
|
943
|
-
zdr?: boolean;
|
|
944
|
-
/** Whether to restrict routing to only models that allow text distillation. */
|
|
945
|
-
enforce_distillable_text?: boolean;
|
|
946
|
-
/** An ordered list of provider names/slugs to try in sequence, falling back to the next if unavailable. */
|
|
947
|
-
order?: string[];
|
|
948
|
-
/** List of provider names/slugs to exclusively allow for this request. */
|
|
949
|
-
only?: string[];
|
|
950
|
-
/** List of provider names/slugs to skip for this request. */
|
|
951
|
-
ignore?: string[];
|
|
952
|
-
/** A list of quantization levels to filter providers by (e.g., ["fp16", "bf16", "fp8", "fp6", "int8", "int4", "fp4", "fp32"]). */
|
|
953
|
-
quantizations?: string[];
|
|
954
|
-
/** Sorting strategy. Can be a string (e.g., "price", "throughput", "latency") or an object with `by` and `partition`. */
|
|
955
|
-
sort?: string | {
|
|
956
|
-
/** The sorting metric: "price", "throughput", "latency". */
|
|
957
|
-
by?: string;
|
|
958
|
-
/** Partitioning strategy: "model" (default) or "none". */
|
|
959
|
-
partition?: string | null;
|
|
960
|
-
};
|
|
961
|
-
/** Maximum price per million tokens (USD). */
|
|
962
|
-
max_price?: {
|
|
963
|
-
/** Price per million prompt tokens. */
|
|
964
|
-
prompt?: number | string;
|
|
965
|
-
/** Price per million completion tokens. */
|
|
966
|
-
completion?: number | string;
|
|
967
|
-
/** Price per image. */
|
|
968
|
-
image?: number | string;
|
|
969
|
-
/** Price per audio unit. */
|
|
970
|
-
audio?: number | string;
|
|
971
|
-
/** Price per request. */
|
|
972
|
-
request?: number | string;
|
|
973
|
-
};
|
|
974
|
-
/** Preferred minimum throughput (tokens/second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */
|
|
975
|
-
preferred_min_throughput?: number | {
|
|
976
|
-
/** Minimum tokens/second at the 50th percentile. */
|
|
977
|
-
p50?: number;
|
|
978
|
-
/** Minimum tokens/second at the 75th percentile. */
|
|
979
|
-
p75?: number;
|
|
980
|
-
/** Minimum tokens/second at the 90th percentile. */
|
|
981
|
-
p90?: number;
|
|
982
|
-
/** Minimum tokens/second at the 99th percentile. */
|
|
983
|
-
p99?: number;
|
|
984
|
-
};
|
|
985
|
-
/** Preferred maximum latency (seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */
|
|
986
|
-
preferred_max_latency?: number | {
|
|
987
|
-
/** Maximum latency in seconds at the 50th percentile. */
|
|
988
|
-
p50?: number;
|
|
989
|
-
/** Maximum latency in seconds at the 75th percentile. */
|
|
990
|
-
p75?: number;
|
|
991
|
-
/** Maximum latency in seconds at the 90th percentile. */
|
|
992
|
-
p90?: number;
|
|
993
|
-
/** Maximum latency in seconds at the 99th percentile. */
|
|
994
|
-
p99?: number;
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
/**
|
|
998
|
-
* Vercel AI Gateway routing preferences.
|
|
999
|
-
* Controls which upstream providers the gateway routes requests to.
|
|
1000
|
-
* @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options
|
|
1001
|
-
*/
|
|
1002
|
-
export interface VercelGatewayRouting {
|
|
1003
|
-
/** List of provider slugs to exclusively use for this request (e.g., ["bedrock", "anthropic"]). */
|
|
1004
|
-
only?: string[];
|
|
1005
|
-
/** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
|
|
1006
|
-
order?: string[];
|
|
1007
|
-
}
|
|
1008
|
-
export interface ModelCostRates {
|
|
1009
|
-
input: number;
|
|
1010
|
-
output: number;
|
|
1011
|
-
cacheRead: number;
|
|
1012
|
-
cacheWrite: number;
|
|
1013
|
-
}
|
|
1014
|
-
export interface ModelCostTier extends ModelCostRates {
|
|
1015
|
-
/** Use this tier for requests whose total input usage exceeds this token count. */
|
|
1016
|
-
inputTokensAbove: number;
|
|
1017
|
-
}
|
|
1018
|
-
export interface ModelCost extends ModelCostRates {
|
|
1019
|
-
/** Request-wide pricing tiers. The highest matching input threshold applies to the full request. */
|
|
1020
|
-
tiers?: ModelCostTier[];
|
|
1021
|
-
}
|
|
1022
|
-
export interface ModelImageResizeOptions {
|
|
1023
|
-
maxWidth?: number;
|
|
1024
|
-
maxHeight?: number;
|
|
1025
|
-
/** Maximum base64-encoded payload size in bytes. */
|
|
1026
|
-
maxBytes?: number;
|
|
1027
|
-
jpegQuality?: number;
|
|
1028
|
-
}
|
|
1029
|
-
export interface ModelImageInputLimits {
|
|
1030
|
-
/** Cache-safe resize profile applied before a new image enters conversation history. */
|
|
1031
|
-
resize?: ModelImageResizeOptions;
|
|
1032
|
-
/** Maximum images accepted in one provider message. */
|
|
1033
|
-
maxPerMessage?: number;
|
|
1034
|
-
/** Maximum images accepted across one provider request. */
|
|
1035
|
-
maxPerRequest?: number;
|
|
1036
|
-
}
|
|
1037
|
-
export interface ModelInputLimits {
|
|
1038
|
-
/** Maximum serialized provider request size in bytes. */
|
|
1039
|
-
maxRequestBytes?: number;
|
|
1040
|
-
images?: ModelImageInputLimits;
|
|
1041
|
-
}
|
|
1042
678
|
/** Service tiers a model can advertise beyond standard processing. */
|
|
1043
679
|
export type ModelServiceTierId = "priority" | "ultrafast";
|
|
1044
680
|
/**
|
|
@@ -1076,7 +712,7 @@ export interface BaseModel<TApi extends string> {
|
|
|
1076
712
|
api: TApi;
|
|
1077
713
|
provider: ProviderId;
|
|
1078
714
|
baseUrl: string;
|
|
1079
|
-
input:
|
|
715
|
+
input: ModelInputModality[];
|
|
1080
716
|
/** Provider input limits and cache-safe preprocessing metadata. */
|
|
1081
717
|
inputLimits?: ModelInputLimits;
|
|
1082
718
|
cost: ModelCost;
|