Why swap the model at all
Cost
GLM and DeepSeek can be dramatically cheaper per token for everyday coding work.
Availability
When one provider is capped, rate-limited, or down, a second model keeps you moving.
Privacy / control
A local or self-hosted model keeps code on your own machine or network.
How model routing works
Under the hood, a coding agent sends chat-completion requests to a model endpoint and runs the tool calls it gets back. If two providers speak the same API shape — and most speak the OpenAI-compatible one — swapping between them is just changing three things: the base URL, the API key, and the model name. The agent loop doesn't care which model is behind the endpoint.
What you typically set
| Field | Example | Notes |
|---|---|---|
| Base URL | https://…/v1 | The provider's OpenAI-compatible endpoint |
| API key | your own key | Billed to you as usage |
| Model name | glm-4.7 / deepseek-chat / your local model | Whatever that endpoint exposes |
The catch: not every client lets you
The blocker is usually the client, not the model. An agent hard-wired to one provider won't let you change the endpoint, so you're stuck on that provider's pricing and limits. To route freely you need a client that's built to bring your own model — where the provider, base URL, and key are settings, not fixed.
Running a local model
For a fully local setup, serve a model with something that exposes an OpenAI-compatible API (for example vLLM), then point the agent's base URL at your local server. Now your code never leaves your machine and there's no per-token bill at all — you trade that for needing the hardware to run the model.
FAQ
Can I use GLM or DeepSeek instead of the default model?
Yes, if your client lets you set the base URL, key, and model name. Both GLM and DeepSeek expose OpenAI-compatible endpoints, so a client that supports custom providers can route to them directly.
Can a coding agent run a local model?
Yes — serve the model with an OpenAI-compatible server (like vLLM) and point the agent's base URL at your local endpoint. Your code stays on your machine and there's no per-token cost.
Why can't I change the model in my current agent?
Because it's hard-wired to one provider. To switch freely you need a client where the provider, base URL, and key are configurable settings rather than fixed values.