add crud for providers and models

This commit is contained in:
miloschwartz
2026-07-31 15:44:17 -04:00
parent 3d34ed70b0
commit f1a2da277e
27 changed files with 2241 additions and 3 deletions
+48
View File
@@ -0,0 +1,48 @@
export type AiProviderType = "openai" | "anthropic" | "bedrock" | "custom";
export type AiProviderAuthType = "bearer";
export type AiBudgetUnit = "usd" | "tokens";
type AiProviderDefaults = {
upstreamUrl: string;
authType: AiProviderAuthType;
};
export const AI_PROVIDER_DEFAULTS: Record<
Exclude<AiProviderType, "custom">,
AiProviderDefaults
> = {
openai: {
upstreamUrl: "https://api.openai.com/v1",
authType: "bearer"
},
anthropic: {
upstreamUrl: "https://api.anthropic.com",
authType: "bearer"
},
bedrock: {
upstreamUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
authType: "bearer"
}
};
export function resolveAiProviderConfig(input: {
type: AiProviderType;
upstreamUrl: string | null;
authType: AiProviderAuthType | null;
}): {
upstreamUrl: string | null;
authType: AiProviderAuthType | null;
} {
if (input.type === "custom") {
return {
upstreamUrl: input.upstreamUrl,
authType: input.authType
};
}
const defaults = AI_PROVIDER_DEFAULTS[input.type];
return {
upstreamUrl: input.upstreamUrl ?? defaults.upstreamUrl,
authType: input.authType ?? defaults.authType
};
}