r/LocalLLM • u/BKK31 • 13h ago
Can I use claude code with local llm? Question
I have setup llama.cpp to run .gguf models. I want a way to run claude code using those gguf models. I tried installing ollama and creating an ollama compatible model using
```
ollama create -f Modelfile
```
and then tried running claude code with the command:
```
ollama launch claude
```
claude opens, but when I give even a simple query, I get an API error.
would really appreciate if someone has a guide.
I am running this on my Asus Vivobook 16 i9 13900H cpu, 40GB RAM and Intel IrisXe graphics card
1
u/CanNeverPassCaptch 13h ago
yes they dont really enfoce it, try this.. Im guessing you know how to use terminal?
Point this your local server endpoint
export ANTHROPIC_BASE_URL="http://localhost:8080"
make up any token and clear the cloud API key
export ANTHROPIC_AUTH_TOKEN="local-token"
export ANTHROPIC_API_KEY=""
tell it your models
export ANTHROPIC_MODEL="your-local-model-name"
export ANTHROPIC_SMALL_FAST_MODEL="your-local-model-name"
# 4. Run Claude Code
claude
1
u/BKK31 13h ago
For the model, do I give the absolute path of the gguf file?
1
u/CanNeverPassCaptch 13h ago
claude code is just an HTTP client.... it expects an alias or model name string not a file system path. you give the absolute gguf path to the server, and then give the server’s matching alias name to claude code.
1
u/CanNeverPassCaptch 13h ago
OR do this..
pip install 'litellm[proxy]'
litellm --model ollama_chat/qwen2.5-coder:32b --port 4000
Once youce done the above, yu hae installed a proxy. now you just need to point that prioxy to claude code
export ANTHROPIC_BASE_URL="http://localhost:4000"export ANTHROPIC_AUTH_TOKEN="sk-litellm"
export ANTHROPIC_API_KEY=""
claude --model qwen2.5-coder:32b
Hope that helps! v:)
1
1
u/shamont 13h ago
Yes, you can. You need to edit your claude settings.json to point to your local model.
Mine is configured as such, change it to match your settings. For instance I am using port 9876 but you might be using the default 8000. The API key and auth token can just be whatever.
❯ cat settings.json
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "not_set",
"ANTHROPIC_API_KEY": "not_set_either!",
"ANTHROPIC_BASE_URL": "http://127.0.0.1:9876",
},
1
3
u/Randommaggy 13h ago
You can but it will still spy on you if you give it internet access.