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:

text
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:

text
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:

text
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:

text
zsh

Temporary environment variables:

bash
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:

bash
unset OLLAMA_HOST
unset OPENROUTER_API_KEY
unset OPENAI_API_KEY
unset OPENAI_BASE_URL

Permanent shell aliases:

text
/Users/zarachtech/.zshrc

Claude Code settings:

text
/Users/zarachtech/.claude/settings.json

Codex config:

text
/Users/zarachtech/.codex/config.toml

Project folder example:

bash
cd ~/Documents/Codes/testglmmodel

Windows PowerShell

Use PowerShell, preferably Windows Terminal.

Temporary environment variables for the current PowerShell window:

powershell
$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:

powershell
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:

text
C:\Users\YOUR_WINDOWS_USERNAME\.claude\settings.json

Codex config:

text
C:\Users\YOUR_WINDOWS_USERNAME\.codex\config.toml

Project folder example:

powershell
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:

bat
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:

bat
set OLLAMA_HOST=
set OPENROUTER_API_KEY=
set OPENAI_API_KEY=
set OPENAI_BASE_URL=

SSH Tunnel On macOS

bash
ssh -L 11434:127.0.0.1:11434 root@153.75.90.251

In another terminal:

bash
export OLLAMA_HOST=http://127.0.0.1:11434
ollama list

SSH Tunnel On Windows PowerShell

Windows 10/11 usually includes OpenSSH.

powershell
ssh -L 11434:127.0.0.1:11434 root@153.75.90.251

Keep that PowerShell window open. In another PowerShell window:

powershell
$env:OLLAMA_HOST = "http://127.0.0.1:11434"
ollama list

If ssh is not found, install OpenSSH Client from:

text
Settings -> Apps -> Optional Features -> OpenSSH Client

1. Check Which Ollama You Are Using

Run:

bash
echo $OLLAMA_HOST

On Windows PowerShell:

powershell
echo $env:OLLAMA_HOST

If it prints nothing, your terminal is using your MacBook's local Ollama:

text
local default http://127.0.0.1:11434

If it prints your VPS URL, you are using the VPS:

text
http://153.75.90.251:11434

You can also test with:

bash
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:

bash
export OLLAMA_HOST=http://153.75.90.251:11434
ollama list

On Windows PowerShell:

powershell
$env:OLLAMA_HOST = "http://153.75.90.251:11434"
ollama list

Test the model:

bash
ollama run qwen2.5-coder:7b "Write a simple Python function that adds two numbers."

You can also test the larger model:

bash
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:

bash
cd /path/to/your/project

Point Ollama to the VPS:

bash
export OLLAMA_HOST=http://153.75.90.251:11434

On Windows PowerShell:

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:

bash
ollama run qwen2.5-coder:7b

Example prompt:

text
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:

bash
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:

bash
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:

bash
ollama launch codex --model glm-5.2:cloud

Option C: Claude Code

Use this if Claude Code is installed:

bash
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:

bash
cd /path/to/your/project
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch claude --model qwen3-coder:30b

For Ollama Cloud:

bash
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:

bash
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:

bash
export OLLAMA_HOST=http://153.75.90.251:11434
ollama launch codex-app --model qwen3-coder:30b

For Ollama Cloud:

bash
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:

text
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:

bash
export OLLAMA_HOST=http://153.75.90.251:11434
ollama list

Confirm the VPS model appears:

text
qwen2.5-coder:7b
qwen3-coder:30b

Then launch the app you want:

bash
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:

bash
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:

bash
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:

bash
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:

bash
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:

bash
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:

bash
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:

bash
export OLLAMA_HOST=http://127.0.0.1:11434
ollama list

Then launch the app:

bash
cd /path/to/your/project
ollama launch codex --model qwen2.5-coder:7b

To use qwen3-coder:30b through the tunnel:

bash
cd /path/to/your/project
ollama launch codex --model qwen3-coder:30b

Other app examples:

bash
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:

bash
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:

bash
ollama launch codex --model qwen2.5-coder

Your VPS currently has the explicit tag:

text
qwen2.5-coder:7b
qwen3-coder:30b

Use the exact model name from ollama list. For your VPS, the stable smaller model is:

bash
--model qwen2.5-coder:7b

The larger model is:

bash
--model qwen3-coder:30b

Recommended default for this VPS:

bash
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:

bash
unset OLLAMA_HOST

Confirm:

bash
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:

bash
nano ~/.zshrc

Add:

bash
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:

bash
source ~/.zshrc

Now switch with:

bash
ollama-vps
ollama-where
ollama list

And switch back:

bash
ollama-local
ollama-where
ollama list

7. Safer VPS Connection With SSH Tunnel

Direct VPS access uses:

bash
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:

bash
ssh -L 11434:127.0.0.1:11434 root@153.75.90.251

Keep that terminal open. In another terminal:

bash
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:

text
IP: NEW_VPS_IP
Username: root
OS: Ubuntu/Debian

SSH into it:

bash
ssh root@NEW_VPS_IP

Install Ollama:

bash
apt-get update -y
apt-get install -y curl
curl -fsSL https://ollama.com/install.sh | sh

Enable and start Ollama:

bash
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:

bash
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:

bash
curl http://127.0.0.1:11434/api/version

From your laptop:

bash
export OLLAMA_HOST=http://NEW_VPS_IP:11434
ollama list

9. Install Any Ollama Model On The New VPS

SSH into the VPS:

bash
ssh root@NEW_VPS_IP

Pull a model:

bash
ollama pull qwen2.5-coder:7b

Other examples:

bash
ollama pull llama3.1:8b
ollama pull qwen2.5-coder:14b
ollama pull deepseek-coder-v2:16b

List installed models:

bash
ollama list

Test:

bash
ollama run qwen2.5-coder:7b "Reply with exactly: ready"

Then use it from your laptop:

bash
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:

bash
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:

bash
ssh -L 11434:127.0.0.1:11434 root@NEW_VPS_IP

In another terminal:

bash
cd /path/to/your/project
export OLLAMA_HOST=http://127.0.0.1:11434
ollama launch claude --model qwen2.5-coder:7b

For CPU-only VPS:

text
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:

bash
ufw allow OpenSSH
ufw deny 11434
ufw enable

Then connect using SSH tunnel:

bash
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.