Run Claude Code on a self-hosted uncensored Qwen model (Vast.ai + llama-server) A developer published a gist showing how to point the Claude Code CLI at a self-hosted, abliterated Qwen 35B MoE model instead of the Anthropic API, running on a rented Vast.ai A100 GPU and served by llama-server with --jinja, which speaks the Anthropic Messages API directly with no proxy in between. The setup preserves tool calling, multi-turn conversation and 262k context, and was measured at 141 tok/s generation at short context, 112 tok/s at 104k context, and 4505 tok/s prompt eval. The guide includes a patched chat template, zsh management functions, and a troubleshooting table, and is intended for authorized pentest work. Point the Claude Code CLI at a self-hosted, abliterated Qwen model instead of the Anthropic API. The model runs on a rented Vast.ai GPU and is served by llama-server . There is no router or proxy in between: llama-server --jinja speaks the Anthropic Messages API /v1/messages directly, which is what Claude Code talks. Result: full Claude Code tool calling, multi-turn, 262k context on an uncensored 35B MoE model. Intended for authorized pentest work. Measured on an A100 PCIE 40 GB: 141 tok/s generation at short context, 112 tok/s at 104k context, 4505 tok/s prompt eval. Files in this gist: - README.md - this guide, setup steps, and a troubleshooting table for every error found while building this - qwen-chat-template.jinja - the patched chat template required, do not skip it - claude-qwen.zsh - the zsh functions that manage everything php Claude Code CLI ----HTTP /v1/messages---- ssh tunnel =====ssh===== llama-server Vast.ai box local machine 127.0.0.1:11435 11435 - 8080 :8080, model in RAM - llama-server listens on the box on port 8080. - A local ssh tunnel forwards 127.0.0.1:11435 to that port. - Claude Code talks to http://127.0.0.1:11435 as if it were the Anthropic API. - llama-server is started with --jinja , which makes it accept the Anthropic /v1/messages request and response format directly. No translation layer. Every placeholder in this guide is one of these, and each section says where to get it: | Placeholder | Meaning | How to get it | |---|---|---| |