mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
feat(cli): add openai provider support for OpenAI-compatible endpoints
Add the `openai` provider to the CLI's supported providers list, enabling use of OpenAI-compatible API endpoints (e.g., locally deployed LLMs via vLLM, llama.cpp, Ollama, LM Studio, etc.). Changes: - Add "openai" to supportedProviders in types.ts - Add "openai" env var mapping (OPENAI_API_KEY) in provider.ts - Add "openai" case in getProviderSettings() with support for OPENAI_BASE_URL environment variable for custom endpoints - Update README environment variable table The openai provider uses the existing @roo-code/types openAi schema (openAiBaseUrl, openAiApiKey, openAiModelId) which is already fully supported in the core extension via OpenAiHandler. Usage: export OPENAI_API_KEY=sk-local export OPENAI_BASE_URL=http://localhost:8080/v1 roo --provider openai --model my-model "Hello" Closes #11917
This commit is contained in:
parent
44fd975b17
commit
1e9c05a54a
3 changed files with 10 additions and 0 deletions
|
|
@ -215,10 +215,13 @@ The CLI will look for API keys in environment variables if not provided via `--a
|
|||
| roo | `ROO_API_KEY` |
|
||||
| anthropic | `ANTHROPIC_API_KEY` |
|
||||
| openai-native | `OPENAI_API_KEY` |
|
||||
| openai | `OPENAI_API_KEY` |
|
||||
| openrouter | `OPENROUTER_API_KEY` |
|
||||
| gemini | `GOOGLE_API_KEY` |
|
||||
| vercel-ai-gateway | `VERCEL_AI_GATEWAY_API_KEY` |
|
||||
|
||||
The `openai` provider also reads `OPENAI_BASE_URL` to set a custom API endpoint (e.g., `http://localhost:8080/v1` for locally deployed models).
|
||||
|
||||
**Authentication Environment Variables:**
|
||||
|
||||
| Variable | Description |
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import type { SupportedProvider } from "@/types/index.js"
|
|||
const envVarMap: Record<SupportedProvider, string> = {
|
||||
anthropic: "ANTHROPIC_API_KEY",
|
||||
"openai-native": "OPENAI_API_KEY",
|
||||
openai: "OPENAI_API_KEY",
|
||||
gemini: "GOOGLE_API_KEY",
|
||||
openrouter: "OPENROUTER_API_KEY",
|
||||
"vercel-ai-gateway": "VERCEL_AI_GATEWAY_API_KEY",
|
||||
|
|
@ -36,6 +37,11 @@ export function getProviderSettings(
|
|||
if (apiKey) config.openAiNativeApiKey = apiKey
|
||||
if (model) config.apiModelId = model
|
||||
break
|
||||
case "openai":
|
||||
if (apiKey) config.openAiApiKey = apiKey
|
||||
if (model) config.openAiModelId = model
|
||||
if (process.env.OPENAI_BASE_URL) config.openAiBaseUrl = process.env.OPENAI_BASE_URL
|
||||
break
|
||||
case "gemini":
|
||||
if (apiKey) config.geminiApiKey = apiKey
|
||||
if (model) config.apiModelId = model
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import type { OutputFormat } from "./json-events.js"
|
|||
export const supportedProviders = [
|
||||
"anthropic",
|
||||
"openai-native",
|
||||
"openai",
|
||||
"gemini",
|
||||
"openrouter",
|
||||
"vercel-ai-gateway",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue