feat(llm): unify OpenAI-compatible providers behind a registry + generic endpoint
The OpenAI-compatible family (openai, xAI, DeepSeek, Qwen, GLM, MiniMax, OpenRouter, Ollama) all speak the same Chat Completions API and differ only by base_url, key, and two narrow wire-format quirks already isolated in subclasses. Replace the scattered base-URL dict, key handling, and client-class branches with one ProviderSpec registry that get_llm and the factory drive off; provider quirks stay in their subclasses. Add a generic "openai_compatible" provider for any OpenAI-compatible server (vLLM, LM Studio, llama.cpp, relays) via backend_url + optional key — adding a provider is now one registry row. Native Anthropic/Google keep their own clients (genuinely different APIs). Also fixes the env backend URL being ignored when the provider was chosen interactively (#978).
This commit is contained in:
11 files changed
+301
-85
No files matched your search
@@ -32,6 +32,10 @@ PROVIDER_API_KEY_ENV: dict[str, Optional[str]] = {
|
||||
"openrouter": "OPENROUTER_API_KEY",
|
||||
# Local runtimes do not authenticate.
|
||||
"ollama": None,
|
||||
# Generic OpenAI-compatible endpoint: the client reads this when set (keyed
|
||||
# relays), but it is marked key-optional in the provider registry so the CLI
|
||||
# never forces a prompt and keyless local servers still work.
|
||||
"openai_compatible": "OPENAI_COMPATIBLE_API_KEY",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user