{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/steipete-me/2025-07-31-self-hosting-ai-models-after-claude-s-usage-limits/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "![](https://steipete.me/assets/img/2025/self-hosting-ai-models/hero.png)\n\nWhen Anthropic changed Claude Max’s subscription model from a 5-hour usage window to weekly limits, [it hit me hard](https://x.com/steipete/status/1949901121998508119).\n\n**TL;DR:** Claude Code is still king, Qwen 3 Coder + opencode is a strong contender tho. Have high hopes for Gemini cli and Crush.\n\n## Claude Code Anonymous\n\nI’m definitely part of the 1% that has got [**a ton**](https://x.com/steipete/status/1948549916604989706) of benefit out of their payment model, and I’m not entirely surprised that they’re changing the deal, given the incredible demand for Claude Code. Much like [Cursor’s recent pricing changes](https://www.reddit.com/r/cursor/comments/1lrc7q8/cursor_pricing_changed_after_12_days/), this caused a lot of anger in the community, and it also triggered my curiosity on what other options are out there.\n\nJust to set the record straight tho: While I often worked 16h-days, I never automated Claude Code and was well within their Terms of Service. My Anthropic bill for July is at [\\~6000$](https://x.com/steipete/status/1949908573452193866), since I’ve been using their GitHub Review bot, and while some people have been extracting the Max API Token to run on GitHub in the background, I opted to not break the rules and pay up… so Anthropic, we cool?\n\n## Evaluating The Landscape\n\nSo what are the alternatives? I spend some time testing every promising tool I could find. Claude Code is insofar hard to replace, as it’s this genius blend of amazing model & tooling. But the landscape is changing fast! There’s quite a few contenders out there that are worth a look:\n\n- [opencode](https://opencode.ai/) In my tests, opencode is the [most promising](https://x.com/steipete/status/1951288839814725862) alternative currently. It supports pretty much all providers and gets better every day. It has an optimized prompt for Qwen 3 Coder, and produces good results. I’ll definitely be using this more.\n\n- [charm crush](https://github.com/charmbracelet/crush) I *really* want to love this one. It’s gorgeous and fun to use. No surprise, it’s backed by a company that makes fun cli tools and that shows. Crush was released just yesterday and it’s still early. [It has problems with the edit tool and sometimes just gets stuck](https://x.com/steipete/status/1951288839814725862), at least when using it with Qwen 3 Coder. I had to [send a PR](https://github.com/charmbracelet/crush/pull/414) to make it work with self hosted inference. There’s a whole team working on it so my hopes are up. If you use Anthropic’s models, I’m sure it performs much better. Personal deal-breaker: The non-working text selection. You can’t click on links either. I use this a lot so it’d really disruptive for my workflow.\n\n- [Claude Code with claude-code-router](https://github.com/musistudio/claude-code-router) Clever hack that patches Claude Code to use different models. Since CC is optimized for Anthropic’s models, tool use and overall results aren’t as good as with Sonnet or Opus. I didn’t explore this further.\n\n- [Cline](https://github.com/cline/cline) I used Cline for testing the model, but since it’s a VS Code extension and not a cli, it doesn’t fit my workflow, and generally [I haven’t been impressed by it](https://x.com/steipete/status/1951062013913727332).\n\n- [amp](https://ampcode.com/) Amp is a very opinionated CLI. It uses Claude Sonnet and has a tool that can invoke OpenAI’s o3. Pricing is forwarded without markup. You can’t use your subscription here, so until now, it wasn’t interesting. It’s hyped, in my tests [it didn’t impress me tho](https://x.com/steipete/status/1951059420193968581). Some people swear by it tho, and it’s certaily more token efficient than Claude Code.\n\n- [Gemini CLI](https://github.com/google-gemini/gemini-cli) / [Qwen Code](https://github.com/QwenLM/qwen-code) I have high hopes for Gemini CLI, and with it, the [Qwen Code fork](https://x.com/steipete/status/1951058436030079159). Gemini is REALLY FAST. I use it to debug tricky issues that need a large context space. Tool calling is still [very broken “I’m just a file”](https://x.com/steipete/status/1942113964231442876) and [it can be really lazy](https://x.com/steipete/status/1951301660950581709), however it’s open source and a lot of folks are working on making it better. As for the Quen Code fork, we’ll see if they keep up with the fast-paced development of Gemini or abandon it. I worry it’ll be the latter, at least from looking at the current pace of updates.\n\nThere are [so](https://github.com/RooCodeInc/Roo-Code) [many](https://kiro.dev/) [more](https://www.augmentcode.com/changelog/auggie-cli) tools out there in all colors and sizes, and it’s really impressive how important tooling & the right system prompt are (e.g. [RooCode drawing diagrams!](https://x.com/steipete/status/1951080437188624564)). IMO that’s Claude Code’s strength: it’s optimized for just one model, and it shows.\n\n## The Infrastructure Journey\n\nMy main goals for this exploration are twofold: I don’t wanna be too dependent on one company & tool (Anthropic), and I want to have a less costy solution for my heavy use.\n\nA few months ago I bought a Mac Studio with 512GB ram, top of the line, to experiment with models (and because it’s prettyyh). Turns out, back then there just wasn’t anything great out there that could compete with Opus & Gemini. And then came Deepseek, and with that the realization that even the 512GB won’t get me very far.\n\nYes, I can run Deepseek Coder V2 at ~25 tok/s or a quantified version of R1 at ~8–15 tok/s, but that’s not fun, and 128k context size is quite a bit of a downgrade compared to Claude’s 200k or Gemini’s 1Mio context. There’s ways to connect multiple Studio’s for more performance and/or less compressed models, but then we’re talking 30k$+ for the setup.\n\nHardware is one thing - we also need capable models. These days, chinese labs releases better and more capable models on an almost weekly basis. The release of [Qwen3-Coder-480B](https://qwenlm.github.io/blog/qwen3-coder/) got my attention, as it’s the first model that achieves a similar score on SWE-bench as Claude Sonnet 4. Plus, it has a native 256k token context window that can stretch to 1M tokens with YaRN.\n\nRunning this needs some beefy hardware. NVidia’s H200 (Hopper refresh) is currently the best top-of-the-line choice. There’s also B200 (Blackwell), but they are usually even more expensive to rent, and software support is still quite weak.\n\nI’ve been experimenting with [Prime Intellect](https://www.primeintellect.ai/), [Vast.ai](https://vast.ai/) and [DataCrunch](https://datacrunch.io/). Prices for 8xH200 machines range from $5-30/hour, depending on location, availability and if you rent a spot instance or a regular one. Now spot instances are instances that are available temporarily. Whenever data centers need more capacity, they will simply deprovision it and use it again.\n\nIn my tests, if you get a H200 spot instance it’ll likely disappear before you are finished setting it up. They can be incredibly cheap, but it aint fun when you suddenly have to stop working and set up a new rack because of peak demand. We’re talking $6/h for spot instances vs $14/h for a regular 8xH200 rack, at least on DataCrunch, which seems to be one of the cheapest (while still reliable in my tests) options out there. On vast.ai, a similar setup is more like ~$26/h, and double that again if you look at AWS.\n\nThe setup I’m currently running:\n\n```bash\n8x H200 (1128GB GPU VRAM)\n176 CPU, 1450GB RAM\nUbuntu 24.04, CUDA 12.8\n$15/h\n```\n\nWith my rig I could set up the FP8[^1]-version of Qwen3 Coder 480B with a 400k context. FP8 means smaller float’s, so you lose a few percent accuracy compared to the FP16-version, which is used for the benchmarks. For the Qwen model these losses are insignificant though, and it’s a big performance win, plus squeezing in the FP16 model would leave us with maybe 32k tokens of context.\n\nMemory is absolutely everything at this scale. The KV cache[^2] (that’s what stores the conversation context) eats about 4.2MB per token when using FP16 precision. If you want a 1M token context window, you’d need 17-30 H200 GPUs. That’s why I “only” got 400k tokens with 8 GPUs.\n\nSetup is tricky, but since [Claude Code is my computer](https://steipete.me/posts/2025/claude-code-is-my-computer), it was mostly a bit of prompting and about half an hour waiting until the rig was ready - at least for H200.\n\nCurrently sparse instances of B200 are an incredibly good deal (~$4/h) and they also been extremely stable in my tests. I also understand why: this hardware is so new that you’ll unlikely succeed running models efficiently on it. [I spent all day on this and got it partially running](https://x.com/steipete/status/1951217528161567193), but at no point was it faster than a 8xH200 rig. That will change in a few weeks tho as software catches up.\n\nInsane if you think about it: The 3 8xB200 rack hardware I rented here is worth about 2 Mio Dollar.\n\n## Cost Analysis\n\nWith the technical setup sorted, let’s get to the question everyone’s really asking about: Money.\n\nRunning this setup costs $15/h per hour. That’s ~$360 per day if you run it 24/7, or about $11,000/month. You could recreate the machine every day to save money, but setting this up also takes 30-60 minutes each morning. That would drive cost down to ~$120 a day and ~$2,600 a month (if we just count work days, but who doesn’t work on the weekends?)\n\nThose numbers probably made you wince. So here’s the honest assessment after burning through all that cash:\n\n## Is It Worth It?\n\nSimple answer: No. You can’t stop and easily restart instances, at least not with the hardware provider I tested. Restarted instances will be scheduled, but there’s no guarantee you get a spot in that data center, so it might take days or weeks until your setup reboots.\n\nWhat about performance? I naively thought that I’d get better performance with my personal 8xH200 rig, so I ran some tests. And since I couldn’t find a simple benchmark tool, [I vibed one in go](https://x.com/steipete/status/1951288839814725862). Turns out, Alibaba is slightly faster than my best optimized 8xH200 rig. Maybe that changes once someone gets the B200 racks working.\n\nIf you want REAL performance and also a damn good deal, check out [Cerebra’s new offering](https://www.cerebras.ai/blog/qwen3-coder-480b-is-live-on-cerebras) that came out today. Cerebras Code Max, 5000 messages per day for $200/month. About 20x faster than Claude 4 Sonnet.\n\nYou can rent the 1 Mio-context version of Qwen 3 Coder on Alibaba for [$1-$6 In / $5-$60 Out per Million tokens](https://www.alibabacloud.com/help/en/model-studio/models#8e453767fbkka), depending how much context you’re using. That’s a lot of tokens you have to burn to make self-hosting cost effective. And yes, a self-hosted runner could be shared, but the economics are still against you, and you quickly run into bottlenecks if more than one person accesses your server concurrently.\n\nCompare to Anthropic: [$15 / $75 for Opus, $3 / $15 for Sonnet](https://www.anthropic.com/pricing#api)\n\nGoogle’s Gemini 2.5 Pro: [$1.25-$2.50 / $10-$15](https://ai.google.dev/gemini-api/docs/pricing)\n\nTo give you an idea, on an intense day I need maybe 500 Mio tokens. Calculating the price is difficult tho, since many tokens are cached as you work through a session. The cost for that, when using Opus, would be about $1000; for Sonnet about $200 - that’s similar to running my rig for 8h. Using other models is significantly cheaper.\n\nRealistically, using Qwen 3 Coder with opencode is now a very usable and cost effective alternative today. And in a month when the subscription nerving takes effect, things will look different again.\n\nIt’s great to know that open-source models are a merely 6-12 month behind the best commercial ones, and that it’s absolutely possible to host them yourself. Commercially tho, paying per token is the economically saner choice.\n\n**Verdict:** Claude Code as terminal + coding, opencode + Qwen on Alibaba (or Cerebas for speeeeeed!) as alternative coding agent for simpler tasks (or when the subscription is used up) and Gemini for debugging.\n\n🤖 Setup Guide for AI Agents to Self-Hosting Qwen3-Coder-480B on 8xH200\n\n## Complete Setup Instructions for Self-Hosting Qwen3-Coder-480B\n\nThis guide provides step-by-step instructions for AI agents to set up Qwen3-Coder-480B on Vast.ai with maximum context window.\n\n### Prerequisites\n\n- Vast.ai account with billing configured\n- SSH client installed\n- 2-3 hours for initial setup\n\n### Step 1: Create Vast.ai Instance\n\n1. Go to [Vast.ai](https://vast.ai)\n\n2. Search for instances with:\n\n   - 8x H200 GPUs (minimum 4x H200)\n   - vLLM template pre-installed\n   - 1TB+ disk space\n   - Good DLPerf score (>80)\n3. Select instance and configure:\n\n   ```plaintext\n   Docker Image: Leave default vLLM image\n   Jupyter: Optional (uses port 8080)\n   SSH: Required\n   Direct SSH: Recommended\n   ```\n\n4. Deploy instance and note:\n\n   - SSH port and IP\n   - Instance ID\n   - Cost per hour\n\n### Step 2: SSH Configuration\n\nAdd to `~/.ssh/config`:\n\n```bash\nHost vastai-qwen\n  HostName [YOUR_IP]\n  Port [YOUR_PORT]\n  User root\n  StrictHostKeyChecking no\n  UserKnownHostsFile /dev/null\n```\n\nCreate SSH tunnel:\n\n```bash\nssh -f -N -L 8000:localhost:8000 vastai-qwen\n```\n\n### Step 3: Deploy vLLM with Qwen3-480B\n\nSSH into instance:\n\n```bash\nssh vastai-qwen\n```\n\nCheck GPU status:\n\n```bash\nnvidia-smi\n```\n\nCreate deployment script:\n\n```bash\ncat > deploy-qwen3.sh << 'EOF'\n#!/bin/bash\n\n# Kill any existing vLLM processes\npkill -f vllm.entrypoints.openai.api_server || true\n\n# Start vLLM with optimal settings\n/venv/main/bin/python -m vllm.entrypoints.openai.api_server \\\n  --model Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 \\\n  --served-model-name qwen3-coder \\\n  --tensor-parallel-size 8[^3] \\\n  --enable-expert-parallel \\\n  --gpu-memory-utilization 0.95 \\\n  --max-model-len 400000 \\\n  --rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.53,\"original_max_position_embeddings\":262144}' \\\n  --download-dir /workspace/models \\\n  --host 0.0.0.0 \\\n  --port 8000 \\\n  --trust-remote-code \\\n  --dtype float16 \\\n  --enable-prefix-caching \\\n  --enable-chunked-prefill \\\n  --max-num-batched-tokens 32768 \\\n  > vllm.log 2>&1 &\n\necho \"vLLM deployment started. Check vllm.log for progress.\"\nEOF\n\nchmod +x deploy-qwen3.sh\n./deploy-qwen3.sh\n```\n\n### Step 4: Monitor Model Download\n\nModel download takes 1-2 hours for 480GB:\n\n```bash\n# Watch download progress\ntail -f vllm.log | grep -E \"Downloading|Loading|Progress\"\n\n# Check disk usage\nwatch -n 5 'df -h /workspace'\n```\n\n### Step 5: Disable Vast.ai Authentication\n\nVast.ai uses Caddy proxy with auth. Disable it:\n\n```bash\n# Stop Caddy to remove authentication\nsupervisorctl stop caddy\n\n# Verify direct access works\ncurl http://localhost:8000/v1/models\n```\n\n### Step 6: Configure AI Coding Clients\n\n#### For Cline (VS Code Extension):\n\n1. Install Cline extension in VS Code\n2. Open Cline settings\n3. Configure:\n\n   ```plaintext\n   API Provider: OpenAI Compatible\n   Base URL: http://localhost:8000/v1\n   API Key: not-needed\n   Model: qwen3-coder\n   ```\n\n#### For Cursor:\n\n1. Open Cursor settings\n2. Add custom model:\n\n   ```json\n   {\n     \"openai_api_key\": \"not-needed\",\n     \"openai_api_base\": \"http://localhost:8000/v1\",\n     \"model\": \"qwen3-coder\"\n   }\n   ```\n\n#### For Command Line (qwen CLI):\n\nCreate config at `~/.config/qwen/config.json`:\n\n```json\n{\n  \"providers\": {\n    \"qwen3-local\": {\n      \"type\": \"openai\",\n      \"base_url\": \"http://localhost:8000/v1\",\n      \"api_key\": \"not-needed\",\n      \"models\": [{\n        \"id\": \"qwen3-coder\",\n        \"name\": \"Qwen3-Coder-480B (400k context)\",\n        \"context_window\": 400000,\n        \"max_tokens\": 16384\n      }]\n    }\n  },\n  \"default_provider\": \"qwen3-local\",\n  \"default_model\": \"qwen3-coder\"\n}\n```\n\n### Step 7: Test the Deployment\n\nTest with curl:\n\n```bash\ncurl -X POST http://localhost:8000/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"qwen3-coder\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Write a Python hello world\"}],\n    \"max_tokens\": 100\n  }'\n```\n\nTest context window:\n\n```bash\n# Create large context test\npython3 << 'EOF'\nimport requests\nimport json\n\n# Create a message with ~100k tokens (roughly 400k characters)\nlarge_context = \"The quick brown fox jumps over the lazy dog. \" * 10000\nmessages = [\n    {\"role\": \"system\", \"content\": large_context},\n    {\"role\": \"user\", \"content\": \"Summarize the above in one sentence.\"}\n]\n\nresponse = requests.post(\n    \"http://localhost:8000/v1/chat/completions\",\n    json={\"model\": \"qwen3-coder\", \"messages\": messages, \"max_tokens\": 50}\n)\n\nprint(json.dumps(response.json(), indent=2))\nEOF\n```\n\n### Step 8: Performance Optimization\n\nMonitor GPU utilization:\n\n```bash\n# Real-time GPU monitoring\nwatch -n 1 nvidia-smi\n\n# Check vLLM metrics\ncurl http://localhost:8000/metrics\n```\n\nOptimize for your use case:\n\n- **For speed**: Reduce max\\_model\\_len to 100k-200k\n- **For context**: Keep at 400k but expect slower responses\n- **For cost**: Use 4x H200 instead of 8x (limited to 190k context)\n\n### Step 9: Troubleshooting\n\nCommon issues and solutions:\n\n#### Model won’t load\n\n```bash\n# Check available memory\nnvidia-smi\n# Solution: Reduce --gpu-memory-utilization to 0.90\n```\n\n#### Authentication errors\n\n```bash\n# Ensure Caddy is stopped\nsupervisorctl status\nsupervisorctl stop caddy\n```\n\n#### Context too large errors\n\n```bash\n# Reduce max_model_len in deployment script\n# 4x H200: max 190000\n# 8x H200: max 400000\n```\n\n#### Slow responses\n\n```bash\n# Check batch settings\n# Reduce --max-num-batched-tokens to 16384\n# Enable streaming in client\n```\n\n### Step 10: Cost Monitoring\n\nTrack usage and costs:\n\n```bash\n# Create usage tracker\ncat > track_usage.py << 'EOF'\n#!/usr/bin/env python3\nimport time\nimport datetime\n\nstart_time = datetime.datetime.now()\nhourly_rate = 12.40  # Adjust based on your instance\n\nwhile True:\n    elapsed = datetime.datetime.now() - start_time\n    hours = elapsed.total_seconds() / 3600\n    cost = hours * hourly_rate\n    \n    print(f\"\\rRunning for: {elapsed} | Cost: ${cost:.2f}\", end=\"\")\n    time.sleep(60)\nEOF\n\nchmod +x track_usage.py\n./track_usage.py\n```\n\n### Advanced: Context Window Tuning\n\nFor different context windows, adjust these parameters:\n\n#### 100k context (fastest):\n\n```bash\n--max-model-len 100000 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.0,\"original_max_position_embeddings\":262144}'\n```\n\n#### 256k context (native):\n\n```bash\n--max-model-len 262144 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.0,\"original_max_position_embeddings\":262144}'\n```\n\n#### 400k context (current):\n\n```bash\n--max-model-len 400000 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.53,\"original_max_position_embeddings\":262144}'\n```\n\n#### 760k context (maximum, requires 16+ H200s):\n\n```bash\n--max-model-len 760000 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":2.9,\"original_max_position_embeddings\":262144}'\n```\n\n### Maintenance\n\nRegular maintenance tasks:\n\n```bash\n# Check logs for errors\ntail -n 100 vllm.log | grep ERROR\n\n# Monitor disk space\ndf -h /workspace\n\n# Restart vLLM if needed\npkill -f vllm.entrypoints.openai.api_server\n./deploy-qwen3.sh\n\n# Clean old model files\nfind /workspace/models -type f -mtime +7 -delete\n```\n\n### Security Notes\n\n1. **SSH Tunnel**: Always use SSH tunnel, never expose port 8000 directly\n2. **API Key**: Even though “not-needed”, don’t leave blank\n3. **Firewall**: Ensure only SSH port is open on Vast.ai\n4. **Monitoring**: Check access logs regularly\n\n### Cost-Saving Tips\n\n1. **Pause when not using**: Vast.ai charges by the minute\n2. **Use 4x H200**: Sufficient for 190k context at half the cost\n3. **Spot instances**: 90% cheaper but risk of termination\n4. **Optimize context**: Most tasks don’t need 400k tokens\n\nThis completes the detailed setup guide for AI agents. The entire process should take 2-3 hours including model download time.\n\n* * *\n\n## **Btw:** I’m organizing the first Claude Code Anonymous meetup in London on August 18. For people who build. DM me if you’re interested!\n\n[^1]: **FP8/FP16** - Floating-point precision formats. FP16 uses 16 bits per number (higher accuracy), FP8 uses 8 bits (lower memory usage, slightly less accurate).\n\n[^2]: **KV Cache** - Key-Value cache stores the model’s “memory” of previous tokens in the conversation, enabling efficient context handling without recomputing everything.\n",
  "authors": [],
  "captured_at": "2026-09-27T19:29:15.293681927+00:00",
  "category": "programming",
  "content_html": "<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://steipete.me/assets/img/2025/self-hosting-ai-models/hero.png\" alt=\"\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>When Anthropic changed Claude Max’s subscription model from a 5-hour usage window to weekly limits, <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1949901121998508119\">it hit me hard</a>.</p>\n<p><strong>TL;DR:</strong> Claude Code is still king, Qwen 3 Coder + opencode is a strong contender tho. Have high hopes for Gemini cli and Crush.</p>\n<h2>Claude Code Anonymous</h2>\n<p>I’m definitely part of the 1% that has got <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1948549916604989706\"><strong>a ton</strong></a> of benefit out of their payment model, and I’m not entirely surprised that they’re changing the deal, given the incredible demand for Claude Code. Much like <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.reddit.com/r/cursor/comments/1lrc7q8/cursor_pricing_changed_after_12_days/\">Cursor’s recent pricing changes</a>, this caused a lot of anger in the community, and it also triggered my curiosity on what other options are out there.</p>\n<p>Just to set the record straight tho: While I often worked 16h-days, I never automated Claude Code and was well within their Terms of Service. My Anthropic bill for July is at <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1949908573452193866\">~6000$</a>, since I’ve been using their GitHub Review bot, and while some people have been extracting the Max API Token to run on GitHub in the background, I opted to not break the rules and pay up… so Anthropic, we cool?</p>\n<h2>Evaluating The Landscape</h2>\n<p>So what are the alternatives? I spend some time testing every promising tool I could find. Claude Code is insofar hard to replace, as it’s this genius blend of amazing model &amp; tooling. But the landscape is changing fast! There’s quite a few contenders out there that are worth a look:</p>\n<ul>\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://opencode.ai/\">opencode</a> In my tests, opencode is the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951288839814725862\">most promising</a> alternative currently. It supports pretty much all providers and gets better every day. It has an optimized prompt for Qwen 3 Coder, and produces good results. I’ll definitely be using this more.</p>\n</li>\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/charmbracelet/crush\">charm crush</a> I <em>really</em> want to love this one. It’s gorgeous and fun to use. No surprise, it’s backed by a company that makes fun cli tools and that shows. Crush was released just yesterday and it’s still early. <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951288839814725862\">It has problems with the edit tool and sometimes just gets stuck</a>, at least when using it with Qwen 3 Coder. I had to <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/charmbracelet/crush/pull/414\">send a PR</a> to make it work with self hosted inference. There’s a whole team working on it so my hopes are up. If you use Anthropic’s models, I’m sure it performs much better. Personal deal-breaker: The non-working text selection. You can’t click on links either. I use this a lot so it’d really disruptive for my workflow.</p>\n</li>\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/musistudio/claude-code-router\">Claude Code with claude-code-router</a> Clever hack that patches Claude Code to use different models. Since CC is optimized for Anthropic’s models, tool use and overall results aren’t as good as with Sonnet or Opus. I didn’t explore this further.</p>\n</li>\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/cline/cline\">Cline</a> I used Cline for testing the model, but since it’s a VS Code extension and not a cli, it doesn’t fit my workflow, and generally <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951062013913727332\">I haven’t been impressed by it</a>.</p>\n</li>\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://ampcode.com/\">amp</a> Amp is a very opinionated CLI. It uses Claude Sonnet and has a tool that can invoke OpenAI’s o3. Pricing is forwarded without markup. You can’t use your subscription here, so until now, it wasn’t interesting. It’s hyped, in my tests <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951059420193968581\">it didn’t impress me tho</a>. Some people swear by it tho, and it’s certaily more token efficient than Claude Code.</p>\n</li>\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/google-gemini/gemini-cli\">Gemini CLI</a> / <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/QwenLM/qwen-code\">Qwen Code</a> I have high hopes for Gemini CLI, and with it, the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951058436030079159\">Qwen Code fork</a>. Gemini is REALLY FAST. I use it to debug tricky issues that need a large context space. Tool calling is still <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1942113964231442876\">very broken “I’m just a file”</a> and <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951301660950581709\">it can be really lazy</a>, however it’s open source and a lot of folks are working on making it better. As for the Quen Code fork, we’ll see if they keep up with the fast-paced development of Gemini or abandon it. I worry it’ll be the latter, at least from looking at the current pace of updates.</p>\n</li>\n</ul>\n<p>There are <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/RooCodeInc/Roo-Code\">so</a> <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://kiro.dev/\">many</a> <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.augmentcode.com/changelog/auggie-cli\">more</a> tools out there in all colors and sizes, and it’s really impressive how important tooling &amp; the right system prompt are (e.g. <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951080437188624564\">RooCode drawing diagrams!</a>). IMO that’s Claude Code’s strength: it’s optimized for just one model, and it shows.</p>\n<h2>The Infrastructure Journey</h2>\n<p>My main goals for this exploration are twofold: I don’t wanna be too dependent on one company &amp; tool (Anthropic), and I want to have a less costy solution for my heavy use.</p>\n<p>A few months ago I bought a Mac Studio with 512GB ram, top of the line, to experiment with models (and because it’s prettyyh). Turns out, back then there just wasn’t anything great out there that could compete with Opus &amp; Gemini. And then came Deepseek, and with that the realization that even the 512GB won’t get me very far.</p>\n<p>Yes, I can run Deepseek Coder V2 at ~25 tok/s or a quantified version of R1 at ~8–15 tok/s, but that’s not fun, and 128k context size is quite a bit of a downgrade compared to Claude’s 200k or Gemini’s 1Mio context. There’s ways to connect multiple Studio’s for more performance and/or less compressed models, but then we’re talking 30k$+ for the setup.</p>\n<p>Hardware is one thing - we also need capable models. These days, chinese labs releases better and more capable models on an almost weekly basis. The release of <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://qwenlm.github.io/blog/qwen3-coder/\">Qwen3-Coder-480B</a> got my attention, as it’s the first model that achieves a similar score on SWE-bench as Claude Sonnet 4. Plus, it has a native 256k token context window that can stretch to 1M tokens with YaRN.</p>\n<p>Running this needs some beefy hardware. NVidia’s H200 (Hopper refresh) is currently the best top-of-the-line choice. There’s also B200 (Blackwell), but they are usually even more expensive to rent, and software support is still quite weak.</p>\n<p>I’ve been experimenting with <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.primeintellect.ai/\">Prime Intellect</a>, <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://vast.ai/\">Vast.ai</a> and <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://datacrunch.io/\">DataCrunch</a>. Prices for 8xH200 machines range from $5-30/hour, depending on location, availability and if you rent a spot instance or a regular one. Now spot instances are instances that are available temporarily. Whenever data centers need more capacity, they will simply deprovision it and use it again.</p>\n<p>In my tests, if you get a H200 spot instance it’ll likely disappear before you are finished setting it up. They can be incredibly cheap, but it aint fun when you suddenly have to stop working and set up a new rack because of peak demand. We’re talking $6/h for spot instances vs $14/h for a regular 8xH200 rack, at least on DataCrunch, which seems to be one of the cheapest (while still reliable in my tests) options out there. On vast.ai, a similar setup is more like ~$26/h, and double that again if you look at AWS.</p>\n<p>The setup I’m currently running:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">8x</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> H200 (1128GB GPU VRAM</span><span class=\"syntax-meta syntax-function-call syntax-shell\"></span><span class=\"syntax-meta syntax-post-cmd syntax-shell\">)</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">176</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> CPU, 1450GB RAM</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">Ubuntu</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> 24.04, CUDA 12.8</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\"><span class=\"syntax-meta syntax-group syntax-expansion syntax-parameter syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-variable syntax-shell\">$</span><span class=\"syntax-variable syntax-other syntax-readwrite syntax-shell\">1</span></span>5/h</span></span>\n</span></span></code></pre>\n<p>With my rig I could set up the FP8<sup class=\"footnote-ref\"><a href=\"#fn-1\" id=\"fnref-1\" data-footnote-ref>1</a></sup>-version of Qwen3 Coder 480B with a 400k context. FP8 means smaller float’s, so you lose a few percent accuracy compared to the FP16-version, which is used for the benchmarks. For the Qwen model these losses are insignificant though, and it’s a big performance win, plus squeezing in the FP16 model would leave us with maybe 32k tokens of context.</p>\n<p>Memory is absolutely everything at this scale. The KV cache<sup class=\"footnote-ref\"><a href=\"#fn-2\" id=\"fnref-2\" data-footnote-ref>2</a></sup> (that’s what stores the conversation context) eats about 4.2MB per token when using FP16 precision. If you want a 1M token context window, you’d need 17-30 H200 GPUs. That’s why I “only” got 400k tokens with 8 GPUs.</p>\n<p>Setup is tricky, but since <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://steipete.me/posts/2025/claude-code-is-my-computer\">Claude Code is my computer</a>, it was mostly a bit of prompting and about half an hour waiting until the rig was ready - at least for H200.</p>\n<p>Currently sparse instances of B200 are an incredibly good deal (~$4/h) and they also been extremely stable in my tests. I also understand why: this hardware is so new that you’ll unlikely succeed running models efficiently on it. <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951217528161567193\">I spent all day on this and got it partially running</a>, but at no point was it faster than a 8xH200 rig. That will change in a few weeks tho as software catches up.</p>\n<p>Insane if you think about it: The 3 8xB200 rack hardware I rented here is worth about 2 Mio Dollar.</p>\n<h2>Cost Analysis</h2>\n<p>With the technical setup sorted, let’s get to the question everyone’s really asking about: Money.</p>\n<p>Running this setup costs $15/h per hour. That’s ~$360 per day if you run it 24/7, or about $11,000/month. You could recreate the machine every day to save money, but setting this up also takes 30-60 minutes each morning. That would drive cost down to ~$120 a day and ~$2,600 a month (if we just count work days, but who doesn’t work on the weekends?)</p>\n<p>Those numbers probably made you wince. So here’s the honest assessment after burning through all that cash:</p>\n<h2>Is It Worth It?</h2>\n<p>Simple answer: No. You can’t stop and easily restart instances, at least not with the hardware provider I tested. Restarted instances will be scheduled, but there’s no guarantee you get a spot in that data center, so it might take days or weeks until your setup reboots.</p>\n<p>What about performance? I naively thought that I’d get better performance with my personal 8xH200 rig, so I ran some tests. And since I couldn’t find a simple benchmark tool, <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://x.com/steipete/status/1951288839814725862\">I vibed one in go</a>. Turns out, Alibaba is slightly faster than my best optimized 8xH200 rig. Maybe that changes once someone gets the B200 racks working.</p>\n<p>If you want REAL performance and also a damn good deal, check out <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.cerebras.ai/blog/qwen3-coder-480b-is-live-on-cerebras\">Cerebra’s new offering</a> that came out today. Cerebras Code Max, 5000 messages per day for $200/month. About 20x faster than Claude 4 Sonnet.</p>\n<p>You can rent the 1 Mio-context version of Qwen 3 Coder on Alibaba for <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.alibabacloud.com/help/en/model-studio/models#8e453767fbkka\">$1-$6 In / $5-$60 Out per Million tokens</a>, depending how much context you’re using. That’s a lot of tokens you have to burn to make self-hosting cost effective. And yes, a self-hosted runner could be shared, but the economics are still against you, and you quickly run into bottlenecks if more than one person accesses your server concurrently.</p>\n<p>Compare to Anthropic: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.anthropic.com/pricing#api\">$15 / $75 for Opus, $3 / $15 for Sonnet</a></p>\n<p>Google’s Gemini 2.5 Pro: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://ai.google.dev/gemini-api/docs/pricing\">$1.25-$2.50 / $10-$15</a></p>\n<p>To give you an idea, on an intense day I need maybe 500 Mio tokens. Calculating the price is difficult tho, since many tokens are cached as you work through a session. The cost for that, when using Opus, would be about $1000; for Sonnet about $200 - that’s similar to running my rig for 8h. Using other models is significantly cheaper.</p>\n<p>Realistically, using Qwen 3 Coder with opencode is now a very usable and cost effective alternative today. And in a month when the subscription nerving takes effect, things will look different again.</p>\n<p>It’s great to know that open-source models are a merely 6-12 month behind the best commercial ones, and that it’s absolutely possible to host them yourself. Commercially tho, paying per token is the economically saner choice.</p>\n<p><strong>Verdict:</strong> Claude Code as terminal + coding, opencode + Qwen on Alibaba (or Cerebas for speeeeeed!) as alternative coding agent for simpler tasks (or when the subscription is used up) and Gemini for debugging.</p>\n<p>🤖 Setup Guide for AI Agents to Self-Hosting Qwen3-Coder-480B on 8xH200</p>\n<h2>Complete Setup Instructions for Self-Hosting Qwen3-Coder-480B</h2>\n<p>This guide provides step-by-step instructions for AI agents to set up Qwen3-Coder-480B on Vast.ai with maximum context window.</p>\n<h3>Prerequisites</h3>\n<ul>\n<li>Vast.ai account with billing configured</li>\n<li>SSH client installed</li>\n<li>2-3 hours for initial setup</li>\n</ul>\n<h3>Step 1: Create Vast.ai Instance</h3>\n<ol>\n<li>\n<p>Go to <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://vast.ai\">Vast.ai</a></p>\n</li>\n<li>\n<p>Search for instances with:</p>\n<ul>\n<li>8x H200 GPUs (minimum 4x H200)</li>\n<li>vLLM template pre-installed</li>\n<li>1TB+ disk space</li>\n<li>Good DLPerf score (&gt;80)</li>\n</ul>\n</li>\n<li>\n<p>Select instance and configure:</p>\n<pre><code class=\"language-plaintext\"><span class=\"code-snippet\">Docker Image: Leave default vLLM image\nJupyter: Optional (uses port 8080)\nSSH: Required\nDirect SSH: Recommended\n</span></code></pre>\n</li>\n<li>\n<p>Deploy instance and note:</p>\n<ul>\n<li>SSH port and IP</li>\n<li>Instance ID</li>\n<li>Cost per hour</li>\n</ul>\n</li>\n</ol>\n<h3>Step 2: SSH Configuration</h3>\n<p>Add to <code>~/.ssh/config</code>:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">Host</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> vastai-qwen</span>\n  <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">HostName</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> <span class=\"syntax-keyword syntax-control syntax-regexp syntax-set syntax-begin syntax-shell\">[</span>YOUR_IP<span class=\"syntax-keyword syntax-control syntax-regexp syntax-set syntax-end syntax-shell\">]</span></span>\n  <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">Port</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> <span class=\"syntax-keyword syntax-control syntax-regexp syntax-set syntax-begin syntax-shell\">[</span>YOUR_PORT<span class=\"syntax-keyword syntax-control syntax-regexp syntax-set syntax-end syntax-shell\">]</span></span>\n  <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">User</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> root</span>\n  <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">StrictHostKeyChecking</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> no</span>\n  <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">UserKnownHostsFile</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> /dev/null</span>\n</span></span></code></pre>\n<p>Create SSH tunnel:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">ssh</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>f</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>N</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>L</span> 8000:localhost:8000 vastai-qwen</span>\n</span></span></code></pre>\n<h3>Step 3: Deploy vLLM with Qwen3-480B</h3>\n<p>SSH into instance:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">ssh</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> vastai-qwen</span>\n</span></span></code></pre>\n<p>Check GPU status:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">nvidia-smi</span></span>\n</span></span></code></pre>\n<p>Create deployment script:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">cat</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&gt;</span> deploy-qwen3.sh <span class=\"syntax-string syntax-unquoted syntax-heredoc syntax-shell\"><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&lt;&lt;</span> <span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span><span class=\"syntax-keyword syntax-control syntax-heredoc-token syntax-shell\">EOF</span><span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span><span class=\"syntax-string syntax-unquoted syntax-heredoc syntax-shell\">\n#!/bin/bash\n\n# Kill any existing vLLM processes\npkill -f vllm.entrypoints.openai.api_server || true\n\n# Start vLLM with optimal settings\n/venv/main/bin/python -m vllm.entrypoints.openai.api_server \\\n  --model Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 \\\n  --served-model-name qwen3-coder \\\n  --tensor-parallel-size 8[^3] \\\n  --enable-expert-parallel \\\n  --gpu-memory-utilization 0.95 \\\n  --max-model-len 400000 \\\n  --rope-scaling &#39;{&quot;rope_type&quot;:&quot;yarn&quot;,&quot;factor&quot;:1.53,&quot;original_max_position_embeddings&quot;:262144}&#39; \\\n  --download-dir /workspace/models \\\n  --host 0.0.0.0 \\\n  --port 8000 \\\n  --trust-remote-code \\\n  --dtype float16 \\\n  --enable-prefix-caching \\\n  --enable-chunked-prefill \\\n  --max-num-batched-tokens 32768 \\\n  &gt; vllm.log 2&gt;&amp;1 &amp;\n\necho &quot;vLLM deployment started. Check vllm.log for progress.&quot;\n<span class=\"syntax-keyword syntax-control syntax-heredoc-token syntax-shell\">EOF</span></span></span>\n\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">chmod</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> +x deploy-qwen3.sh</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">./deploy-qwen3.sh</span></span>\n</span></span></code></pre>\n<h3>Step 4: Monitor Model Download</h3>\n<p>Model download takes 1-2 hours for 480GB:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Watch download progress</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">tail</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>f</span> vllm.log</span> <span class=\"syntax-keyword syntax-operator syntax-logical syntax-pipe syntax-shell\">|</span> <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">grep</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>E</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&quot;</span>Downloading|Loading|Progress<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&quot;</span></span></span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Check disk usage</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">watch</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>n</span> 5 <span class=\"syntax-string syntax-quoted syntax-single syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span>df -h /workspace<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span></span>\n</span></span></code></pre>\n<h3>Step 5: Disable Vast.ai Authentication</h3>\n<p>Vast.ai uses Caddy proxy with auth. Disable it:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Stop Caddy to remove authentication</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">supervisorctl</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> stop caddy</span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Verify direct access works</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">curl</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> http://localhost:8000/v1/models</span>\n</span></span></code></pre>\n<h3>Step 6: Configure AI Coding Clients</h3>\n<h4>For Cline (VS Code Extension):</h4>\n<ol>\n<li>\n<p>Install Cline extension in VS Code</p>\n</li>\n<li>\n<p>Open Cline settings</p>\n</li>\n<li>\n<p>Configure:</p>\n<pre><code class=\"language-plaintext\"><span class=\"code-snippet\">API Provider: OpenAI Compatible\nBase URL: http://localhost:8000/v1\nAPI Key: not-needed\nModel: qwen3-coder\n</span></code></pre>\n</li>\n</ol>\n<h4>For Cursor:</h4>\n<ol>\n<li>\n<p>Open Cursor settings</p>\n</li>\n<li>\n<p>Add custom model:</p>\n<pre><code class=\"language-json\"><span class=\"code-snippet\" data-language=\"JSON\"><span class=\"syntax-source syntax-json\"><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-json\"><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-begin syntax-json\">{</span>\n  <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>openai_api_key<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>not-needed<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n  <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>openai_api_base<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>http://localhost:8000/v1<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n  <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>model<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>qwen3-coder<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span>\n</span><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-end syntax-json\">}</span></span>\n</span></span></code></pre>\n</li>\n</ol>\n<h4>For Command Line (qwen CLI):</h4>\n<p>Create config at <code>~/.config/qwen/config.json</code>:</p>\n<pre><code class=\"language-json\"><span class=\"code-snippet\" data-language=\"JSON\"><span class=\"syntax-source syntax-json\"><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-json\"><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-begin syntax-json\">{</span>\n  <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>providers<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-json\"><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-begin syntax-json\">{</span>\n    <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>qwen3-local<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-json\"><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-begin syntax-json\">{</span>\n      <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>type<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>openai<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n      <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>base_url<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>http://localhost:8000/v1<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n      <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>api_key<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>not-needed<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n      <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>models<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-meta syntax-structure syntax-array syntax-json\"><span class=\"syntax-punctuation syntax-section syntax-array syntax-begin syntax-json\">[</span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-json\"><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-begin syntax-json\">{</span>\n        <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>id<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>qwen3-coder<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n        <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>name<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>Qwen3-Coder-480B (400k context)<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n        <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>context_window<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-constant syntax-numeric syntax-json\">400000</span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n        <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>max_tokens<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-constant syntax-numeric syntax-json\">16384</span>\n      </span><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-end syntax-json\">}</span></span><span class=\"syntax-punctuation syntax-section syntax-array syntax-end syntax-json\">]</span></span>\n    </span><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-end syntax-json\">}</span></span>\n  </span><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-end syntax-json\">}</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n  <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>default_provider<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>qwen3-local<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-pair syntax-json\">,</span></span>\n  <span class=\"syntax-meta syntax-structure syntax-dictionary syntax-key syntax-json\"><span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>default_model<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span></span><span class=\"syntax-meta syntax-structure syntax-dictionary syntax-value syntax-json\"><span class=\"syntax-punctuation syntax-separator syntax-dictionary syntax-key-value syntax-json\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-json\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-json\">&quot;</span>qwen3-coder<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-json\">&quot;</span></span>\n</span><span class=\"syntax-punctuation syntax-section syntax-dictionary syntax-end syntax-json\">}</span></span>\n</span></span></code></pre>\n<h3>Step 7: Test the Deployment</h3>\n<p>Test with curl:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">curl</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>X</span> POST http://localhost:8000/v1/chat/completions <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\">  -</span>H</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&quot;</span>Content-Type: application/json<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&quot;</span></span> <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\">  -</span>d</span> <span class=\"syntax-string syntax-quoted syntax-single syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span>{\n    &quot;model&quot;: &quot;qwen3-coder&quot;,\n    &quot;messages&quot;: [{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Write a Python hello world&quot;}],\n    &quot;max_tokens&quot;: 100\n  }<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span></span>\n</span></span></code></pre>\n<p>Test context window:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Create large context test</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">python3</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> <span class=\"syntax-string syntax-unquoted syntax-heredoc syntax-shell\"><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&lt;&lt;</span> <span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span><span class=\"syntax-keyword syntax-control syntax-heredoc-token syntax-shell\">EOF</span><span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span><span class=\"syntax-string syntax-unquoted syntax-heredoc syntax-shell\">\nimport requests\nimport json\n\n# Create a message with ~100k tokens (roughly 400k characters)\nlarge_context = &quot;The quick brown fox jumps over the lazy dog. &quot; * 10000\nmessages = [\n    {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: large_context},\n    {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Summarize the above in one sentence.&quot;}\n]\n\nresponse = requests.post(\n    &quot;http://localhost:8000/v1/chat/completions&quot;,\n    json={&quot;model&quot;: &quot;qwen3-coder&quot;, &quot;messages&quot;: messages, &quot;max_tokens&quot;: 50}\n)\n\nprint(json.dumps(response.json(), indent=2))\n<span class=\"syntax-keyword syntax-control syntax-heredoc-token syntax-shell\">EOF</span></span></span>\n</span></span></code></pre>\n<h3>Step 8: Performance Optimization</h3>\n<p>Monitor GPU utilization:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Real-time GPU monitoring</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">watch</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>n</span> 1 nvidia-smi</span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Check vLLM metrics</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">curl</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> http://localhost:8000/metrics</span>\n</span></span></code></pre>\n<p>Optimize for your use case:</p>\n<ul>\n<li><strong>For speed</strong>: Reduce max_model_len to 100k-200k</li>\n<li><strong>For context</strong>: Keep at 400k but expect slower responses</li>\n<li><strong>For cost</strong>: Use 4x H200 instead of 8x (limited to 190k context)</li>\n</ul>\n<h3>Step 9: Troubleshooting</h3>\n<p>Common issues and solutions:</p>\n<h4>Model won’t load</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Check available memory</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">nvidia-smi</span></span>\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Solution: Reduce --gpu-memory-utilization to 0.90</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span></span></span></code></pre>\n<h4>Authentication errors</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Ensure Caddy is stopped</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">supervisorctl</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> status</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">supervisorctl</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> stop caddy</span>\n</span></span></code></pre>\n<h4>Context too large errors</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Reduce max_model_len in deployment script</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> 4x H200: max 190000</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> 8x H200: max 400000</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span></span></span></code></pre>\n<h4>Slow responses</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Check batch settings</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Reduce --max-num-batched-tokens to 16384</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Enable streaming in client</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span></span></span></code></pre>\n<h3>Step 10: Cost Monitoring</h3>\n<p>Track usage and costs:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Create usage tracker</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">cat</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&gt;</span> track_usage.py <span class=\"syntax-string syntax-unquoted syntax-heredoc syntax-shell\"><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-redirection syntax-shell\">&lt;&lt;</span> <span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span><span class=\"syntax-keyword syntax-control syntax-heredoc-token syntax-shell\">EOF</span><span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span><span class=\"syntax-string syntax-unquoted syntax-heredoc syntax-shell\">\n#!/usr/bin/env python3\nimport time\nimport datetime\n\nstart_time = datetime.datetime.now()\nhourly_rate = 12.40  # Adjust based on your instance\n\nwhile True:\n    elapsed = datetime.datetime.now() - start_time\n    hours = elapsed.total_seconds() / 3600\n    cost = hours * hourly_rate\n    \n    print(f&quot;\\rRunning for: {elapsed} | Cost: ${cost:.2f}&quot;, end=&quot;&quot;)\n    time.sleep(60)\n<span class=\"syntax-keyword syntax-control syntax-heredoc-token syntax-shell\">EOF</span></span></span>\n\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">chmod</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> +x track_usage.py</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">./track_usage.py</span></span>\n</span></span></code></pre>\n<h3>Advanced: Context Window Tuning</h3>\n<p>For different context windows, adjust these parameters:</p>\n<h4>100k context (fastest):</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">--max-model-len</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> 100000 <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\">--</span>rope-scaling</span> <span class=\"syntax-string syntax-quoted syntax-single syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span>{&quot;rope_type&quot;:&quot;yarn&quot;,&quot;factor&quot;:1.0,&quot;original_max_position_embeddings&quot;:262144}<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span></span>\n</span></span></code></pre>\n<h4>256k context (native):</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">--max-model-len</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> 262144 <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\">--</span>rope-scaling</span> <span class=\"syntax-string syntax-quoted syntax-single syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span>{&quot;rope_type&quot;:&quot;yarn&quot;,&quot;factor&quot;:1.0,&quot;original_max_position_embeddings&quot;:262144}<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span></span>\n</span></span></code></pre>\n<h4>400k context (current):</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">--max-model-len</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> 400000 <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\">--</span>rope-scaling</span> <span class=\"syntax-string syntax-quoted syntax-single syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span>{&quot;rope_type&quot;:&quot;yarn&quot;,&quot;factor&quot;:1.53,&quot;original_max_position_embeddings&quot;:262144}<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span></span>\n</span></span></code></pre>\n<h4>760k context (maximum, requires 16+ H200s):</h4>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">--max-model-len</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> 760000 <span class=\"syntax-punctuation syntax-separator syntax-continuation syntax-line syntax-shell\">\\\n</span><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\">--</span>rope-scaling</span> <span class=\"syntax-string syntax-quoted syntax-single syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-shell\">&#39;</span>{&quot;rope_type&quot;:&quot;yarn&quot;,&quot;factor&quot;:2.9,&quot;original_max_position_embeddings&quot;:262144}<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-shell\">&#39;</span></span></span>\n</span></span></code></pre>\n<h3>Maintenance</h3>\n<p>Regular maintenance tasks:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Check logs for errors</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">tail</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>n</span> 100 vllm.log</span> <span class=\"syntax-keyword syntax-operator syntax-logical syntax-pipe syntax-shell\">|</span> <span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">grep</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> ERROR</span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Monitor disk space</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">df</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>h</span> /workspace</span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Restart vLLM if needed</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">pkill</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"><span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>f</span> vllm.entrypoints.openai.api_server</span>\n<span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">./deploy-qwen3.sh</span></span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Clean old model files</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">find</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> /workspace/models<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>type</span> f<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>mtime</span> +7<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> -</span>delete</span></span>\n</span></span></code></pre>\n<h3>Security Notes</h3>\n<ol>\n<li><strong>SSH Tunnel</strong>: Always use SSH tunnel, never expose port 8000 directly</li>\n<li><strong>API Key</strong>: Even though “not-needed”, don’t leave blank</li>\n<li><strong>Firewall</strong>: Ensure only SSH port is open on Vast.ai</li>\n<li><strong>Monitoring</strong>: Check access logs regularly</li>\n</ol>\n<h3>Cost-Saving Tips</h3>\n<ol>\n<li><strong>Pause when not using</strong>: Vast.ai charges by the minute</li>\n<li><strong>Use 4x H200</strong>: Sufficient for 190k context at half the cost</li>\n<li><strong>Spot instances</strong>: 90% cheaper but risk of termination</li>\n<li><strong>Optimize context</strong>: Most tasks don’t need 400k tokens</li>\n</ol>\n<p>This completes the detailed setup guide for AI agents. The entire process should take 2-3 hours including model download time.</p>\n<hr />\n<h2><strong>Btw:</strong> I’m organizing the first Claude Code Anonymous meetup in London on August 18. For people who build. DM me if you’re interested!</h2>\n<section class=\"footnotes\" data-footnotes>\n<ol>\n<li id=\"fn-1\">\n<p><strong>FP8/FP16</strong> - Floating-point precision formats. FP16 uses 16 bits per number (higher accuracy), FP8 uses 8 bits (lower memory usage, slightly less accurate). <a href=\"#fnref-1\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\"1\" aria-label=\"Back to reference 1\">↩</a></p>\n</li>\n<li id=\"fn-2\">\n<p><strong>KV Cache</strong> - Key-Value cache stores the model’s “memory” of previous tokens in the conversation, enabling efficient context handling without recomputing everything. <a href=\"#fnref-2\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\"2\" aria-label=\"Back to reference 2\">↩</a></p>\n</li>\n</ol>\n</section>\n",
  "content_markdown": "![](https://steipete.me/assets/img/2025/self-hosting-ai-models/hero.png)\n\nWhen Anthropic changed Claude Max’s subscription model from a 5-hour usage window to weekly limits, [it hit me hard](https://x.com/steipete/status/1949901121998508119).\n\n**TL;DR:** Claude Code is still king, Qwen 3 Coder + opencode is a strong contender tho. Have high hopes for Gemini cli and Crush.\n\n## Claude Code Anonymous\n\nI’m definitely part of the 1% that has got [**a ton**](https://x.com/steipete/status/1948549916604989706) of benefit out of their payment model, and I’m not entirely surprised that they’re changing the deal, given the incredible demand for Claude Code. Much like [Cursor’s recent pricing changes](https://www.reddit.com/r/cursor/comments/1lrc7q8/cursor_pricing_changed_after_12_days/), this caused a lot of anger in the community, and it also triggered my curiosity on what other options are out there.\n\nJust to set the record straight tho: While I often worked 16h-days, I never automated Claude Code and was well within their Terms of Service. My Anthropic bill for July is at [\\~6000$](https://x.com/steipete/status/1949908573452193866), since I’ve been using their GitHub Review bot, and while some people have been extracting the Max API Token to run on GitHub in the background, I opted to not break the rules and pay up… so Anthropic, we cool?\n\n## Evaluating The Landscape\n\nSo what are the alternatives? I spend some time testing every promising tool I could find. Claude Code is insofar hard to replace, as it’s this genius blend of amazing model & tooling. But the landscape is changing fast! There’s quite a few contenders out there that are worth a look:\n\n- [opencode](https://opencode.ai/) In my tests, opencode is the [most promising](https://x.com/steipete/status/1951288839814725862) alternative currently. It supports pretty much all providers and gets better every day. It has an optimized prompt for Qwen 3 Coder, and produces good results. I’ll definitely be using this more.\n\n- [charm crush](https://github.com/charmbracelet/crush) I *really* want to love this one. It’s gorgeous and fun to use. No surprise, it’s backed by a company that makes fun cli tools and that shows. Crush was released just yesterday and it’s still early. [It has problems with the edit tool and sometimes just gets stuck](https://x.com/steipete/status/1951288839814725862), at least when using it with Qwen 3 Coder. I had to [send a PR](https://github.com/charmbracelet/crush/pull/414) to make it work with self hosted inference. There’s a whole team working on it so my hopes are up. If you use Anthropic’s models, I’m sure it performs much better. Personal deal-breaker: The non-working text selection. You can’t click on links either. I use this a lot so it’d really disruptive for my workflow.\n\n- [Claude Code with claude-code-router](https://github.com/musistudio/claude-code-router) Clever hack that patches Claude Code to use different models. Since CC is optimized for Anthropic’s models, tool use and overall results aren’t as good as with Sonnet or Opus. I didn’t explore this further.\n\n- [Cline](https://github.com/cline/cline) I used Cline for testing the model, but since it’s a VS Code extension and not a cli, it doesn’t fit my workflow, and generally [I haven’t been impressed by it](https://x.com/steipete/status/1951062013913727332).\n\n- [amp](https://ampcode.com/) Amp is a very opinionated CLI. It uses Claude Sonnet and has a tool that can invoke OpenAI’s o3. Pricing is forwarded without markup. You can’t use your subscription here, so until now, it wasn’t interesting. It’s hyped, in my tests [it didn’t impress me tho](https://x.com/steipete/status/1951059420193968581). Some people swear by it tho, and it’s certaily more token efficient than Claude Code.\n\n- [Gemini CLI](https://github.com/google-gemini/gemini-cli) / [Qwen Code](https://github.com/QwenLM/qwen-code) I have high hopes for Gemini CLI, and with it, the [Qwen Code fork](https://x.com/steipete/status/1951058436030079159). Gemini is REALLY FAST. I use it to debug tricky issues that need a large context space. Tool calling is still [very broken “I’m just a file”](https://x.com/steipete/status/1942113964231442876) and [it can be really lazy](https://x.com/steipete/status/1951301660950581709), however it’s open source and a lot of folks are working on making it better. As for the Quen Code fork, we’ll see if they keep up with the fast-paced development of Gemini or abandon it. I worry it’ll be the latter, at least from looking at the current pace of updates.\n\nThere are [so](https://github.com/RooCodeInc/Roo-Code) [many](https://kiro.dev/) [more](https://www.augmentcode.com/changelog/auggie-cli) tools out there in all colors and sizes, and it’s really impressive how important tooling & the right system prompt are (e.g. [RooCode drawing diagrams!](https://x.com/steipete/status/1951080437188624564)). IMO that’s Claude Code’s strength: it’s optimized for just one model, and it shows.\n\n## The Infrastructure Journey\n\nMy main goals for this exploration are twofold: I don’t wanna be too dependent on one company & tool (Anthropic), and I want to have a less costy solution for my heavy use.\n\nA few months ago I bought a Mac Studio with 512GB ram, top of the line, to experiment with models (and because it’s prettyyh). Turns out, back then there just wasn’t anything great out there that could compete with Opus & Gemini. And then came Deepseek, and with that the realization that even the 512GB won’t get me very far.\n\nYes, I can run Deepseek Coder V2 at ~25 tok/s or a quantified version of R1 at ~8–15 tok/s, but that’s not fun, and 128k context size is quite a bit of a downgrade compared to Claude’s 200k or Gemini’s 1Mio context. There’s ways to connect multiple Studio’s for more performance and/or less compressed models, but then we’re talking 30k$+ for the setup.\n\nHardware is one thing - we also need capable models. These days, chinese labs releases better and more capable models on an almost weekly basis. The release of [Qwen3-Coder-480B](https://qwenlm.github.io/blog/qwen3-coder/) got my attention, as it’s the first model that achieves a similar score on SWE-bench as Claude Sonnet 4. Plus, it has a native 256k token context window that can stretch to 1M tokens with YaRN.\n\nRunning this needs some beefy hardware. NVidia’s H200 (Hopper refresh) is currently the best top-of-the-line choice. There’s also B200 (Blackwell), but they are usually even more expensive to rent, and software support is still quite weak.\n\nI’ve been experimenting with [Prime Intellect](https://www.primeintellect.ai/), [Vast.ai](https://vast.ai/) and [DataCrunch](https://datacrunch.io/). Prices for 8xH200 machines range from $5-30/hour, depending on location, availability and if you rent a spot instance or a regular one. Now spot instances are instances that are available temporarily. Whenever data centers need more capacity, they will simply deprovision it and use it again.\n\nIn my tests, if you get a H200 spot instance it’ll likely disappear before you are finished setting it up. They can be incredibly cheap, but it aint fun when you suddenly have to stop working and set up a new rack because of peak demand. We’re talking $6/h for spot instances vs $14/h for a regular 8xH200 rack, at least on DataCrunch, which seems to be one of the cheapest (while still reliable in my tests) options out there. On vast.ai, a similar setup is more like ~$26/h, and double that again if you look at AWS.\n\nThe setup I’m currently running:\n\n```bash\n8x H200 (1128GB GPU VRAM)\n176 CPU, 1450GB RAM\nUbuntu 24.04, CUDA 12.8\n$15/h\n```\n\nWith my rig I could set up the FP8[^1]-version of Qwen3 Coder 480B with a 400k context. FP8 means smaller float’s, so you lose a few percent accuracy compared to the FP16-version, which is used for the benchmarks. For the Qwen model these losses are insignificant though, and it’s a big performance win, plus squeezing in the FP16 model would leave us with maybe 32k tokens of context.\n\nMemory is absolutely everything at this scale. The KV cache[^2] (that’s what stores the conversation context) eats about 4.2MB per token when using FP16 precision. If you want a 1M token context window, you’d need 17-30 H200 GPUs. That’s why I “only” got 400k tokens with 8 GPUs.\n\nSetup is tricky, but since [Claude Code is my computer](https://steipete.me/posts/2025/claude-code-is-my-computer), it was mostly a bit of prompting and about half an hour waiting until the rig was ready - at least for H200.\n\nCurrently sparse instances of B200 are an incredibly good deal (~$4/h) and they also been extremely stable in my tests. I also understand why: this hardware is so new that you’ll unlikely succeed running models efficiently on it. [I spent all day on this and got it partially running](https://x.com/steipete/status/1951217528161567193), but at no point was it faster than a 8xH200 rig. That will change in a few weeks tho as software catches up.\n\nInsane if you think about it: The 3 8xB200 rack hardware I rented here is worth about 2 Mio Dollar.\n\n## Cost Analysis\n\nWith the technical setup sorted, let’s get to the question everyone’s really asking about: Money.\n\nRunning this setup costs $15/h per hour. That’s ~$360 per day if you run it 24/7, or about $11,000/month. You could recreate the machine every day to save money, but setting this up also takes 30-60 minutes each morning. That would drive cost down to ~$120 a day and ~$2,600 a month (if we just count work days, but who doesn’t work on the weekends?)\n\nThose numbers probably made you wince. So here’s the honest assessment after burning through all that cash:\n\n## Is It Worth It?\n\nSimple answer: No. You can’t stop and easily restart instances, at least not with the hardware provider I tested. Restarted instances will be scheduled, but there’s no guarantee you get a spot in that data center, so it might take days or weeks until your setup reboots.\n\nWhat about performance? I naively thought that I’d get better performance with my personal 8xH200 rig, so I ran some tests. And since I couldn’t find a simple benchmark tool, [I vibed one in go](https://x.com/steipete/status/1951288839814725862). Turns out, Alibaba is slightly faster than my best optimized 8xH200 rig. Maybe that changes once someone gets the B200 racks working.\n\nIf you want REAL performance and also a damn good deal, check out [Cerebra’s new offering](https://www.cerebras.ai/blog/qwen3-coder-480b-is-live-on-cerebras) that came out today. Cerebras Code Max, 5000 messages per day for $200/month. About 20x faster than Claude 4 Sonnet.\n\nYou can rent the 1 Mio-context version of Qwen 3 Coder on Alibaba for [$1-$6 In / $5-$60 Out per Million tokens](https://www.alibabacloud.com/help/en/model-studio/models#8e453767fbkka), depending how much context you’re using. That’s a lot of tokens you have to burn to make self-hosting cost effective. And yes, a self-hosted runner could be shared, but the economics are still against you, and you quickly run into bottlenecks if more than one person accesses your server concurrently.\n\nCompare to Anthropic: [$15 / $75 for Opus, $3 / $15 for Sonnet](https://www.anthropic.com/pricing#api)\n\nGoogle’s Gemini 2.5 Pro: [$1.25-$2.50 / $10-$15](https://ai.google.dev/gemini-api/docs/pricing)\n\nTo give you an idea, on an intense day I need maybe 500 Mio tokens. Calculating the price is difficult tho, since many tokens are cached as you work through a session. The cost for that, when using Opus, would be about $1000; for Sonnet about $200 - that’s similar to running my rig for 8h. Using other models is significantly cheaper.\n\nRealistically, using Qwen 3 Coder with opencode is now a very usable and cost effective alternative today. And in a month when the subscription nerving takes effect, things will look different again.\n\nIt’s great to know that open-source models are a merely 6-12 month behind the best commercial ones, and that it’s absolutely possible to host them yourself. Commercially tho, paying per token is the economically saner choice.\n\n**Verdict:** Claude Code as terminal + coding, opencode + Qwen on Alibaba (or Cerebas for speeeeeed!) as alternative coding agent for simpler tasks (or when the subscription is used up) and Gemini for debugging.\n\n🤖 Setup Guide for AI Agents to Self-Hosting Qwen3-Coder-480B on 8xH200\n\n## Complete Setup Instructions for Self-Hosting Qwen3-Coder-480B\n\nThis guide provides step-by-step instructions for AI agents to set up Qwen3-Coder-480B on Vast.ai with maximum context window.\n\n### Prerequisites\n\n- Vast.ai account with billing configured\n- SSH client installed\n- 2-3 hours for initial setup\n\n### Step 1: Create Vast.ai Instance\n\n1. Go to [Vast.ai](https://vast.ai)\n\n2. Search for instances with:\n\n   - 8x H200 GPUs (minimum 4x H200)\n   - vLLM template pre-installed\n   - 1TB+ disk space\n   - Good DLPerf score (>80)\n3. Select instance and configure:\n\n   ```plaintext\n   Docker Image: Leave default vLLM image\n   Jupyter: Optional (uses port 8080)\n   SSH: Required\n   Direct SSH: Recommended\n   ```\n\n4. Deploy instance and note:\n\n   - SSH port and IP\n   - Instance ID\n   - Cost per hour\n\n### Step 2: SSH Configuration\n\nAdd to `~/.ssh/config`:\n\n```bash\nHost vastai-qwen\n  HostName [YOUR_IP]\n  Port [YOUR_PORT]\n  User root\n  StrictHostKeyChecking no\n  UserKnownHostsFile /dev/null\n```\n\nCreate SSH tunnel:\n\n```bash\nssh -f -N -L 8000:localhost:8000 vastai-qwen\n```\n\n### Step 3: Deploy vLLM with Qwen3-480B\n\nSSH into instance:\n\n```bash\nssh vastai-qwen\n```\n\nCheck GPU status:\n\n```bash\nnvidia-smi\n```\n\nCreate deployment script:\n\n```bash\ncat > deploy-qwen3.sh << 'EOF'\n#!/bin/bash\n\n# Kill any existing vLLM processes\npkill -f vllm.entrypoints.openai.api_server || true\n\n# Start vLLM with optimal settings\n/venv/main/bin/python -m vllm.entrypoints.openai.api_server \\\n  --model Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 \\\n  --served-model-name qwen3-coder \\\n  --tensor-parallel-size 8[^3] \\\n  --enable-expert-parallel \\\n  --gpu-memory-utilization 0.95 \\\n  --max-model-len 400000 \\\n  --rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.53,\"original_max_position_embeddings\":262144}' \\\n  --download-dir /workspace/models \\\n  --host 0.0.0.0 \\\n  --port 8000 \\\n  --trust-remote-code \\\n  --dtype float16 \\\n  --enable-prefix-caching \\\n  --enable-chunked-prefill \\\n  --max-num-batched-tokens 32768 \\\n  > vllm.log 2>&1 &\n\necho \"vLLM deployment started. Check vllm.log for progress.\"\nEOF\n\nchmod +x deploy-qwen3.sh\n./deploy-qwen3.sh\n```\n\n### Step 4: Monitor Model Download\n\nModel download takes 1-2 hours for 480GB:\n\n```bash\n# Watch download progress\ntail -f vllm.log | grep -E \"Downloading|Loading|Progress\"\n\n# Check disk usage\nwatch -n 5 'df -h /workspace'\n```\n\n### Step 5: Disable Vast.ai Authentication\n\nVast.ai uses Caddy proxy with auth. Disable it:\n\n```bash\n# Stop Caddy to remove authentication\nsupervisorctl stop caddy\n\n# Verify direct access works\ncurl http://localhost:8000/v1/models\n```\n\n### Step 6: Configure AI Coding Clients\n\n#### For Cline (VS Code Extension):\n\n1. Install Cline extension in VS Code\n2. Open Cline settings\n3. Configure:\n\n   ```plaintext\n   API Provider: OpenAI Compatible\n   Base URL: http://localhost:8000/v1\n   API Key: not-needed\n   Model: qwen3-coder\n   ```\n\n#### For Cursor:\n\n1. Open Cursor settings\n2. Add custom model:\n\n   ```json\n   {\n     \"openai_api_key\": \"not-needed\",\n     \"openai_api_base\": \"http://localhost:8000/v1\",\n     \"model\": \"qwen3-coder\"\n   }\n   ```\n\n#### For Command Line (qwen CLI):\n\nCreate config at `~/.config/qwen/config.json`:\n\n```json\n{\n  \"providers\": {\n    \"qwen3-local\": {\n      \"type\": \"openai\",\n      \"base_url\": \"http://localhost:8000/v1\",\n      \"api_key\": \"not-needed\",\n      \"models\": [{\n        \"id\": \"qwen3-coder\",\n        \"name\": \"Qwen3-Coder-480B (400k context)\",\n        \"context_window\": 400000,\n        \"max_tokens\": 16384\n      }]\n    }\n  },\n  \"default_provider\": \"qwen3-local\",\n  \"default_model\": \"qwen3-coder\"\n}\n```\n\n### Step 7: Test the Deployment\n\nTest with curl:\n\n```bash\ncurl -X POST http://localhost:8000/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"qwen3-coder\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Write a Python hello world\"}],\n    \"max_tokens\": 100\n  }'\n```\n\nTest context window:\n\n```bash\n# Create large context test\npython3 << 'EOF'\nimport requests\nimport json\n\n# Create a message with ~100k tokens (roughly 400k characters)\nlarge_context = \"The quick brown fox jumps over the lazy dog. \" * 10000\nmessages = [\n    {\"role\": \"system\", \"content\": large_context},\n    {\"role\": \"user\", \"content\": \"Summarize the above in one sentence.\"}\n]\n\nresponse = requests.post(\n    \"http://localhost:8000/v1/chat/completions\",\n    json={\"model\": \"qwen3-coder\", \"messages\": messages, \"max_tokens\": 50}\n)\n\nprint(json.dumps(response.json(), indent=2))\nEOF\n```\n\n### Step 8: Performance Optimization\n\nMonitor GPU utilization:\n\n```bash\n# Real-time GPU monitoring\nwatch -n 1 nvidia-smi\n\n# Check vLLM metrics\ncurl http://localhost:8000/metrics\n```\n\nOptimize for your use case:\n\n- **For speed**: Reduce max\\_model\\_len to 100k-200k\n- **For context**: Keep at 400k but expect slower responses\n- **For cost**: Use 4x H200 instead of 8x (limited to 190k context)\n\n### Step 9: Troubleshooting\n\nCommon issues and solutions:\n\n#### Model won’t load\n\n```bash\n# Check available memory\nnvidia-smi\n# Solution: Reduce --gpu-memory-utilization to 0.90\n```\n\n#### Authentication errors\n\n```bash\n# Ensure Caddy is stopped\nsupervisorctl status\nsupervisorctl stop caddy\n```\n\n#### Context too large errors\n\n```bash\n# Reduce max_model_len in deployment script\n# 4x H200: max 190000\n# 8x H200: max 400000\n```\n\n#### Slow responses\n\n```bash\n# Check batch settings\n# Reduce --max-num-batched-tokens to 16384\n# Enable streaming in client\n```\n\n### Step 10: Cost Monitoring\n\nTrack usage and costs:\n\n```bash\n# Create usage tracker\ncat > track_usage.py << 'EOF'\n#!/usr/bin/env python3\nimport time\nimport datetime\n\nstart_time = datetime.datetime.now()\nhourly_rate = 12.40  # Adjust based on your instance\n\nwhile True:\n    elapsed = datetime.datetime.now() - start_time\n    hours = elapsed.total_seconds() / 3600\n    cost = hours * hourly_rate\n    \n    print(f\"\\rRunning for: {elapsed} | Cost: ${cost:.2f}\", end=\"\")\n    time.sleep(60)\nEOF\n\nchmod +x track_usage.py\n./track_usage.py\n```\n\n### Advanced: Context Window Tuning\n\nFor different context windows, adjust these parameters:\n\n#### 100k context (fastest):\n\n```bash\n--max-model-len 100000 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.0,\"original_max_position_embeddings\":262144}'\n```\n\n#### 256k context (native):\n\n```bash\n--max-model-len 262144 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.0,\"original_max_position_embeddings\":262144}'\n```\n\n#### 400k context (current):\n\n```bash\n--max-model-len 400000 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":1.53,\"original_max_position_embeddings\":262144}'\n```\n\n#### 760k context (maximum, requires 16+ H200s):\n\n```bash\n--max-model-len 760000 \\\n--rope-scaling '{\"rope_type\":\"yarn\",\"factor\":2.9,\"original_max_position_embeddings\":262144}'\n```\n\n### Maintenance\n\nRegular maintenance tasks:\n\n```bash\n# Check logs for errors\ntail -n 100 vllm.log | grep ERROR\n\n# Monitor disk space\ndf -h /workspace\n\n# Restart vLLM if needed\npkill -f vllm.entrypoints.openai.api_server\n./deploy-qwen3.sh\n\n# Clean old model files\nfind /workspace/models -type f -mtime +7 -delete\n```\n\n### Security Notes\n\n1. **SSH Tunnel**: Always use SSH tunnel, never expose port 8000 directly\n2. **API Key**: Even though “not-needed”, don’t leave blank\n3. **Firewall**: Ensure only SSH port is open on Vast.ai\n4. **Monitoring**: Check access logs regularly\n\n### Cost-Saving Tips\n\n1. **Pause when not using**: Vast.ai charges by the minute\n2. **Use 4x H200**: Sufficient for 190k context at half the cost\n3. **Spot instances**: 90% cheaper but risk of termination\n4. **Optimize context**: Most tasks don’t need 400k tokens\n\nThis completes the detailed setup guide for AI agents. The entire process should take 2-3 hours including model download time.\n\n* * *\n\n## **Btw:** I’m organizing the first Claude Code Anonymous meetup in London on August 18. For people who build. DM me if you’re interested!\n\n[^1]: **FP8/FP16** - Floating-point precision formats. FP16 uses 16 bits per number (higher accuracy), FP8 uses 8 bits (lower memory usage, slightly less accurate).\n\n[^2]: **KV Cache** - Key-Value cache stores the model’s “memory” of previous tokens in the conversation, enabling efficient context handling without recomputing everything.\n",
  "dateCreated": "2026-09-27T19:29:15.293681927+00:00",
  "date_created": "2025-07-31T09:00:00+00:00",
  "date_modified": "2025-07-31T09:00:00+00:00",
  "date_published": "2025-07-31T09:00:00+00:00",
  "description": "After Claude Pro changed to weekly limits, I explored self-hosting Qwen3-Coder-480B with 400k context windows. Here's what I learned about costs, alternatives, and why Claude Code still dominates the landscape.",
  "external_url": "https://steipete.me/posts/2025/self-hosting-ai-models/",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/steipete-me/2025/07/2025-07-31-self-hosting-ai-models-after-claude-s-usage-limits.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/steipete-me/2025/07/2025-07-31-self-hosting-ai-models-after-claude-s-usage-limits.md"
  },
  "id": "urn:aggr:item:316570e7263fa7134efbe6cf3374390122bd21ed",
  "isBasedOn": {
    "@id": "https://steipete.me/posts/2025/self-hosting-ai-models/"
  },
  "mainEntity": {
    "@id": "https://steipete.me/posts/2025/self-hosting-ai-models/",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/steipete-me/2025-07-31-self-hosting-ai-models-after-claude-s-usage-limits/#webpage"
    },
    "dateModified": "2025-07-31T09:00:00+00:00",
    "datePublished": "2025-07-31T09:00:00+00:00",
    "headline": "Self-Hosting AI Models After Claude's Usage Limits",
    "timeRequired": "PT13M",
    "url": "https://steipete.me/posts/2025/self-hosting-ai-models/",
    "wordCount": 2895
  },
  "name": "Archived snapshot: Self-Hosting AI Models After Claude's Usage Limits",
  "preview": null,
  "reading_minutes": 13,
  "replicated_at": null,
  "source": "steipete-me",
  "source_name": "Peter Steinberger",
  "summary": "After Claude Pro changed to weekly limits, I explored self-hosting Qwen3-Coder-480B with 400k context windows. Here's what I learned about costs, alternatives, and why Claude Code still dominates the landscape.",
  "tags": [],
  "temporalCoverage": "2026-09-27T19:29:15.293681927+00:00",
  "title": "Self-Hosting AI Models After Claude's Usage Limits",
  "url": "https://aggr.aymericbeaumet.com/items/steipete-me/2025-07-31-self-hosting-ai-models-after-claude-s-usage-limits/",
  "word_count": 2895
}