Using your local vLLM as a backend for Claude Code
Goal and motivation
I have a Windows laptop and also a DGX Spark (Ubuntu) with plenty of VRAM to run vLLM with Qwen3.8-27B. I want to run VS Code on Windows with Claude Code, but instead of using Anthropic models, it should use my self-hosted model. I could run a bigger model, but Qwen3.8-27B has a higher coding score on Artificial Analysis than any other model I can run, even much larger ones.
Why vLLM and not Ollama, LM Studio etc?
I use vLLM because it handles concurrent requests exceptionally well. I tested it on the DGX Spark. Up to 8 simultaneous requests will give hardly any additional overhead, so it is 8x faster. More than that and you pay a price: 32 concurrent requests might only be 20x faster. This means that you can scale to a team of developers that shares a vLLM server for coding.
Ollama and LM Studio focus more on single users running a model on their own system.
Prerequisites
Make sure Claude Code is installed, either as a CLI, or as an extension in VS Code, or both.
Install vLLM
My DGX Spark can handle the quantization NVFP4 natively, which is much faster and makes a model only slightly dumber. So I always use NVFP4 for the Spark. If you use BF16 instead, it can easily be 10x slower.
I looked up the recipe on the vLLM website:
https://recipes.vllm.ai/Qwen/Qwen3.8-27B?variant=nvfp4_nvidia&hardware=dgx_spark_gb10
I used the latest stable vLLM image:vllm/vllm-openai:v0.31.0.
Then I used fllame to create a compose.yaml for the recipe.
I made some small changes to the recipe:
- No pre-installation of transformers>=5.8.0, because it works without this, and installing it makes startup slower. fllame solves this by making an additional Dockerfile, which I don't want for this tutorial.
- Removed the environment variable VLLM_USE_RUST_FRONTEND=1. This worked on previous versions of vLLM, but on v0.31.0 this crashes at startup (I created fllame to cope with precisely this kind of configuration madness).
fllame generated the following compose.yaml:
services:
qwen3-8-27b-nvfp4:
image: vllm/vllm-openai:v0.31.0
entrypoint:
- vllm
- serve
command:
- nvidia/Qwen3.8-27B-NVFP4
- --kv-cache-dtype
- fp8
- --gpu-memory-utilization
- '0.7'
- --max-model-len
- '262144'
- --max-num-seqs
- '8'
- --max-num-batched-tokens
- '8192'
- --enable-chunked-prefill
- --async-scheduling
- --enable-prefix-caching
- --load-format
- fastsafetensors
- --tensor-parallel-size
- '1'
- --enable-auto-tool-choice
- --tool-call-parser
- qwen3_coder
- --reasoning-parser
- qwen3
- --mm-encoder-tp-mode
- data
ports:
- 8000:8000
environment:
- HF_HOME=/root/.cache/huggingface
- HF_HUB_CACHE=/root/.cache/huggingface
- HF_HUB_OFFLINE=1
- HF_HUB_DISABLE_TELEMETRY=1
- VLLM_NO_USAGE_STATS=1
- DO_NOT_TRACK=1
- RAY_USAGE_STATS_ENABLED=0
- PYTHONUNBUFFERED=1
volumes:
- ${HOME}/.cache/huggingface/hub:/root/.cache/huggingface
ipc: host
gpus: all
container_name: fllame-qwen3-8-27b-nvfp4
The default port setting of 8000:8000 allows other machines to access the vLLM server without additional configuration. That makes it easy to use, but slightly less secure. You can change it to 127.0.0.1:8000:8000, but then you need some extra work to access it from other machines. In an enterprise environment, you would put the whole thing behind a reverse proxy like nginx. For a personal network, you can use an SSH tunnel, which is what I did.
The file contains HF_HUB_OFFLINE=1, which prevents downloading models from Hugging Face. Make sure to download the model first, or remove this line.
You don’t need fllame after the compose.yaml is generated; you can just serve vLLM with docker compose up -d.
The DGX Spark is linked to my Windows laptop via a small LAN cable, with an SSH tunnel that maps port 8000 on the Spark to my localhost. For the rest of the tutorial, I assume vLLM runs at http://localhost:8000 and serves the model “nvidia/Qwen3.8-27B-NVFP4”. For a different URL or model, just replace the values.
Claude Code CLI
A bunch of environment variables need to be changed. The most important one is ANTHROPIC_BASE_URL, which must point to vLLM. You could permanently set them, but I want to be able to switch between vLLM and online Claude models, depending on the situation. To achieve this, I created a claude-local function (with Claude Code) that calls vLLM instead of online Claude.
The function is for PowerShell on Windows, but the same principle should apply to Linux.
- In PowerShell, create a profile file with the function:
if (!(Test-Path $PROFILE)) { New-Item -Type File -Force $PROFILE }- Then open it in notepad: notepad $PROFILE
- Paste this function in there:
function claude-local {
# match vLLM URL and served model
$model = 'nvidia/Qwen3.8-27B-NVFP4'
$env:ANTHROPIC_BASE_URL = 'http://localhost:8000'
$env:ANTHROPIC_AUTH_TOKEN = 'dummy' # required by Claude Code; any value works if vLLM has no --api-key
$env:ANTHROPIC_API_KEY = $null # conflicts with AUTH_TOKEN; $null = remove
$env:ANTHROPIC_MODEL = $model
$env:ANTHROPIC_DEFAULT_FABLE_MODEL = $model
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = $model
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = $model
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = $model
$env:CLAUDE_CODE_SUBAGENT_MODEL = $model
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = '1'
$env:CLAUDE_CODE_MAX_CONTEXT_TOKENS = '229376' # below vLLM --max-model-len (262144 - 32768 = 229376)
$env:CLAUDE_CODE_MAX_OUTPUT_TOKENS = '32768' # context + output <= --max-model-len
claude @args
}- Save the file and restart PowerShell to load the new profile.
- Browse to a folder with code and execute claude-local.

Qwen 3.8 can use reasoning effort of xhigh, medium or low, but not high. When starting your first session, check the current value with /effort and make sure it is supported. If you use an invalid reasoning effort, vLLM will raise an error, which will be shown in the Claude Code terminal.
If you close the PowerShell terminal, all environment variables are back to their default. You can start a new terminal, and execute claude there, which will redirect all prompts to online models. This even works at the same time, but it's probably not a good idea to have two different models make changes at the same time. However, it is totally plausible to have local Claude Code create the code and online Claude Code check the code.
Idea 1: create FEEDBACK.md that the local model uses to read feedback, and the online model uses to write feedback.
Idea 2: create FILE-USE.md where a model lists what files it is currently editing. Models could even negotiate file use. It would be funny if it becomes really slow and you discover a heated debate over who gets to use poetry.lock.
Claude Code extension in VS Code
In the terminal of VS Code, claude-local should already work, but the Claude Code extension with the chat interface still points to Claude online.
- Create a new profile: Ctrl+Shift+P → “Profiles: New Profile”. Enter a name and copy from default to keep currently installed extensions (such as Claude Code).
- Ctrl+Shift+P → “Preferences: Open User Settings (JSON)”
- Replace "claudeCode.environmentVariables": [] or add it if missing:
"claudeCode.environmentVariables": [
{ "name": "ANTHROPIC_BASE_URL", "value": "http://localhost:8000" },
{ "name": "ANTHROPIC_AUTH_TOKEN", "value": "dummy" },
{ "name": "ANTHROPIC_MODEL", "value": "nvidia/Qwen3.8-27B-NVFP4" },
{ "name": "ANTHROPIC_DEFAULT_FABLE_MODEL", "value": "nvidia/Qwen3.8-27B-NVFP4" },
{ "name": "ANTHROPIC_DEFAULT_OPUS_MODEL", "value": "nvidia/Qwen3.8-27B-NVFP4" },
{ "name": "ANTHROPIC_DEFAULT_SONNET_MODEL", "value": "nvidia/Qwen3.8-27B-NVFP4" },
{ "name": "ANTHROPIC_DEFAULT_HAIKU_MODEL", "value": "nvidia/Qwen3.8-27B-NVFP4" },
{ "name": "CLAUDE_CODE_SUBAGENT_MODEL", "value": "nvidia/Qwen3.8-27B-NVFP4" },
{ "name": "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC", "value": "1" },
{ "name": "CLAUDE_CODE_MAX_CONTEXT_TOKENS", "value": "229376" },
{ "name": "CLAUDE_CODE_MAX_OUTPUT_TOKENS", "value": "32768" },
],
// Skip the Anthropic sign-in screen
"claudeCode.disableLoginPrompt": true,
You can switch profiles in the settings in the left bottom of VS Code. Select the new profile to activate it:

The Claude Code extension should show your local model:

Now the VS Code configuration and the terminal configuration both work, but they can conflict. You can use claude-local in the terminal inside VS Code, and the default profile that points to Claude online, or vice versa. That could be useful if you want to use them both at the same time. If you don't want that, you can extend the user settings in the profile like this:
"terminal.integrated.env.windows": {
"ANTHROPIC_BASE_URL": "http://localhost:8000",
"ANTHROPIC_AUTH_TOKEN": "dummy",
"ANTHROPIC_API_KEY": null,
"ANTHROPIC_MODEL": "nvidia/Qwen3.8-27B-NVFP4",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "nvidia/Qwen3.8-27B-NVFP4",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "nvidia/Qwen3.8-27B-NVFP4",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "nvidia/Qwen3.8-27B-NVFP4",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "nvidia/Qwen3.8-27B-NVFP4",
"CLAUDE_CODE_SUBAGENT_MODEL": "nvidia/Qwen3.8-27B-NVFP4",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "229376",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32768",
},Now, the terminal of VS Code automatically uses the environment variables for the terminal as well, so that the command claude links it to vLLM:

Test
I created an empty folder, started VS Code with it, and in the terminal I started claude-local.
Then the prompt: “create a space invaders clone using html + js. also add super concise readme how to start it”.
On the DGX Spark I checked the vLLM logs: docker logs -f fllame-qwen3-8-27b-nvfp4, and I saw the requests coming in.
I turned off Wi-Fi, and it kept working. It gave a warning that automode would no longer work as soon as I did, but it kept working just fine.
After a while, it ended with:
✻ Churned for 2m 35s · done 2:21 PM
※ recap: Created a complete Space Invaders clone (index.html, vanilla JS, no dependencies) plus a
concise README in C:\Code\space-invaders. Both are done; next action is for you to open index.html
in a browser and confirm it runs. (disable recaps in /config)
And look at that! An actual playable demo of Space Invaders created by Qwen 3.8. And that on medium reasoning effort!

Using Claude to not use Claude
I used Claude to create the claude-localscript. It knew what environment variables needed to be set. While making this tutorial, Claude Code updated and defaulted to Fable instead of vLLM when calling claude-local. I did some research (I asked Claude) and added some extra environment variables, which fixed the problem.
That gives me two clear insights for future use:
- At any time, Anthropic can change the environment variables, add new ones, or stop supporting local models altogether. You could probably let Claude Code generate a version that works with vLLM, but that would be against their policy. Then it is time to switch to OpenCode.
- When Anthropic manages to create a super-intelligent LLM using recursive self-improvement, my first prompt will be: make me a local LLM that is better than yourself at coding.
I work at Profit4Cloud as an AI Engineer. If you want to use Claude Code or set up vLLM in an enterprise environment, visit www.profit4cloud.nl.