@@ -31,6 +31,16 @@ const DEFAULT_COST = {
3131 cache_write : 0 ,
3232} ;
3333
34+ type Protocol = "openai" | "anthropic" ;
35+
36+ // Providers we explicitly know how to route. Models from any provider not
37+ // listed here are skipped. Adding a provider is a one-line change here.
38+ const PROVIDERS = new Map < string , { protocol : Protocol } > ( [
39+ [ "openai" , { protocol : "openai" } ] ,
40+ [ "anthropic" , { protocol : "anthropic" } ] ,
41+ [ "deepseek" , { protocol : "anthropic" } ] ,
42+ ] ) ;
43+
3444type ModelDevEntry = {
3545 id ?: string ;
3646 name ?: string ;
@@ -97,10 +107,9 @@ export type ConfigModel = {
97107
98108function buildLookupMap ( modelsDevData : ModelsDevData ) {
99109 const byFullId = new Map < string , ModelDevEntry > ( ) ;
100- const allowedProviders = new Set ( [ "openai" , "anthropic" , "deepseek" ] ) ;
101110
102111 for ( const [ provider , providerData ] of Object . entries ( modelsDevData ) ) {
103- if ( ! allowedProviders . has ( provider ) || ! providerData ?. models ) continue ;
112+ if ( ! PROVIDERS . has ( provider ) || ! providerData ?. models ) continue ;
104113 for ( const [ modelId , entry ] of Object . entries ( providerData . models ) ) {
105114 byFullId . set ( `${ provider } /${ modelId } ` , entry ) ;
106115 }
@@ -156,10 +165,6 @@ export async function fetchHubModels(): Promise<HubResponse> {
156165 return res . json ( ) as Promise < HubResponse > ;
157166}
158167
159- function usesAnthropicApi ( provider : string ) : boolean {
160- return provider === "anthropic" || provider === "deepseek" ;
161- }
162-
163168export function buildConfigModels (
164169 modelsDevData : ModelsDevData ,
165170 hubData : HubResponse ,
@@ -169,9 +174,10 @@ export function buildConfigModels(
169174 const warnings : string [ ] = [ ] ;
170175
171176 for ( const [ provider , providerData ] of Object . entries ( hubData . providers ) ) {
172- if ( ! providerData ?. models ) continue ;
177+ const known = PROVIDERS . get ( provider ) ;
178+ if ( ! known || ! providerData ?. models ) continue ;
173179
174- const anthropic = usesAnthropicApi ( provider ) ;
180+ const anthropic = known . protocol === "anthropic" ;
175181
176182 for ( const [ modelId , hubModel ] of Object . entries ( providerData . models ) ) {
177183 const entry = resolveEntry ( provider , modelId , byFullId ) ;
0 commit comments