(modelId: string)
| 109 | } |
| 110 | |
| 111 | export function getZenLanguageModel(modelId: string): SupportedModel { |
| 112 | const normalized = normalizeModelId(modelId); |
| 113 | const cacheKey = `zen:${normalized}`; |
| 114 | |
| 115 | if (modelCache.has(cacheKey)) { |
| 116 | return modelCache.get(cacheKey)!; |
| 117 | } |
| 118 | |
| 119 | const { openai, openaiCompatible, anthropic } = ensureProviders(); |
| 120 | const endpoint = inferEndpoint(normalized); |
| 121 | |
| 122 | let model: SupportedModel; |
| 123 | switch (endpoint) { |
| 124 | case "anthropic": |
| 125 | model = anthropic(normalized) as unknown as SupportedModel; |
| 126 | break; |
| 127 | case "responses": |
| 128 | model = openai.responses(normalized) as unknown as SupportedModel; |
| 129 | break; |
| 130 | case "chat": |
| 131 | default: |
| 132 | model = openaiCompatible.chatModel( |
| 133 | normalized, |
| 134 | ) as unknown as SupportedModel; |
| 135 | break; |
| 136 | } |
| 137 | |
| 138 | modelCache.set(cacheKey, model); |
| 139 | return model; |
| 140 | } |
no test coverage detected