Can I use Claude code with own LLM/non-claude APIs?
Posted by superloser48@reddit | LocalLLaMA | View on Reddit | 32 comments
Anybody using claude code with local LLMs/non-claude APIs - does it work and work well?
I really dont like opencode. I find the UX/permission management somehow better. Its hard to explain - really intangible. And I suspect that claude code uses less context (in default settings)
MikePounce@reddit
You should check out https://pi.dev/
I use it with llamacpp and Qwen3.6-27b-Q4.
By default it's in YOLO mode but it is so extensible and flexible, it can self modify. Just tell it how you want it to behave or look and it will code its own extensions.
redblood252@reddit
I used claude code with qwen mainly for the superpowers:brainstorming “skill”. Do you have templates for coding? Mainly design/spec/plan/review/refactor/reduce codebase size
MikePounce@reddit
It supports skills and extensions. There are plenty already available check out https://pi.dev/packages but the point is : just describe to it your dream extension/skill and it will extend itself for you.
SatoshiNotMe@reddit
Very easy via Env Vars as others said. I’ve collected the full instructions along with exact llama server configs for several local models here, mostly tested on my M1 Max 64GB MacBook:
https://pchalasani.github.io/claude-code-tools/integrations/local-llms/
Annual_Award1260@reddit
Yeah you just set the environment variables
export ANTHROPIC_BASE_URL=http://localhost:1234 export ANTHROPIC_AUTH_TOKEN=lmstudio
No where near claude opus but yeah it works
HiddenoO@reddit
It's worth noting that Claude Code is one of the worse harnesses even for Claude models, let alone for models it's not designed for. The only reasons it's so popular are that it was one of the first that was decent and that Claude models were at one point by far the best for agentic coding and the subscription would let you use them by far the cheapest.
hdhfhdnfkfjgbfj@reddit
I like how you included several alternatives and talking about the pros and cons of them and which you ultimately ended up using so that you shared the knowledge you gained in a credible way.
HiddenoO@reddit
Are you seriously acting entitled to an in-depth report from a random person on the internet?
hdhfhdnfkfjgbfj@reddit
I’m asking someone who’s making quite a bold claim a couple of lines about what’s better and why after saying Claude code is the worst.
I’ve only used codex, copilot, and Claude and Claude seemed on par with copilot and better than codex.
If someone is saying it’s the worst the least they can do is offer a line or two about what’s better so we can all improve - is this not a community to help each other or just to shit on things? Because if I want grumbling about things that are bad without practical insights I can speak to my grandparents.
HiddenoO@reddit
It's a bold claim to suggest that a harness built for a specific model and provider that doesn't even perform the best for that very model (see https://www.tbench.ai/leaderboard/terminal-bench/2.0) is not a good idea to use for other models? Some of its functionality literally breaks because it's built around Anthropic API endpoints outside of the harness itself.
Then why didn't you make a comment with that comparison if you compared Claude Code to alternatives with non-Anthropic models? Why do you demand that others do it for you?
I never said it's the worst, I said it's one of the worse, and there are already plenty alternatives mentioned by other people in this thread. Warning people reading the top response that it's probably not a good idea to use Claude Code with models it is literally not designed for is not "just shit[ting] on things".
It's crazy how entitled you're acting when you yourself didn't even attempt to contribute anything to this topic.
ActInternational5976@reddit
What are the best alternatives?
HiddenoO@reddit
From my experience, the "best" ones constantly change with how rapidly everything is being developed, but you're better off with pretty much any of the ones mentioned here or featured on https://www.tbench.ai/leaderboard/terminal-bench/2.0 that aren't built around a specific environment the way Claude Code is.
Environment doesn't just entail the model, but also other aspects such as API endpoints + tools (like search) that aren't part of the harness itself.
thlandgraf@reddit
Claude Code is locked to Anthropic — the binary itself, no provider override. Cline in VS Code is the closest match I've tried for that permission-managed agent feel against local LLMs (OpenAI-compatible API so anything OpenAI-shaped works — Ollama, LM Studio, vLLM, etc). Roo is a more autonomous fork of cline if you want fewer prompts. Aider if you'd rather stay terminal — different model (diff-based) but mature, runs against Ollama via LiteLLM cleanly.
superloser48@reddit (OP)
fyi - aider died a while back. abandoned by creator.
odragora@reddit
Last commit is 2 days ago, though.
Am I missing something?
thlandgraf@reddit
oh, RIP
Widget2049@reddit
what a slop. update your em dashses dataset, clanker. claude code has ENV override to use any antrophic-compatible api endpoint. also roocode is closing down, why are you recommending a deprecated software.
DavidXGA@reddit
You can, but you might want to consider opencode instead, which is designed for use with your own LLMs.
nic_tbone@reddit
If your goal with a local model is to keep your code out of the cloude it is not the one to use.
OpenCode out of the box will communicate with their free AI model which will learn off your data. If you haven't configured it correctly it will revert to the free cloud service. It requires extra effort by locking it down with a firewall rule, and being attentitive to what model is in use.
Ell2509@reddit
You mean if I use qwen3.6 35b in opencode, it still talks to their cloud model too?
nic_tbone@reddit
OpenCode requires that you get the configuration right, and that you pay attention to the model it uses. With no configuration, or an invalid configuration, it will talk to their free model that requires no login, and will learn from your data.
If you configure it correctly it will use whatever local model, or cloud model you choose.
I don't trust it due to the fact that its default config is a free model with no login and no real warning.
I also now give scrutiney to all similar tools. Its important that
1. They can be used with a local model
2. They won't fall back to some free service if not configured correctly.
It can be easy to overlook which model you are using, especially if you think it was already configured correctly.
There are three categories of tools like claude-code, opencode etc..
DavidXGA@reddit
But OP's alternative was Claude Code. It's obviously not worse than that.
nic_tbone@reddit
Claude-Code won't work with a cloude service unless you sign in. If you are tryign to use it locally, and never sign into the cloude it will be very obvious that its not using your local model because it won't work at all.
OpenCode will gladly talk to the free model it has configured by default if the configuration is incorrect. This can be as simple as not having the config file in the right location.
The problem with OpenCode is it can use a free model that has no login requirements that will train off your data. If one of the reasons you are using a local model is to keep your code out of the clodue, there is risk with OpenCode unless you are very diligent in making sure its using the right model. Claude-Code will not work at all if mis-configured unless you sign in to the cloude service. Copilot-cli works the same way in this regard.
FortiTree@reddit
TIL have you tried with PiCode? or whats your goto? I thought ClaudeCode or OpenCode is the best for local harness but now Im not so sure.
nic_tbone@reddit
I have not yet tried PiCode.
I have tried ClaudeCode and Copilot-cli with local llm with good results.
I never made it through an evalutation with OpenCode as I aborted the evaluation after I realized it would communicate with a free cloud model. I am still deciding on whether to give OpenCode another chance. If I create a firewall rule, and create it properly, it should prevent it from accessing the web at all which would eliminate/reduce the risk of accidentally communicating with the wrong model. The problem there is, what if being sure I made the fireall rule correctly and at some point it didn't get changed or reset. This is also under Windows where the possibility of Firewall rules being reset is a risk.
FortiTree@reddit
Yea pi.dev. I think it should be a lot simpler to fix any harness to your local model. Really dont need to fiddle with firewall rule and all. It's all open source so another person suggested to just have a model analyze it and spit out yhe exact way to control it.
DeltaSqueezer@reddit
It works, but a few things are broken and CC has massive prompts which take up a lot of context. I started experimenting with writing my own agent as a learning exercise and after 2 weeks, it has now replaced claude code as my default harness.
bharattrader@reddit
Really looking for good options. When I try claude code or even pi somehow unable to get performance. I am on mac mini m4 pro 64gb running qwen36 27b at 65536 ctx. Any help recommendations?
Zeta1Reticuli@reddit
You'd probably like pi.dev. It's lightweight and uses significantly less context with its system prompts.
comefaith@reddit
there's a piece of doc by deepseek that shows how to override env variables for claude code cli to make requests to antropic-like endpoint https://api-docs.deepseek.com/guides/coding_agents
SAPPHIR3ROS3@reddit
I don’t recommend claude code, it’s a shit software i guarantee you, there are better harnesses like codex, forgecode, hermes agent ecc. you can use your own models in all of them. Claude code is reall one of the worst harnesses you can find but if you really want to use claude code , yes you can use your own models there too, i am not exactly sure it has openai api compatibility but it should. As for the context it does use the same amount (kinda) of context in default settings, it just has a good compaction but nothing REALLY impressive
Spare-Ad-4810@reddit
https://github.com/Alishahryar1/free-claude-code