LLM Coding Guide
This guide covers:
- Using the setup on macOS and Windows.
- Using OpenRouter from your laptop with Claude Code, Codex CLI, Codex App, and other coding applications.
- Switching between your MacBook Ollama and your VPS Ollama.
- Using a VPS-hosted model to code inside a project folder on your laptop.
- Switching back to local Ollama when done.
- Setting up Ollama on any VPS and connecting to it when you need a self-hosted model.
Primary workflow:
Laptop -> OpenRouter -> cloud model provider
Use this when you want models like GLM 5.2, Claude, Gemini, GPT, or other OpenRouter-hosted models inside Claude Code, Codex CLI, Codex App, and OpenAI-compatible coding applications.
Secondary workflow:
Laptop -> Ollama API -> any VPS running Ollama -> VPS model
Use this when you specifically want to run your own Ollama models on a VPS.
Example VPS currently used in this guide:
Host: 153.75.90.251
Ollama API: http://153.75.90.251:11434
Current VPS model: qwen2.5-coder:7b
Additional VPS model: qwen3-coder:30b
Do not keep passwords in shell files or project files. Prefer SSH keys for long-term use.
0. macOS And Windows Notes
This guide works for both macOS and Windows, but commands and config paths differ.
macOS
Common shell:
zsh
Temporary environment variables:
export OLLAMA_HOST=http://153.75.90.251:11434
export OPENROUTER_API_KEY="YOUR_OPENROUTER_API_KEY"
export OPENAI_API_KEY="$OPENROUTER_API_KEY"
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
Remove temporary variables:
unset OLLAMA_HOST
unset OPENROUTER_API_KEY
unset OPENAI_API_KEY
unset OPENAI_BASE_URL
Permanent shell aliases:
/Users/zarachtech/.zshrc
Claude Code settings:
/Users/zarachtech/.claude/settings.json
Codex config:
/Users/zarachtech/.codex/config.toml
Project folder example:
cd ~/Documents/Codes/testglmmodel
Windows PowerShell
Use PowerShell, preferably Windows Terminal.
Temporary environment variables for the current PowerShell window:
$env:OLLAMA_HOST = "http://153.75.90.251:11434"
$env:OPENROUTER_API_KEY = "YOUR_OPENROUTER_API_KEY"
$env:OPENAI_API_KEY = $env:OPENROUTER_API_KEY
$env:OPENAI_BASE_URL = "https://openrouter.ai/api/v1"
Remove temporary variables:
Remove-Item Env:\OLLAMA_HOST -ErrorAction SilentlyContinue
Remove-Item Env:\OPENROUTER_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:\OPENAI_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:\OPENAI_BASE_URL -ErrorAction SilentlyContinue
Claude Code settings:
C:\Users\YOUR_WINDOWS_USERNAME\.claude\settings.json
Codex config:
C:\Users\YOUR_WINDOWS_USERNAME\.codex\config.toml
Project folder example:
cd C:\Users\YOUR_WINDOWS_USERNAME\Documents\Codes\testglmmodel
If a command in this guide uses export, use $env:NAME = "value" on Windows.
If a command uses unset, use Remove-Item Env:\NAME.
If a path starts with /Users/zarachtech, replace it with your Windows user path.
Windows Command Prompt
PowerShell is recommended, but Command Prompt also works.
Set variables:
set OLLAMA_HOST=http://153.75.90.251:11434
set OPENROUTER_API_KEY=YOUR_OPENROUTER_API_KEY
set OPENAI_API_KEY=%OPENROUTER_API_KEY%
set OPENAI_BASE_URL=https://openrouter.ai/api/v1
Remove variables:
set OLLAMA_HOST=
set OPENROUTER_API_KEY=
set OPENAI_API_KEY=
set OPENAI_BASE_URL=
SSH Tunnel On macOS
ssh -L 11434:127.0.0.1:11434 root@153.75.90.251
In another terminal:
export OLLAMA_HOST=http://127.0.0.1:11434
ollama list
SSH Tunnel On Windows PowerShell
Windows 10/11 usually includes OpenSSH.
ssh -L 11434:127.0.0.1:11434 root@153.75.90.251
Keep that PowerShell window open. In another PowerShell window:
$env:OLLAMA_HOST = "http://127.0.0.1:11434"
ollama list
If ssh is not found, install OpenSSH Client from:
Settings -> Apps -> Optional Features -> OpenSSH Client
1. Check Which Ollama You Are Using
Run:
echo $OLLAMA_HOST
On Windows PowerShell:
echo $env:OLLAMA_HOST
If it prints nothing, your terminal is using your MacBook's local Ollama:
local default http://127.0.0.1:11434
If it prints your VPS URL, you are using the VPS:
http://153.75.90.251:11434
You can also test with:
ollama list
If you see qwen2.5-coder:7b, you are likely connected to the VPS unless you also downloaded that model locally.
2. Switch To Your VPS Ollama
Use this when you want your laptop terminal or coding tool to use the model running on the VPS:
export OLLAMA_HOST=http://153.75.90.251:11434
ollama list
On Windows PowerShell:
$env:OLLAMA_HOST = "http://153.75.90.251:11434"
ollama list
Test the model:
ollama run qwen2.5-coder:7b "Write a simple Python function that adds two numbers."
You can also test the larger model:
ollama run qwen3-coder:30b "Reply with exactly: ready"
Note: qwen3-coder:30b is installed on the example VPS, but it is much heavier than qwen2.5-coder:7b. That VPS has 12 GB RAM, while qwen3-coder:30b is about 18 GB on disk. It may run slowly, swap heavily, or fail under load. Use qwen2.5-coder:7b for stable day-to-day coding on a small VPS.
3. Code In A Specific Project Folder On Your Laptop
Go to the local project folder:
cd /path/to/your/project
Point Ollama to the VPS:
export OLLAMA_HOST=http://153.75.90.251:11434
On Windows PowerShell:
$env:OLLAMA_HOST = "http://153.75.90.251:11434"
Then use one of these workflows.
Option A: Simple Ollama Prompt
This is useful for asking questions or generating files manually:
ollama run qwen2.5-coder:7b
Example prompt:
I am inside a Laravel project. Help me build a booking module. First inspect what files I should create, then give me the commands and code.
Plain ollama run will not automatically edit your files. It only chats with the model.
Option B: Codex CLI
Use this if your Codex CLI is installed and you want a coding agent workflow in the current folder:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch codex --model qwen2.5-coder:7b
To use the larger qwen3-coder:30b model:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch codex --model qwen3-coder:30b
For Ollama Cloud models, after subscribing/signing in:
ollama launch codex --model glm-5.2:cloud
Option C: Claude Code
Use this if Claude Code is installed:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch claude --model qwen2.5-coder:7b
To use the larger qwen3-coder:30b model:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch claude --model qwen3-coder:30b
For Ollama Cloud:
ollama launch claude --model glm-5.2:cloud
Option D: Codex App
Use this if you want the Codex App to use the selected Ollama model:
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch codex-app --model qwen2.5-coder:7b
To use the larger qwen3-coder:30b model:
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch codex-app --model qwen3-coder:30b
For Ollama Cloud:
ollama launch codex-app --model glm-5.2:cloud
4. Run Ollama Applications On Your Laptop With The VPS Model
The model can stay installed on the VPS while the coding application runs on your MacBook.
The rule is:
Your laptop app -> your laptop Ollama CLI -> VPS Ollama API -> VPS model
The app itself must be installed on your MacBook. For example, Claude Code, Codex CLI, Codex App, OpenCode, OpenClaw, or Hermes must exist locally before ollama launch can start/configure it.
Direct VPS Mode
Use this when your VPS Ollama API is reachable directly:
export OLLAMA_HOST=http://153.75.90.251:11434
ollama list
Confirm the VPS model appears:
qwen2.5-coder:7b
qwen3-coder:30b
Then launch the app you want:
ollama launch claude --model qwen2.5-coder:7b
ollama launch codex --model qwen2.5-coder:7b
ollama launch codex-app --model qwen2.5-coder:7b
ollama launch opencode --model qwen2.5-coder:7b
ollama launch openclaw --model qwen2.5-coder:7b
ollama launch hermes --model qwen2.5-coder:7b
To use qwen3-coder:30b instead:
ollama launch claude --model qwen3-coder:30b
ollama launch codex --model qwen3-coder:30b
ollama launch codex-app --model qwen3-coder:30b
ollama launch opencode --model qwen3-coder:30b
ollama launch openclaw --model qwen3-coder:30b
ollama launch hermes --model qwen3-coder:30b
If you want to work inside a project folder, go to the folder first:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch codex --model qwen2.5-coder:7b
Use qwen3-coder:30b for the same project folder:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch codex --model qwen3-coder:30b
Or with Claude Code:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch claude --model qwen2.5-coder:7b
Or with Claude Code and qwen3-coder:30b:
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch claude --model qwen3-coder:30b
Safer Tunnel Mode
This is better if you do not want the Ollama API open publicly.
Open terminal 1 and start the tunnel:
ssh -L 11434:127.0.0.1:11434 root@153.75.90.251
Keep terminal 1 open.
Open terminal 2 and point Ollama to the local tunnel:
export OLLAMA_HOST=http://127.0.0.1:11434
ollama list
Then launch the app:
cd /path/to/your/project
ollama launch codex --model qwen2.5-coder:7b
To use qwen3-coder:30b through the tunnel:
cd /path/to/your/project
ollama launch codex --model qwen3-coder:30b
Other app examples:
ollama launch claude --model qwen2.5-coder:7b
ollama launch codex-app --model qwen2.5-coder:7b
ollama launch opencode --model qwen2.5-coder:7b
Other app examples with qwen3-coder:30b:
ollama launch claude --model qwen3-coder:30b
ollama launch codex-app --model qwen3-coder:30b
ollama launch opencode --model qwen3-coder:30b
Model Name Notes
The Ollama website may show:
ollama launch codex --model qwen2.5-coder
Your VPS currently has the explicit tag:
qwen2.5-coder:7b
qwen3-coder:30b
Use the exact model name from ollama list. For your VPS, the stable smaller model is:
--model qwen2.5-coder:7b
The larger model is:
--model qwen3-coder:30b
Recommended default for this VPS:
qwen2.5-coder:7b
Use qwen3-coder:30b only when you want to test heavier coding output and can tolerate slow responses.
5. Switch Back To Your MacBook Local Ollama
When you are done using the VPS:
unset OLLAMA_HOST
Confirm:
echo $OLLAMA_HOST
ollama list
If echo $OLLAMA_HOST prints nothing, you are back to local Ollama.
6. Add Easy Switch Commands
Add aliases to your shell config:
nano ~/.zshrc
Add:
alias ollama-local='unset OLLAMA_HOST && echo "Ollama: local MacBook"'
alias ollama-vps='export OLLAMA_HOST=http://153.75.90.251:11434 && echo "Ollama: VPS 153.75.90.251"'
alias ollama-where='echo "OLLAMA_HOST=${OLLAMA_HOST:-local default http://127.0.0.1:11434}"'
Reload:
source ~/.zshrc
Now switch with:
ollama-vps
ollama-where
ollama list
And switch back:
ollama-local
ollama-where
ollama list
7. Safer VPS Connection With SSH Tunnel
Direct VPS access uses:
export OLLAMA_HOST=http://153.75.90.251:11434
This is simple, but it means the Ollama API may be reachable from the internet.
Safer method:
ssh -L 11434:127.0.0.1:11434 root@153.75.90.251
Keep that terminal open. In another terminal:
export OLLAMA_HOST=http://127.0.0.1:11434
ollama list
ollama run qwen2.5-coder:7b "Say ready"
With a tunnel, your laptop talks to the VPS through SSH, but tools still see Ollama at 127.0.0.1:11434.
8. Setting Up Ollama On A New VPS
Assume the new VPS has:
IP: NEW_VPS_IP
Username: root
OS: Ubuntu/Debian
SSH into it:
ssh root@NEW_VPS_IP
Install Ollama:
apt-get update -y
apt-get install -y curl
curl -fsSL https://ollama.com/install.sh | sh
Enable and start Ollama:
systemctl enable --now ollama
systemctl status ollama --no-pager
By default, Ollama listens only on localhost inside the VPS. To access it from your laptop directly, set it to listen on all interfaces:
mkdir -p /etc/systemd/system/ollama.service.d
printf '%s\n' '[Service]' 'Environment="OLLAMA_HOST=0.0.0.0:11434"' > /etc/systemd/system/ollama.service.d/override.conf
systemctl daemon-reload
systemctl restart ollama
Check:
curl http://127.0.0.1:11434/api/version
From your laptop:
export OLLAMA_HOST=http://NEW_VPS_IP:11434
ollama list
9. Install Any Ollama Model On The New VPS
SSH into the VPS:
ssh root@NEW_VPS_IP
Pull a model:
ollama pull qwen2.5-coder:7b
Other examples:
ollama pull llama3.1:8b
ollama pull qwen2.5-coder:14b
ollama pull deepseek-coder-v2:16b
List installed models:
ollama list
Test:
ollama run qwen2.5-coder:7b "Reply with exactly: ready"
Then use it from your laptop:
export OLLAMA_HOST=http://NEW_VPS_IP:11434
ollama run qwen2.5-coder:7b "Write a Node.js hello world server."
You can also use the newly installed VPS model with applications from your laptop:
cd /path/to/your/project
export OLLAMA_HOST=http://NEW_VPS_IP:11434
ollama launch codex --model qwen2.5-coder:7b
Or through an SSH tunnel:
ssh -L 11434:127.0.0.1:11434 root@NEW_VPS_IP
In another terminal:
cd /path/to/your/project
export OLLAMA_HOST=http://127.0.0.1:11434
ollama launch claude --model qwen2.5-coder:7b
10. Recommended VPS Sizes
For CPU-only VPS:
2 vCPU / 8 GB RAM: very small models only
4 vCPU / 12-16 GB RAM: good for 7B coding models
8 vCPU / 32 GB RAM: better for 14B models and smoother coding
16 vCPU / 64 GB RAM: heavier local models, still CPU-slow
Your current 4 vCPU / 12 GB VPS is best suited for qwen2.5-coder:7b.
Large cloud-only models like glm-5.2:cloud are not downloaded to your VPS. They require Ollama Cloud access/subscription and run on Ollama's hosted GPUs.
11. Security Checklist
If your VPS exposes port 11434 publicly, anyone who reaches it may use your Ollama server.
Recommended:
ufw allow OpenSSH
ufw deny 11434
ufw enable
Then connect using SSH tunnel:
ssh -L 11434:127.0.0.1:11434 root@VPS_IP
export OLLAMA_HOST=http://127.0.0.1:11434
Also change root passwords after sharing them anywhere, and prefer SSH keys.