SSD Nodes Learn 8GB RAM — $66/yr
How to do am Matt ConnorBy Matt Connor · Updated 2026-08-02

You Fit Self-Host Claude? The Honest Answer

Claude weights no dey public, so your server no fit run am. See wetin you fit self-host instead: open models, API gateway, and Claude Code.

You fit self-host Claude? No, and na dis why

You no fit self-host Claude. Anthropic no publish the model weights, so no file dey to download, no container dey to run, and no licence dey wey go allow you serve am from your own hardware. Every Claude request dey go Anthropic API or hosted partner like Amazon Bedrock, Google Vertex AI, or Microsoft Foundry. To run am for machine wey you own no be configuration problem. The artefact simply no dey outside Anthropic.

Na the short answer be that. The longer answer be say most people wey dey ask this question no really want the weights. Dem want one of three things wey all fit work for server wey you control: capable model wey dey run locally, gateway wey dey hold their API keys and limit their spending, or coding agent wey dey live for their own box instead of their laptop. This guide cover all three, with the commands.

Wetin “self-hosted Claude” usually mean

People wey dey search for “self-hosted Claude” dey look for different things, and each one need different answer.

Some people want privacy. Dem no want prompts comot from their network. Na only local open weight model fit solve this, because any Claude request by definition na request to Anthropic.

Some people want control over cost. Dem dey fear say agent fit run anyhow and use all their credits. Gateway fit solve this, and e dey work with Claude, so you still keep the model quality.

Some people want make dem no depend on laptop. Dem want agent wey go continue to work while dem close the lid. VPS fit solve this, and Claude Code dey run well on am.

Some people want the phrase “self-hosted OpenRouter”. This one still na gateway, and the usual answer na LiteLLM.

Find out which one apply to you, because the correct setup dey different for each case.

Host open model by yourself with Ollama

If you need make sure say no prompt comot your server, run open weight model. The model families wey fit work well for rented server today na Llama, Qwen, Mistral, Gemma, and DeepSeek. All of dem publish weights wey you fit download and run.

Ollama na the fastest way to start. The install script na one line, and e go set up systemd service for Ubuntu.

curl -fsSL https://ollama.com/install.sh | sh
systemctl status ollama

systemctl status ollama suppose print active (running). Then pull model and talk to am.

ollama pull qwen3:8b
ollama run qwen3:8b "Summarise what a reverse proxy does in two sentences."

The first pull go download several gigabytes, so the model must fit inside RAM or GPU memory before e fit answer anything. For quantised models, use this rough rule: model wey get 8 billion parameters need about 6 GB free, model wey get 14 billion parameters need about 10 GB, and model wey get 70 billion parameters need more memory pass wetin most general purpose VPS plans get. If the machine no get enough memory, kernel go kill the process and you go see Error: llama runner process has terminated, with out of memory line for dmesg. Check free -h before you blame the model.

Ollama still dey serve HTTP API on 127.0.0.1:11434, and na this one make am useful to other software, instead of only being chat toy.

curl http://127.0.0.1:11434/api/generate -d '{"model":"qwen3:8b","prompt":"ping","stream":false}'

Leave that port bound to localhost. If Ollama port open for public IP, anybody wey find am fit use your GPU for free. The complete setup, including systemd unit, GPU detection, and putting reverse proxy in front, dey covered for the guide for running Ollama on VPS. If more than one user go use am at the same time, read the comparison between Ollama and vLLM first, because Ollama single stream design go become bottleneck well before the hardware.

Talk true about the difference. Good open model for mid sized VPS dey genuinely useful for summarising, classifying, drafting, and simple extraction. For long multi step reasoning, large codebases, and agentic tool use, e no near frontier hosted model, and no amount of prompt tuning go close that gap. Choose local model for the work wey e good at, and pay for hosted model when the work hard.

Run your own gateway with LiteLLM

Dis na the "self hosted OpenRouter" wey people dey search for. Gateway dey between your applications and every model provider. Your apps go hold one key, wey point to your server. The real provider keys go dey only for that server. You fit set spending limit for each key, route different apps go different models, and log every request for one place.

LiteLLM na the common choice because e dey speak OpenAI compatible API and e dey proxy to Anthropic, Ollama, and most other providers through the same endpoint. Run am for Docker with one config file.

model_list:
  - model_name: claude
    litellm_params:
      model: anthropic/claude-sonnet-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: local
    litellm_params:
      model: ollama/qwen3:8b
      api_base: http://127.0.0.1:11434

Save am as litellm_config.yaml and start the proxy. E dey listen on port 4000.

docker run -v $(pwd)/litellm_config.yaml:/app/config.yaml \
  -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
  -e LITELLM_MASTER_KEY=sk-1234 \
  -p 4000:4000 docker.litellm.ai/berriai/litellm:latest \
  --config /app/config.yaml

LITELLM_MASTER_KEY na the admin credential, so treat am like root password and no use the example value for production. Call the proxy exactly as you for call hosted API.

curl http://localhost:4000/v1/chat/completions \
  -H 'Authorization: Bearer sk-1234' \
  -H 'Content-Type: application/json' \
  -d '{"model": "claude","messages": [{"role": "user","content": "Say hello in five words."}]}'

Healthy response na normal JSON with one choices array. 401 mean say the Authorization header no match your master key. 400 wey name the model mean say the model for your request no match any model_name for the config file.

The reason to build this instead of calling Anthropic directly na the spending limit. Issue one separate virtual key for each application, and give each one e own budget.

curl 'http://0.0.0.0:4000/key/generate' \
--header 'Authorization: Bearer sk-1234' \
--header 'Content-Type: application/json' \
--data-raw '{"models": ["claude"], "max_budget": 100}'

That key fit spend one hundred dollars and reach one model only. E no go reach anything else. If agent misbehave for three in the morning, the blast radius na one key instead of your whole account. That pattern, together with the monitoring around am, na the subject of how to control agent costs for VPS. If you still dey decide whether to pay per token at all, comparison of API and subscription costs dey explain the arithmetic.

Make you note wetin the gateway no dey do. E no make Claude local, and e no hide your prompts from Anthropic. Requests still dey leave your server go the provider. Wetin you gain na control over keys, spending, routing, and logs.

Run Claude Code for your own VPS

The third wish na di easiest one to grant. Claude Code na client. E dey run anywhere wey you install Node.js, and e dey talk to the API through HTTPS. If you put am for server wey you own, the agent go continue to work after you shut your laptop. E also mean say the agent blast radius na box wey you fit rebuild, instead of your main machine.

npm install -g @anthropic-ai/claude-code
claude --version

Run am inside tmux so dropped SSH connection no go kill long job. This setup, including how to handle the session, dey covered for how to run Claude Code for VPS with tmux. Give the agent e own unprivileged user. Before you give am write access to anything wey matter to you, read safety rules for running Claude Code for server.

This na self-hosting the agent, no be the model. E good make we talk am clearly, because na this part people dey mix together. You own the process, the filesystem, the network egress, and the logs. Anthropic still own the inference.

Wetin each option really go cost you

Prices dey change, so take these figures as general guide, no be fixed quote. As of July 2026, Claude Sonnet 5 price na $3 for every million input tokens and $15 for every million output tokens, while Claude Opus 5 na $5 and $25. Local model no get cost per token, but you go pay the server cost every month, whether you use am or not.

The break-even point dey lower than many people expect. VPS wey get enough memory to run useful open model go cost real money every month, and e dey idle most of the time. If your usage dey come in bursts, hosted API normally cheaper. If your usage dey constant, or your data no fit comot from your network, local model win for both reasons.

The honest mixed answer na wetin most teams finally choose. Run open model locally for work wey get high volume but low difficulty. Send hard requests go hosted frontier model. Put gateway in front of both, so applications no need know which model dem dey use, and so you fit move the boundary between them without touching application code. That architecture na the practical version of "self hosted Claude", and unlike the literal version, e dey exist. If you also want run the whole agent stack by yourself, the summary of self-hosted AI agents explain wetin dey available.

FAQ

I fit download Claude model weights run am for my local machine?

No. Anthropic never release weights for any Claude model, and no licence dey allow self hosting. Anything wey dem advertise online as downloadable "Claude model" either na another model with deceptive name, or na wrapper wey dey call the API. If e need API key, e no dey run locally.

Which open model dey closest to Claude?

No exact match dey, and the leading models dey change every few months. The open weight families wey worth testing na Llama, Qwen, Mistral, Gemma, and DeepSeek. For summarising, classification, and simple code edits, good open model wey get 8 to 14 billion parameters fit really help. For long multi step reasoning and agentic tool use, the gap between am and hosted frontier model still big. Test am with your own prompts instead of trusting leaderboard.

LiteLLM na self-hosted OpenRouter?

For routing and key management, yes, e work that way. LiteLLM dey run for your server, e dey provide one OpenAI compatible endpoint, and e dey proxy requests to Anthropic, Ollama, and most other providers. You get spend caps for each key, model routing, and one place to read logs. But e no provide local inference: requests to Claude still dey travel go Anthropic.

If I run Claude Code for my own server, my code go remain private?

No. Claude Code dey send the file contents wey e read go Anthropic API, no matter where the process dey run. VPS gives you isolation for the agent, but e no give privacy for the content. Give am dedicated unprivileged user, keep am away from credentials and unrelated repositories, and treat everything wey e fit read as content wey dey comot from the server.