Set Up a Switchable AI Coding CLI with Domestic LLMs in 10 Minutes

    This article walks you through building an AI coding command-line workflow whose model layer can be swapped on demand. Starting from why a replaceable model layer matters, it explains a three-layer structure (runtime, tooling, provider configuration), how to prepare your runtime and version-control environment, how to install and safely verify the coding agent CLI, and how to manage multiple provider profiles with either a GUI switcher or shell-based commands. It also covers connecting domestic LLMs directly, through a unified gateway such as Baidu AI Cloud, or via a local protocol adapter, plus a JSON configuration template, environment-variable key handling, a minimal connectivity check, common troubleshooting cases, team and production recommendations, and a 10-minute timeline.

    Set Up a Switchable AI Coding CLI with Domestic LLMs in 10 Minutes

    1. Why These 10 Minutes Are Worth It

    Most people get stuck on two questions: how do you actually install a command-line AI coding tool, and once it is installed, can you replace the default overseas API endpoints with a domestic large language model (LLM)? These are really two sides of the same coin — whether your toolchain is usable and whether it stays under your control.

    • Usability determines whether you have an entry point to AI-assisted coding at all. Tools of this kind do much more than autocomplete: they read project context, edit across multiple files, and run tests, making them far more valuable than single-point completion.
    • Controllability determines whether you will still be using that entry point a year from now. Once the model endpoint, API key, and model name are hard-coded into a config file, you are locked into a single vendor. Move those parameters into switchable “provider configurations” and the choice of model is back in your hands.

    So the right goal is not “install a tool” but build an AI coding pipeline with a replaceable model layer: keep the tool layer stable and let the model layer follow your needs. Domestic LLMs are now practical for understanding Chinese technical documentation, handling long contexts, function calling, and data-compliance requirements. Plugging them into the same pipeline is a cost-effective choice today.

    2. The Big Picture: Three Layers, One Configuration

    Breaking the setup into three layers helps you avoid the back-and-forth of discovering a missing dependency halfway through:

    Layer Role How often it changes
    Runtime layer Script runtime and version management that the CLI depends on Almost never
    Tool layer The AI coding CLI agent — understands requests, edits code, runs commands With each version upgrade
    Configuration layer Endpoints, keys, and model names for multiple providers, switchable in one step As needed

    Key design principle: decouple the configuration layer from the tool layer. The tool only cares about “the currently active endpoint + key + model name”; the configuration layer decides which vendor that points to. Switching models therefore requires reinstalling nothing.

    3. Preparation: Check Your Runtime and Version Control

    Confirm the prerequisites first, and skip anything already installed.

    Run the following in your terminal (below, <runtime> and <vcs> are placeholders — substitute the actual runtime and version-control commands):

    1. <runtime> --version
    2. <package-manager> --version
    3. <vcs> --version

    If all three commands print a version number, your environment is ready. Install anything that is missing using your operating system’s package manager where possible; if the package manager is unavailable, get the installer from the project’s official channels.

    Two practical points:

    1. Prefer long-term support (LTS) releases. AI coding tools usually require a fairly recent runtime, and versions that are too old will cause dependency-install failures or syntax incompatibilities.
    2. Do not install global packages with administrator privileges by default. Installing as root/Administrator leaves files with mixed permissions outside your home directory, and upgrades tend to fail later. Instead, use a runtime version manager to point the global package directory at a user-writable path so no administrator rights are needed.

    4. Install the AI Coding CLI

    With dependencies in place, install the tool itself and do a minimal verification:

    1. <package-manager> install -g <coding-agent-cli>
    2. <coding-agent-cli> --version

    Then launch it inside your project:

    1. cd <your-project>
    2. <coding-agent-cli>

    The first time you enter a directory, most tools of this kind will do two things: ask you to trust the directory, and declare file read/write and command-execution permissions. Confirm each item individually, and never grant a high-permission mode by default in a project directory you do not understand. Most tools offer two working modes: a plan mode that only reads and analyzes, and an auto-approve mode that can execute changes. For a new directory, get the flow working in plan mode first, then open up execution permissions.

    One more thing worth knowing: the ceiling on what these tools can do depends on how well the connected model supports function calling (tool use). If a model does not support structured tool calls, the tool degrades into “a chatbot that generates code,” and cross-file edits become visibly unreliable. When choosing a model, this matters more than leaderboard scores.

    5. Install a Visualization Tool for Switching Profiles

    Editing the config file by hand works, but editing environment variables on every switch is error-prone. A visual switcher earns its place by centralizing multiple profiles, activating them in one click, and making rollback easy. Two options:

    • Desktop application: download the installer for your operating system from the project’s official release channel, unzip or install it, and launch it by double-clicking. If a security warning about an “unidentified developer” appears, approve it in your system’s privacy and security settings rather than disabling system protections altogether.
    • Command line only: a few shell functions turn “switch” into a single command, for example switch provider_a. Under the hood this writes variables into the current shell session or a user-level config file. This suits server environments with no graphical interface.

    No graphical environment? Not a problem — write the configuration into a user-level config directory and switch it with environment variables.

    6. Connecting a Domestic Model: Three Options

    1. Connect directly to the vendor API. The most straightforward option, with the key and endpoint coming from a single vendor.
    2. Aggregate multiple models through a unified gateway. For example, use Baidu AI Cloud’s large-model platform to reach multiple domestic models, then point this tool at the unified gateway endpoint. One config change switches everything globally, and keys and usage are managed in one place.
    3. Run a local compatibility layer that converts protocols. When the interface style the tool expects does not match the target vendor, put a lightweight adapter service in front to translate between them. Use this only when direct connection and a gateway are both impractical — it becomes a new failure point and needs extra monitoring.

    7. Configuration Template and Field Reference

    Most tools support a user-level JSON configuration. A sketch of the structure (field names per the actual tool documentation):

    1. {
    2. "defaultProvider": "vendor-a",
    3. "providers": [
    4. {
    5. "id": "vendor-a",
    6. "baseUrl": "https://<vendor-a-endpoint>/v1",
    7. "apiKeyEnv": "VENDOR_A_API_KEY",
    8. "model": "<model-name>"
    9. },
    10. {
    11. "id": "vendor-b",
    12. "baseUrl": "https://<vendor-b-endpoint>/v1",
    13. "apiKeyEnv": "VENDOR_B_API_KEY",
    14. "model": "<model-name>"
    15. }
    16. ]
    17. }

    What the fields mean:

    • baseUrl: the base API address. Check whether the version path segment is already included — missing it or adding an extra one both lead to 404.
    • apiKeyEnv: the key lives in an environment variable and the config file only references the variable name. Keys must never be committed to a repository, written into scripts, or pasted into a chat tool. That is the bottom line.
    • model: the model identifier must match the vendor side exactly; casing and separators are both significant.

    On the environment-variable side:

    1. export VENDOR_A_API_KEY="<your-key>"

    To make the configuration take effect directly, you can also override it with environment variables using the same key names; precedence is defined by the tool documentation.

    8. Connectivity Self-Check

    After configuring, run a minimal connectivity test first so you do not mistake an API problem for a tool problem:

    1. import json, os, urllib.request
    2. base = os.environ["BASE_URL"].rstrip("/")
    3. payload = {
    4. "model": os.environ.get("MODEL", ""),
    5. "messages": [{"role": "user", "content": "ping"}],
    6. "max_tokens": 16,
    7. }
    8. req = urllib.request.Request(
    9. base + "/chat/completions",
    10. data=json.dumps(payload).encode(),
    11. headers={
    12. "Content-Type": "application/json",
    13. "Authorization": "Bearer " + os.environ["API_KEY"],
    14. },
    15. )
    16. with urllib.request.urlopen(req, timeout=20) as resp:
    17. print(resp.status, resp.read().decode()[:200])

    A 200 with content back means the endpoint, key, and model name are all correct. If you get 401/403, check the key and permissions; 404 points to the path; 429 means you hit rate limiting and need to back off and retry.

    9. Common Troubleshooting

    • Runtime version incompatibility at startup: upgrade to an LTS release rather than the newest non-LTS version.
    • Permission errors on global install: manage the global directory with a runtime version manager instead of using administrator privileges.
    • Still calling the old model after switching: the new session was not restarted, or an environment variable takes precedence over the config file — clear the session and verify again.
    • Long conversation suddenly fails or truncates: the context window is exceeded; compress the history or switch to a model with a longer context.
    • Poor quality cross-file edits: the model’s tool-calling ability is weak — switch models and narrow the scope of each task.
    • Empty content or garbled formatting: check whether incompatible sampling parameters or output-format constraints are enabled.

    10. Making It Work for a Team and in Production

    Once it works for you personally, turn it into a team asset: put the provider template under version control and inject keys through a secrets manager or CI environment variables; wire model calls into a logging service with monitoring and alerting, tracking token usage, success rate, and latency; keep a project-conventions file at the repository root (build, test, code style) so the tool works under one consistent set of standards. For scenarios that involve external output or sensitive data, prefer a domestic model service that supports keeping data local and can sign compliance agreements.

    11. The 10-Minute Timeline

    Stage Time Output
    Check runtime and version control 2 min Environment ready
    Install the tool and verify the version 3 min Tool launches
    Install the switcher 2 min Multiple profiles managed centrally
    Fill in config and run connectivity check 3 min Domestic model live

    Follow this schedule and you end up with an AI coding pipeline whose model layer is replaceable: the tool layer stays stable, and you use whichever model you want.