Can I use local models with coding agents like Claude Code, Codex or OpenCode?
Often, yes. Many coding agents let you set a custom API base URL, and local servers such as exo expose OpenAI- and Anthropic-compatible endpoints. Point the agent at your local endpoint and choose a large open model that is strong at tool calling, such as a recent GLM, Kimi, DeepSeek or Qwen coding model.
OpenCode and the Codex CLI support custom providers through their config files. Claude Code reads ANTHROPIC_BASE_URL, which Anthropic documents for LLM gateways; it is designed for Claude models, so results with other models are not supported by Anthropic.
Coding agents send long prompts with many files. Prompt processing speed (prefill) and context length matter as much as generation speed. Test with a real task from your codebase.
Smaller models often fail at multi-step tool use. For agentic coding, prefer the largest model your hardware runs at a usable speed.
Sources
Updated
