(configuration: ProviderSettings)
| 126 | } |
| 127 | |
| 128 | export function buildApiHandler(configuration: ProviderSettings): ApiHandler { |
| 129 | const { apiProvider, ...options } = configuration |
| 130 | |
| 131 | if (apiProvider === "roo") { |
| 132 | throw new Error(getRouterRemovalMessage()) |
| 133 | } |
| 134 | |
| 135 | if (apiProvider && isRetiredProvider(apiProvider)) { |
| 136 | throw new Error( |
| 137 | `Sorry, this provider is no longer supported. We saw very few Roo users actually using it and we need to reduce the surface area of our codebase so we can keep shipping fast and serving our community well in this space. It was a really hard decision but it lets us focus on what matters most to you. It sucks, we know.\n\nPlease select a different provider in your API profile settings.`, |
| 138 | ) |
| 139 | } |
| 140 | |
| 141 | switch (apiProvider) { |
| 142 | case "anthropic": |
| 143 | return new AnthropicHandler(options) |
| 144 | case "openrouter": |
| 145 | return new OpenRouterHandler(options) |
| 146 | case "bedrock": |
| 147 | return new AwsBedrockHandler(options) |
| 148 | case "vertex": |
| 149 | return options.apiModelId?.startsWith("claude") |
| 150 | ? new AnthropicVertexHandler(options) |
| 151 | : new VertexHandler(options) |
| 152 | case "openai": |
| 153 | return new OpenAiHandler(options) |
| 154 | case "ollama": |
| 155 | return new NativeOllamaHandler(options) |
| 156 | case "lmstudio": |
| 157 | return new LmStudioHandler(options) |
| 158 | case "gemini": |
| 159 | return new GeminiHandler(options) |
| 160 | case "openai-codex": |
| 161 | return new OpenAiCodexHandler(options) |
| 162 | case "openai-native": |
| 163 | return new OpenAiNativeHandler(options) |
| 164 | case "deepseek": |
| 165 | return new DeepSeekHandler(options) |
| 166 | case "qwen-code": |
| 167 | return new QwenCodeHandler(options) |
| 168 | case "moonshot": |
| 169 | return new MoonshotHandler(options) |
| 170 | case "vscode-lm": |
| 171 | return new VsCodeLmHandler(options) |
| 172 | case "mistral": |
| 173 | return new MistralHandler(options) |
| 174 | case "requesty": |
| 175 | return new RequestyHandler(options) |
| 176 | case "unbound": |
| 177 | return new UnboundHandler(options) |
| 178 | case "fake-ai": |
| 179 | return new FakeAIHandler(options) |
| 180 | case "xai": |
| 181 | return new XAIHandler(options) |
| 182 | case "litellm": |
| 183 | return new LiteLLMHandler(options) |
| 184 | case "sambanova": |
| 185 | return new SambaNovaHandler(options) |
no test coverage detected