basic provider model selector

This commit is contained in:
miloschwartz
2026-08-10 12:32:00 -04:00
parent 211d3a53f5
commit 93dea0525e
9 changed files with 209 additions and 27 deletions
+2 -19
View File
@@ -2,6 +2,7 @@ import type { AiProviderType } from "@server/lib/aiProviderDefaults";
import type { AiUsage } from "@server/lib/aiUsageExtraction";
import {
aiModelCatalog,
getCatalogProviderForType,
type AiModelCatalogEntry,
type CatalogProvider
} from "@server/lib/aiModelCatalog";
@@ -19,23 +20,6 @@ export type AiModelPricing = {
approximate: boolean;
};
// Each of our provider types maps to at most one catalog provider. Provider types that proxy
// arbitrary underlying models (openRouter, vercelAiGateway, custom) have no
// mapping and always fall back to a global search.
const PROVIDER_CATALOG_MAP: Record<
Exclude<AiProviderType, "custom">,
CatalogProvider | null
> = {
openai: "openai",
anthropic: "anthropic",
googleGemini: "gemini",
vertexAi: "vertex",
bedrock: "bedrock",
microsoftFoundry: "azure",
openRouter: null,
vercelAiGateway: null
};
function stripVendorPrefix(modelId: string): string | null {
const idx = modelId.indexOf("/");
if (idx === -1 || idx === modelId.length - 1) {
@@ -96,8 +80,7 @@ export function getModelPricing(
return null;
}
const catalogProvider =
providerType === "custom" ? null : PROVIDER_CATALOG_MAP[providerType];
const catalogProvider = getCatalogProviderForType(providerType);
if (catalogProvider) {
const scoped = findEntry(modelId, catalogProvider);