| 20 | } |
| 21 | |
| 22 | export function getProviderSettings( |
| 23 | provider: SupportedProvider, |
| 24 | apiKey: string | undefined, |
| 25 | model: string | undefined, |
| 26 | ): RooCodeSettings { |
| 27 | const config: RooCodeSettings = { apiProvider: provider } |
| 28 | |
| 29 | switch (provider) { |
| 30 | case "anthropic": |
| 31 | if (apiKey) config.apiKey = apiKey |
| 32 | if (model) config.apiModelId = model |
| 33 | break |
| 34 | case "openai-native": |
| 35 | if (apiKey) config.openAiNativeApiKey = apiKey |
| 36 | if (model) config.apiModelId = model |
| 37 | break |
| 38 | case "gemini": |
| 39 | if (apiKey) config.geminiApiKey = apiKey |
| 40 | if (model) config.apiModelId = model |
| 41 | break |
| 42 | case "openrouter": |
| 43 | if (apiKey) config.openRouterApiKey = apiKey |
| 44 | if (model) config.openRouterModelId = model |
| 45 | break |
| 46 | case "vercel-ai-gateway": |
| 47 | if (apiKey) config.vercelAiGatewayApiKey = apiKey |
| 48 | if (model) config.vercelAiGatewayModelId = model |
| 49 | break |
| 50 | default: |
| 51 | if (apiKey) config.apiKey = apiKey |
| 52 | if (model) config.apiModelId = model |
| 53 | } |
| 54 | |
| 55 | return config |
| 56 | } |