feat: Support custom OpenAI-compatible providers (e.g. GLM/ZhiPu)
Problem
DeepSeek TUI has a hardcoded provider whitelist (DeepSeek, NVIDIA NIM, OpenRouter, Novita, Fireworks, SGLang). The openai provider appears in deepseek model list but is rejected at runtime:
error: The interactive TUI supports DeepSeek, NVIDIA NIM, OpenRouter, Novita, Fireworks, and SGLang providers.
This makes it impossible to use popular OpenAI-compatible providers like GLM (智谱/ZhiPu), Moonshot, Qwen, etc.
Steps to reproduce
- Configure openai provider with GLM endpoint:
provider = "openai" api_key = "glm-api-key" [providers.openai] base_url = "https://open.bigmodel.cn/api/coding/paas/v4" - Run
deepseek --provider openai --model glm-5 -p "hello" - Error: provider not supported
Workaround attempt: sglang provider
Tried using sglang provider with custom base_url pointing to GLM's endpoint. The model validation passes, but the path is wrong — sglang hardcodes /v1/chat/completions while GLM uses /v4/chat/completions:
info API base URL: https://open.bigmodel.cn/api/coding/paas
Error: HTTP 404 Not Found: {"path":"/v1/chat/completions"}
What's needed
- Enable the
openaiprovider in the TUI (it's already listed inmodel listbut blocked at runtime) - Or add a generic
customprovider that:- Uses user-provided
base_urlas-is - Passes model ID through without normalization
- Uses standard OpenAI-compatible
/v1/chat/completionspath (or allows custom path override)
- Uses user-provided
- Path override option: Some providers (like GLM coding plan) use non-standard paths (
/v4/instead of/v1/). A config likeapi_path = "/v4/chat/completions"would solve this.
Use case
GLM (智谱) Coding Plan API:
- Base URL:
https://open.bigmodel.cn/api/coding/paas/v4 - Endpoint:
/chat/completions(not/v1/chat/completions) - Models:
glm-4.7,glm-5,glm-5.1 - Auth: Bearer token
This is a widely used LLM provider in China with millions of developers. Supporting custom providers would also unlock Moonshot, Qwen, Baichuan, and other OpenAI-compatible APIs.
Environment
- deepseek-tui: 0.8.12
- OS: macOS (aarch64)
This is a common pain point with TUI-based LLM tools. The hardcoded provider whitelist blocks a large ecosystem of OpenAI-compatible endpoints.
For the path mismatch issue (GLM using /v4/chat/completions instead of /v1/chat/completions), a few approaches that work in practice:
-
API path override in config (cleanest):
[providers.custom] base_url = "https://open.bigmodel.cn/api/coding/paas" api_path = "/v4/chat/completions" # override default /v1/ -
Base URL trick: Some providers accept the version in the base URL itself. Setting
base_url = "https://open.bigmodel.cn/api/coding/paas/v4"and having the client append/chat/completions(without/v1/) can work if the HTTP client supports it. -
Reverse proxy: Run a local proxy that rewrites
/v1/chat/completions→/v4/chat/completions. Quick and dirty but works with any TUI.
The broader benefit of enabling custom providers: it unlocks the entire OpenAI-compatible ecosystem — GLM, Moonshot, Qwen, Mistral self-hosted, vLLM, SGLang, Ollama, and any gateway that speaks the OpenAI protocol. Most production LLM deployments now go through some form of OpenAI-compatible proxy.
注意:项目本身使用 deepseek v4 pdf 做了很多 v4 相关的优化,其他的模型未必能达到应有的效果。 Note: The project itself uses Deepseek v4 PDF and has made many v4-related optimizations. Other models may not be able to achieve the desired results.
yes, I am trying to figure out the best way forward with this - I appreciate your suggestion. I am also a huge fan of the GLM models and have considered adding them since they also do not have a dedicated coding terminal (that i'm aware of), but I am weighing the risks against the benfeits
glm5.1 基于deepseek-v3.2训练的,api兼容claude; 直接按官方的文档配置了在claude code/opencode等工具使用就可以了
https://docs.bigmodel.cn/cn/coding-plan/tool/others