中文

Use any LLM API in coding tools: Claude Code, Codex, OpenCode, CC Switch, Cline

Answer

Covers 5 coding tools × 4 providers (DeepSeek, Alibaba Qwen (Model Studio), Moonshot AI (Kimi), Zhipu GLM (Z.ai)). Live-tested: DeepSeek × Claude Code and DeepSeek × Codex CLI (text + tool calls); DeepSeek × OpenCode, Cline CLI and the CC Switch preset (text calls); other combos follow official doc fields and are marked “to be verified”. (source · verified)

Claude Code

Claude Code reads ANTHROPIC_BASE_URL (endpoint override), ANTHROPIC_AUTH_TOKEN (sent as Bearer) or ANTHROPIC_API_KEY (X-Api-Key), and ANTHROPIC_MODEL; they can also go in the env block of ~/.claude/settings.json.

Codex CLI

Codex defines custom providers in user-level ~/.codex/config.toml via [model_providers.<id>] (name, base_url, env_key, wire_api); project-level .codex/config.toml cannot set model_provider(s).

OpenCode

OpenCode ships 75+ built-in providers including DeepSeek: run /connect in the TUI (key stored in ~/.local/share/opencode/auth.json) or set the provider's env var (e.g. DEEPSEEK_API_KEY). Any other OpenAI-compatible API goes in the provider block of opencode.json with npm @ai-sdk/openai-compatible, options.baseURL, options.apiKey as {env:VAR} (or /connect first) and a models map.

CC Switch

CC Switch is an all-in-one manager for Claude Code, Claude Desktop, Codex, Gemini CLI, Grok Build, OpenCode and more: one-click provider switching plus MCP / Skills / Prompts management, no hand-editing JSON / TOML / YAML.

Cline

In Cline (VS Code extension or the cline CLI) pick the “OpenAI Compatible” provider and enter the Base URL, API key and model ID; DeepSeek and others also have built-in providers. CLI: cline auth -p openai-compatible -b <base URL> -k <key> -m <model id>; settings go to ~/.cline/data/settings/providers.json.