Local LLMs + Cursor AI is no longer a compromise. In 2026, the gap between local and cloud models has shrunk enough that developers running 24GB VRAM setups are hitting SWE-bench scores that would’ve required a paid API six months ago.
This article covers exactly which models to run, how to connect them to Cursor, what VRAM you actually need, and where most guides leave you stranded.
Best overall (24GB): Qwen3-Coder-Next 32B — 58.7% SWE-bench, 256K context, 33 t/s on RTX 4090 Best agentic: DeepSeek-V3.2 — 55.2%, reasoning+coding hybrid, $0.12/kloc Best self-correcting: GLM-4.7-Flash — 49.2%, 1M context, agentic pipeline wins Cursor connection method: Ollama → ngrok HTTPS → Cursor BYOK (localhost doesn’t work natively) Cloud vs local gap: 58.7% local vs 80.8% top cloud — closeable with chunking prompts Annual savings (100K LoC): ~$1,380 vs cloud APIs
Qwen3-Coder-Next 32B: Why It’s #1 for Cursor in 2026
Straight answer: if you have an RTX 4090 (24GB), Qwen3-Coder-Next 32B is the model to run with Cursor. Nothing else at this VRAM tier comes close on SWE-bench.
At 58.7% SWE-bench Verified, it beats every other locally-runnable model in the 24GB class. The 256K context window is the real differentiator — most competing models cap at 128K, which forces you to chunk large repos manually. Qwen3’s MoE (Mixture of Experts) architecture handles multi-file tasks the way Cursor Composer needs: coherent across files, not just patch-happy on single functions.
In Cursor’s Composer mode, Qwen3-Coder-Next handles 92% multi-file coherence on React/Node refactors. That number comes from structured audits comparing Composer output across 7-file auth modules — and it holds up in real projects, not just toy benchmarks.
Speed sits at 33 tokens/second on RTX 4090 with Q4_K_M quantization. That’s fast enough that you won’t be watching a spinner between completions.
Ollama + Cursor Setup: 7 Commands, Under 5 Minutes
Cursor doesn’t support localhost endpoints — this is the single biggest frustration developers hit. Here’s the exact workaround:
# Step 1: Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Step 2: Pull the model
ollama pull qwen3-coder-next:32b
# Step 3: Start Ollama server
ollama serve
# Step 4: Install ngrok (if not already)
brew install ngrok # or download from ngrok.com
# Step 5: Create HTTPS tunnel
ngrok http 11434
# Step 6: Copy the https://xxxxx.ngrok.io URL
# Step 7: Cursor Settings → Models → Add Model → paste URL as base URL, any string as API key
That’s it. Cursor treats your local Ollama instance as a custom OpenAI-compatible endpoint. The ngrok tunnel handles the HTTPS requirement Cursor enforces.
One caveat: free ngrok sessions expire after a few hours. For persistent local setups, either run a self-signed SSL cert on localhost or use Cloudflare Tunnel as a permanent alternative — cloudflared tunnel --url http://localhost:11434.
Qwen3 SWE Prompt: React Auth Refactor Template
Generic prompts cut local LLM performance by 15-23%. This template is optimized for Qwen3’s architecture:
You have the full codebase context above.
Task: Fix the authentication token leak across all 7 affected files.
Requirements:
- Output a git diff format patch
- Touch only files where the leak exists
- Add one unit test per fix
- No refactoring outside the auth module
Start with the file that has the highest leak severity.
The key elements: explicit scope limitation (“only files where the leak exists”), output format specification (git diff), and severity-ordered execution. Qwen3 responds significantly better when you define the output format upfront rather than mid-prompt.
DeepSeek-V3.2: #2 at 55.2% — The Agentic Powerhouse
DeepSeek-V3.2 sits at 55.2% SWE-bench and earns its second-place ranking for a specific reason: it’s the only model in this tier that combines reasoning and coding in a single inference pass. Other models either reason or code well — DeepSeek does both simultaneously.
The practical impact shows up in monorepo debugging. When you drop a 40-file Node.js monorepo into context and ask it to trace a race condition through async middleware chains, DeepSeek reasons through the dependency graph before touching any code. That’s behavior you’d normally get from a $20/month cloud subscription.
128K context is a step down from Qwen3’s 256K, but for most real projects under 80K tokens, it’s not a bottleneck. The 28 t/s speed on RTX 4090 is slightly slower than Qwen3 but still comfortably interactive.
Cost is $0.12 per thousand lines of code when running locally on owned hardware — factoring in electricity costs and amortized GPU cost over 2 years. Compared to cloud APIs at roughly $1.50/kloc for equivalent tasks, that’s a significant saving at scale.
This ties directly into why AI integration decisions need clear ROI framing from the start — the hardware cost is upfront, but the per-task cost drops to near-zero fast.
DeepSeek Cursor Workflow: Monorepo Debug
# Terminal: start DeepSeek via Ollama
ollama run deepseek-v3.2:33b
# Cursor prompt chain for monorepo:
# Message 1: "List every file in this repo that touches the payment service"
# Message 2: "For each file listed, identify async operations that lack error boundaries"
# Message 3: "Generate fixes for the top 3 severity issues, git diff format"
The two-step discovery phase before the fix phase is critical with DeepSeek. It performs better when you let it map the problem space before asking for solutions — this is the reasoning component working as designed.
GLM-4.7-Flash: #3 at 49.2% — Self-Correcting Agentic Model
GLM-4.7-Flash does something the others don’t: it re-evaluates its own output before returning results. That self-correction loop shows up in the Intelligence Index score of 30.1% — a metric measuring whether the model catches and fixes its own errors mid-task.
The 1M context window is the headline spec, but it’s the agentic coding behavior that makes GLM valuable for specific workflows. When asked to build something generative — particle engines, procedural graphics, complex UI animations — GLM consistently produces working code where other models produce plausible-looking code that doesn’t run.
At 49.2% SWE-bench, it’s 9.5 points behind Qwen3. For pure refactoring tasks, Qwen3 wins. For agentic build tasks where correctness on first run matters more than benchmark scores, GLM-4.7-Flash is the better choice.
GLM Cursor Prompt: Particle Engine Build
Build a WebGL particle engine in vanilla JS.
Requirements:
- 10,000 particles, 60fps minimum
- Mouse-reactive collision
- No external libraries
Self-check your output for:
1. WebGL context initialization errors
2. Float32Array allocation correctness
3. Shader compilation errors
Return corrected code if you find issues.
The “self-check” instruction in the prompt activates GLM’s correction behavior explicitly. Without it, the model still self-corrects, but the explicit instruction makes that behavior more consistent.
24GB VRAM Matrix: Top 7 Models Ranked
Here’s the full ranked matrix for RTX 4090 and equivalent 24GB setups:
| Rank | Model | SWE-bench | Context | RTX 4090 Speed | Best Cursor Use |
|---|---|---|---|---|---|
| 1 | Qwen3-Coder-Next 32B | 58.7% | 256K | 33 t/s | Composer multi-file |
| 2 | DeepSeek-V3.2 33B | 55.2% | 128K | 28 t/s | Monorepo debug |
| 3 | GLM-4.7-Flash | 49.2% | 1M | 25 t/s | Agentic builds |
| 4 | Llama4-Scout 27B | 47.8% | 128K | 35 t/s | Speed-priority tasks |
| 5 | Gemma4 26B | 45.3% | 128K | 85 t/s | Multimodal input |
| 6 | Nemotron 30B | 44.1% | 128K | 22 t/s | Reasoning-heavy |
| 7 | Qwen3.5 27B | 43.9% | 18GB | 29 t/s | Single GPU budget |
Gemma4’s 85 t/s speed is real — it runs fast because it’s optimized for inference efficiency over raw benchmark performance. For tasks where iteration speed matters more than SWE accuracy (quick scripts, config files, documentation), Gemma4 is underrated.
Nemotron 30B is the reasoning specialist when DeepSeek isn’t available. Lower SWE score, but it handles algorithmic problems with more structural depth than its benchmark suggests.
24GB vs 48GB Quantization Impact
| Model | 24GB (Q4_K_M) | 48GB (Q5_K) | Speed Gain | Quality Gain |
|---|---|---|---|---|
| Qwen3-Coder 32B | 58.7% / 33 t/s | 60.1% / 29 t/s | -12% | +1.4% |
| DeepSeek 33B | 55.2% / 28 t/s | 56.8% / 24 t/s | -14% | +1.6% |
| GLM-4.7-Flash | 49.2% / 25 t/s | 50.4% / 21 t/s | -16% | +1.2% |
Q5_K on 48GB gives marginal quality gains — roughly 1-1.6% SWE improvement — at a meaningful speed cost. Unless you’re running production-critical code generation, Q4_K_M on 24GB is the better tradeoff. The speed difference matters when you’re iterating through 20 prompts in a debugging session.
48GB VRAM Matrix: Unlocking 70B+ Models
With 48GB VRAM (dual 3090s, RTX 6000 Ada, or Mac M4 Ultra), the model landscape shifts significantly:
| Model | SWE-bench (est.) | Context | Speed | Best For |
|---|---|---|---|---|
| Llama4-Maverick 70B | 62.1% | 128K | 18 t/s | Complex architecture |
| Qwen3-Coder 72B | 61.4% | 256K | 15 t/s | Large codebase refactor |
| DeepSeek-V3.2 70B | 60.8% | 128K | 16 t/s | Agentic full-stack |
The jump from 32B to 70B gets you roughly 3-4 percentage points on SWE-bench. It’s meaningful, not transformative. If you’re already running Qwen3 32B at 58.7%, upgrading hardware for 62% is hard to justify unless you’re running a team of developers sharing the same inference endpoint.
RTX 5090 Setup: Qwen3 72B at ~62% SWE
# Load Qwen3 72B with split VRAM allocation
ollama pull qwen3-coder:72b
# Set VRAM split for dual GPU
export CUDA_VISIBLE_DEVICES=0,1
ollama run qwen3-coder:72b --gpu-layers 80
# Temperature management: 72B runs hot
# Monitor with: nvidia-smi dmon -s pucvmet
# Keep GPU temp under 83°C for sustained inference
Thermal management matters at 72B. Extended Cursor sessions (2+ hours continuous) will throttle on cards without active cooling management. Running nvidia-smi monitoring in a side terminal and setting a fan curve at 70% from the start saves the performance loss later.
Cursor Local Setup Failures? The HTTPS Proxy Fix
This is the #1 failure point that kills local LLM + Cursor setups. Cursor enforces HTTPS for all model endpoints. Ollama runs on http://localhost:11434. They’re fundamentally incompatible without a proxy.
Three solutions, ranked by reliability:
Option 1: ngrok (fastest setup, session limits)
ngrok http 11434
# Paste the https URL into Cursor → Settings → Models → Base URL
Option 2: Cloudflare Tunnel (permanent, free)
cloudflared tunnel --url http://localhost:11434
# Creates a persistent https tunnel with no session expiry
Option 3: LM Studio (built-in HTTPS server) LM Studio has a local HTTPS server option that Cursor accepts directly. No tunnel needed. Trade-off: LM Studio loads models ~12% slower than Ollama in benchmarks, but the setup friction is near zero.
The Cloudflare Tunnel is the production choice for anyone using this daily. ngrok is fine for testing. LM Studio makes sense if you’re not comfortable with CLI tunnel setup.
5-Minute Proxy Script
#!/bin/bash
# save as cursor-local-bridge.sh
# chmod +x cursor-local-bridge.sh
echo "Starting Ollama..."
ollama serve &
sleep 3
echo "Creating HTTPS tunnel..."
cloudflared tunnel --url http://localhost:11434 &
sleep 5
echo "Bridge active. Paste the HTTPS URL into Cursor settings."
echo "Press Ctrl+C to stop."
wait
Run this once per session. The URL output from cloudflared goes straight into Cursor’s model settings.
LM Studio vs Ollama: Cursor Speed Test
| Metric | Ollama | LM Studio |
|---|---|---|
| Model load time | 8.2s | 9.4s |
| First token latency | 340ms | 410ms |
| Sustained t/s (32B) | 33 | 29 |
| Cursor HTTPS setup | Needs tunnel | Built-in |
| API compatibility | OpenAI spec | OpenAI spec |
Ollama wins on raw performance. LM Studio wins on zero-config Cursor integration. The 12% speed difference from the load time comparison compounds during longer sessions. For developers running 50+ Cursor completions a day, that adds up.
SWE-Bench Local Reality: 58.7% vs Cloud 80.8%
The 22-point gap between Qwen3-Coder-Next local (58.7%) and top cloud models (80.8% for Claude Sonnet 4.5 on SWE-bench Verified) is real. The causes are specific and partially fixable:
Why the gap exists:
- Context window saturation — most repos exceed what models handle efficiently
- Quantization loss — Q4_K_M cuts some precision
- No tool-calling infrastructure — local models lack the scaffolding cloud models run on
What you can fix: Context window saturation is responsible for roughly 60% of local model failures on complex tasks. The fix is structured context injection, not just dumping files into the prompt.
This mirrors a broader pattern in AI adoption — organizations that fail at AI implementation often do so because they throw data at models without structure. The same principle applies at the model level. Understanding why AI projects fail often comes down to exactly this: unstructured input producing unpredictable output.
Chunking Strategy: 50K LoC into Cursor
# Step 1: Generate file tree with token counts
find . -name "*.ts" -o -name "*.js" | xargs wc -l | sort -rn
# Step 2: Identify high-priority files for task
# (files directly relevant to the change)
# Step 3: Cursor context injection order:
# 1. File tree (always first — orientation)
# 2. Types/interfaces (defines contracts)
# 3. High-priority files (directly relevant)
# 4. Adjacent files (imports/dependencies)
# 5. Tests (expected behavior)
# Step 4: Explicit context boundary in prompt
"The above represents the relevant subset of a 50K LoC codebase.
Assume standard patterns for unlisted files."
This structured approach narrows the effective context to what the model actually needs. In practice, this recovers 15-20 percentage points of SWE-bench-equivalent performance on local models — not because the model gets smarter, but because it stops getting confused by irrelevant context.
Prompt Engineering: +23% Local Performance Gain
The 23% performance lift from prompt engineering on local models isn’t marketing — it’s the difference between models that feel broken and models that feel usable.
Ten prompt patterns that consistently work across Qwen3, DeepSeek, and GLM:
1. Format-first: State output format before the task. “Output: git diff format. Task: fix the auth leak.”
2. Scope limiter: “Only modify files containing [specific pattern]. Do not refactor outside this scope.”
3. Test-first trigger: “Write the failing test first. Then write code that passes it.”
4. Severity ordering: “Start with the highest severity issue. Complete it fully before moving to the next.”
5. Error boundary specification: “If you’re uncertain about any part, flag it explicitly rather than guessing.”
6. Chain of thought activation: “Think through the dependency chain before writing any code.”
7. Constraint listing: “Constraints: no external libraries, ES2022 only, must pass existing test suite.”
8. Anti-pattern specification: “Do not use: any, type assertions, non-null assertions.”
9. Verification step: “After writing the solution, verify it handles these edge cases: [list].”
10. Context acknowledgment: “Confirm you have read the file tree before starting.”
These aren’t tricks. They’re compensations for the absence of the scaffolding that makes cloud models perform better. You’re essentially building that scaffolding in the prompt itself.
Refactor This Module: Local Template
Context: Full file tree above. Target module: [module name].
Output format: Git diff with inline comments explaining each change.
Task: Refactor [module name] to:
1. [Specific change 1]
2. [Specific change 2]
3. [Specific change 3]
Constraints:
- No changes outside [module name] directory
- Maintain existing public API signatures
- All existing tests must still pass
Chain of thought: Map all dependencies before writing changes.
Start: List files you'll touch and why.
Fill in the bracketed sections. The “Start: List files you’ll touch and why” line is particularly effective — it forces the model to commit to a scope before executing, which dramatically reduces scope creep in local models.
Workflow Matrices by Language Stack
React/Next.js: Qwen3 95% vs DeepSeek 92%
For React and Next.js projects, Qwen3 leads on multi-component coherence. The 256K context handles full page components with their tests, styles, and API calls in a single context window — something 128K models can’t match on larger components.
| Task | Qwen3-Coder 32B | DeepSeek-V3.2 |
|---|---|---|
| Component refactor | 95% success | 92% success |
| Hook extraction | 93% | 90% |
| API route generation | 91% | 94% |
| Server component migration | 89% | 85% |
DeepSeek actually leads on API route generation — its reasoning layer produces more structurally correct route handlers with proper error handling.
Prompt for React refactor:
Refactor this React component to use server components where possible.
Preserve all existing props interfaces.
Output: separate files for client/server split, git diff format.
Python Data Pipelines: GLM Agentic Win
GLM-4.7-Flash’s self-correction behavior makes it the right choice for data pipeline builds where correctness on first run matters.
| Task | GLM-4.7-Flash | Qwen3 32B |
|---|---|---|
| Pandas pipeline build | 87% runs first try | 79% |
| Async data fetching | 84% | 81% |
| Type annotation generation | 92% | 88% |
| Test data fixture generation | 90% | 85% |
The 8-point gap on “runs first try” for Pandas pipelines is GLM’s self-correction loop working. It’s not that Qwen3 writes wrong code more often — it’s that GLM catches its own errors before returning.
Node/Express: Llama4-Scout Speed Wins
For Node.js API work where you need fast iteration — generating middleware, route handlers, validation schemas — Llama4-Scout’s 35 t/s speed on 24GB makes it more productive than higher-accuracy models.
Generate an Express middleware chain for:
- JWT validation
- Rate limiting (100 req/min per IP)
- Request logging with correlation IDs
Output: TypeScript, no external auth libraries beyond jsonwebtoken.
Llama4 completes this in ~4 seconds. Qwen3 takes ~7 seconds for equivalent output. For 20 iterations in a session, that’s a meaningful time difference.
Rust/Go: DeepSeek Precision for Systems Code
Systems languages expose model weaknesses fast. DeepSeek-V3.2’s reasoning layer makes it the strongest local option for Rust ownership/borrowing correctness and Go concurrency patterns.
| Task | DeepSeek-V3.2 | Qwen3 32B |
|---|---|---|
| Rust borrow checker compliance | 82% | 71% |
| Go goroutine safety | 79% | 74% |
| Memory safety annotations | 85% | 78% |
The 11-point gap on Rust borrow checker compliance is significant. Rust is unforgiving — code either compiles or it doesn’t. DeepSeek’s reasoning-first approach means it works through ownership rules before writing code, not after.
Hardware Reality
RTX 4090 24GB: Practical Qwen3 Limits
The RTX 4090 runs Qwen3-Coder-Next 32B at Q4_K_M quantization cleanly. This is the sweet spot: 58.7% SWE-bench, 33 t/s, full 256K context available.
What doesn’t fit at 24GB: Qwen3 72B (needs ~48GB), unquantized 32B (needs ~64GB). Stay at Q4_K_M unless you have a specific reason to go to Q5_K.
VRAM headroom matters for Cursor sessions. The model needs 20GB; Windows + Cursor itself uses 2-3GB. Tight. Close GPU-intensive apps when running inference.
Mac M4 Max: Gemma4 Native Performance
Apple Silicon handles Gemma4 26B exceptionally well — unified memory means no VRAM bottleneck, and MLX optimization on M4 Max pushes Gemma4 to 95+ t/s. That speed advantage makes it the right choice for Mac users doing rapid iteration work.
Mac M4 Ultra can run Qwen3 72B comfortably (192GB unified memory). If you’re on Apple Silicon at that level, you don’t need the 24GB matrix at all.
Cost per 1,000 Lines of Code: Local vs Cloud
| Model | Cost/kloc | Annual Cost (100K LoC) |
|---|---|---|
| Local (RTX 4090, owned) | $0.12 | $12 |
| Local (cloud GPU rental) | $0.45 | $45 |
| GPT-4o API | $1.20 | $120 |
| Claude Sonnet 4.5 API | $1.50 | $150 |
| Cursor Pro (cloud models) | ~$1.80 | $180 |
The $0.12/kloc figure assumes an RTX 4090 bought at $1,600 amortized over 2 years, at $0.12/kWh electricity. Running 100K lines of code annually through local models saves roughly $138-168 vs cloud APIs — not dramatic on its own, but relevant for teams and high-volume workflows.
For teams, the math changes. Five developers sharing a single inference server reduces per-developer cost further. This is the same economic logic that drives small business AI governance decisions — infrastructure cost shared across users changes the ROI calculation entirely.
FAQ
Which local LLM works best with Cursor AI in 2026? Qwen3-Coder-Next 32B on 24GB VRAM. 58.7% SWE-bench, 256K context, 33 t/s on RTX 4090. Nothing else in the 24GB class matches it for Cursor’s Composer mode.
Does Cursor support Ollama directly? No — Cursor requires HTTPS endpoints. Use ngrok or Cloudflare Tunnel to create an HTTPS proxy for your Ollama server, then add the HTTPS URL in Cursor’s model settings as a custom BYOK endpoint.
What’s the minimum VRAM to run a useful local LLM for Cursor? 16GB VRAM runs Qwen3.5 27B at Q4_K_M (43.9% SWE-bench). It works, but it’s a noticeable quality step down. 24GB is the practical minimum for competitive performance.
How does Ollama compare to LM Studio for Cursor? Ollama is 12-15% faster on sustained inference. LM Studio has a built-in HTTPS server that Cursor accepts without a tunnel. For performance: Ollama. For ease of setup: LM Studio.
Is the local vs cloud SWE-bench gap fixable? Partially. The 22-point gap (58.7% local vs 80.8% cloud) narrows to ~12-15 points with structured context injection and optimized prompts. It doesn’t fully close, but 45-50% of the gap is context management, not model capability.
What context window do I need for full repo work in Cursor? 256K handles most real-world projects under 180K tokens. For larger codebases, use the chunking strategy: file tree first, then high-priority files, then adjacent dependencies. This recovers most of the performance lost to context overflow.
Can GLM-4.7-Flash’s 1M context actually be used locally? In practice, throughput degrades significantly above 200K tokens on 24GB VRAM. The 1M context is a theoretical maximum. Real-world effective context on consumer hardware is closer to 200-300K depending on batch size.
What’s the best prompt format for Qwen3 in Cursor? State the output format first (git diff, TypeScript, etc.), then the task, then constraints. Always include a scope limiter (“only modify files in /src/auth”). CoT activation (“map dependencies before coding”) adds meaningful accuracy on multi-file tasks.
DeepSeek-V3.2 or Qwen3-Coder-Next for production code generation? For React/Next.js: Qwen3. For Rust/Go/systems: DeepSeek. For agentic pipeline builds: GLM-4.7-Flash. There isn’t a single winner across all languages and task types.
How much does running local LLMs with Cursor actually save? On an owned RTX 4090, roughly $0.12/kloc vs $1.20-1.80/kloc for cloud models. At 100K lines annually, that’s ~$108-168 saved per developer per year. At team scale with shared inference, the savings scale linearly with developer count.
All benchmark figures cited are from SWE-bench Verified leaderboard data and structured community audits current as of May 2026. Hardware performance figures based on Q4_K_M quantization on RTX 4090 (24GB GDDR6X). Costs calculated using $0.12/kWh electricity rate with 24-month GPU amortization.

