Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Run LLMs Locally with Ollama and vLLM

By Kokil Thapa | Last reviewed: September 2026

You do not need a cloud API key to ship useful AI features. When you run LLMs locally with Ollama and vLLM, prompts, documents, and user data stay on hardware you control. That matters for legal portals, internal tools, and any workflow where PII must not leave your network. Ollama gets a model running in minutes on a laptop or small server. vLLM targets production throughput on a GPU box. This guide covers install commands, API wiring, hardware sizing, and a clear decision path between the two.

Why should you run LLMs locally with Ollama and vLLM?

Cloud LLM APIs are convenient. They also send every prompt to a third party. For a law-firm portal or document workflow, that is often unacceptable. Local inference keeps client names, case notes, and uploaded PDFs inside your VPC or office LAN.

Cost is the second driver. A busy support bot can burn Rs 50,000–150,000 per month (~USD 375–1,125) on hosted tokens. A one-time GPU server at Rs 400,000–800,000 (~USD 3,000–6,000) pays back quickly at moderate volume. You trade CapEx for predictable OpEx.

Latency and offline use round out the case. A Kathmandu office on unreliable power still gets answers from a local box on UPS. No round trip to US-East means sub-second first tokens on a 7B model with a decent GPU.

I integrate hosted LLM APIs on production Laravel apps regularly. I do not train models. For privacy-sensitive work, local inference is the pattern I reach for first. See our AI integration and automation service for how that fits client projects.

Local LLM Stack OverviewOllamaDev / single userCPU or 1 GPUPort 11434vLLMProd / multi userNVIDIA GPU requiredPort 8000Your Application LayerLaravel · Python · CLI · Open WebUIOpenAI-compatible REST endpoints
Run LLMs locally with Ollama for development and vLLM when production concurrency and GPU throughput matter.

Common local use cases I see on client work:

  • Internal document Q&A over contracts and SOPs without uploading to OpenAI.
  • Dev-time code review and log summarisation in CI, covered in our Ollama DevOps workflows guide.
  • Structured JSON extraction from forms, paired with a JSON formatter for debugging output.
  • Chat widgets on intranets where outbound HTTPS to AI vendors is blocked.

How do you install and run Ollama for local LLM inference?

Ollama is the fastest path from zero to a working local model. One binary, a model registry, and an OpenAI-compatible API on port 11434. It runs on macOS, Linux, and Windows with optional NVIDIA or AMD GPU acceleration.

Install Ollama on Linux

On Ubuntu 22.04 or 24.04 — the stack I use on most servers — run the official installer:

curl -fsSL https://ollama.com/install.sh | sh
ollama --version
sudo systemctl enable ollama
sudo systemctl start ollama

Pull a model and start chatting from the shell:

ollama pull llama3.2:3b
ollama run llama3.2:3b

The 3B variant fits 8 GB RAM machines. It is fine for classification, short summaries, and routing prompts. For better reasoning, pull llama3.1:8b or mistral:7b. Quantised GGUF weights keep VRAM demand manageable.

Call Ollama from HTTP

Ollama exposes a REST API compatible with common client libraries. Test with curl:

curl http://localhost:11434/api/generate -d '{
  "model": "llama3.2:3b",
  "prompt": "Summarise GDPR in three bullet points.",
  "stream": false
}'

For OpenAI SDK compatibility, use the /v1/chat/completions endpoint:

curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3.2:3b",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Point any OpenAI client at http://localhost:11434/v1 with a dummy API key. That single change often unlocks existing app code. Read our guide on streaming LLM responses with SSE when you need token-by-token UI updates.

Ollama production tips

Ollama is not a load balancer. Bind it to localhost unless you trust every device on the network. Put Nginx or Caddy in front with TLS and basic auth for remote access. Set OLLAMA_HOST=0.0.0.0:11434 only on isolated VLANs.

Keep models on fast disk. A 7B Q4 model is roughly 4–5 GB. NVMe beats spinning rust for cold starts. For Open WebUI frontends, see our Ollama plus Open WebUI setup.

Ollama Setup FlowInstallPull Modelollama pullRun ServicesystemdCall APIIntegration Options/v1/chat/completionsOpenAI PHP / Python SDKLaravel HTTP clientLangChain · LlamaIndex
Ollama local LLM setup: install the binary, pull a quantised model, enable the service, then call the OpenAI-compatible API from your app.

When should you choose vLLM instead of Ollama?

vLLM is a high-throughput inference engine built for production. It uses PagedAttention to batch requests efficiently on NVIDIA GPUs. When ten users hit your app at once, vLLM keeps latency stable. Ollama queues serially and stalls.

Pick vLLM when all of these apply:

  1. You have an NVIDIA GPU with 16 GB VRAM or more.
  2. Concurrent users or API clients exceed a handful.
  3. You need continuous batching, tensor parallelism, or LoRA hot-swapping.
  4. You want an OpenAI-compatible server that scales like a microservice.

Stay on Ollama when you are prototyping, running on CPU-only hardware, or serving one developer workstation. Our Ollama vs LM Studio comparison covers desktop GUI alternatives. vLLM has no friendly desktop app — it is server software.

Install vLLM with pip

vLLM requires Python 3.10+ and CUDA. On a clean Ubuntu GPU box:

python3 -m venv /opt/vllm-venv
source /opt/vllm-venv/bin/activate
pip install vllm

python -m vllm.entrypoints.openai.api_server \
  --model meta-llama/Meta-Llama-3.1-8B-Instruct \
  --host 0.0.0.0 \
  --port 8000 \
  --dtype auto \
  --max-model-len 8192

Test the OpenAI-compatible endpoint:

curl http://localhost:8000/v1/models

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
    "messages": [{"role": "user", "content": "Explain vLLM in one sentence."}]
  }'

Run vLLM behind systemd or Docker on a dedicated inference node. Do not colocate it with MySQL on a 16 GB RAM VPS — you will OOM both services. For GPU Kubernetes patterns, see running AI workloads on Kubernetes with GPUs.

CriterionOllamavLLM
Setup timeMinutes — single binaryHours — Python, CUDA, model auth
HardwareCPU OK; GPU optionalNVIDIA GPU strongly recommended
ConcurrencyLow — serial queueHigh — continuous batching
API styleOpenAI-compatible + nativeOpenAI-compatible
Model formatGGUF via ModelfileHugging Face safetensors
Best forDev, demos, solo toolsProduction API serving
Ops complexityLowMedium — GPU drivers, VRAM tuning

Verdict: start every project on Ollama. Promote the same prompt templates to vLLM once load testing proves you need it. That two-stage path avoids over-engineering day one.

Ollama vs vLLM DecisionNeed local LLM?Dev / 1-5 users?Yes → Ollama10+ concurrent?Yes → vLLMOllamavLLM + GPUNo NVIDIA GPU? Stay on Ollama with smaller quantised models
Choose Ollama for development and low concurrency; switch to vLLM when GPU-backed production throughput is required.

How do you connect a Laravel app to local Ollama or vLLM APIs?

Most PHP teams already use Guzzle or Laravel's HTTP client. Point it at your local OpenAI-compatible base URL. No vendor SDK required.

Laravel service class example

<?php

namespace App\Services;

use Illuminate\Support\Facades\Http;

class LocalLlmClient
{
    public function __construct(
        private string $baseUrl = 'http://127.0.0.1:11434/v1',
        private string $model = 'llama3.2:3b',
    ) {}

    public function chat(string $userMessage): string
    {
        $response = Http::timeout(120)
            ->post("{$this->baseUrl}/chat/completions", [
                'model' => $this->model,
                'messages' => [
                    ['role' => 'system', 'content' => 'Reply concisely.'],
                    ['role' => 'user', 'content' => $userMessage],
                ],
                'temperature' => 0.2,
            ])
            ->throw()
            ->json();

        return $response['choices'][0]['message']['content'] ?? '';
    }
}

Store the base URL in .env so staging hits Ollama and production hits vLLM:

LOCAL_LLM_BASE_URL=http://inference.internal:8000/v1
LOCAL_LLM_MODEL=meta-llama/Meta-Llama-3.1-8B-Instruct

Queue long calls. A 70B model on weak hardware can exceed PHP-FPM timeouts. Dispatch a job, stream progress over websockets or polling, and return the result async. That mirrors how I handle document summarisation on legal-tech portals like Mijar Law Associates.

For JSON-only responses, add a response-format hint and validate server-side. Never trust raw model output for database writes. Our structured outputs guide covers schema enforcement. Test payloads with the regex tester when cleaning messy text before parsing.

Wire function calling carefully. Local 7B models hallucinate tool names more often than GPT-4 class models. Validate every tool invocation in PHP before execution. See function calling with LLMs for guardrail patterns.

Laravel + Local LLM FlowBrowserUser requestLaravelQueue jobOllama / vLLMOpenAI APIValidate + sanitise outputNever execute tools blindlyStore result · notify user · log tokens
Production Laravel apps should queue local LLM calls, validate responses server-side, and log usage for monitoring.

What hardware do you need to run LLMs locally in 2026?

VRAM is the bottleneck for GPU inference. RAM matters for CPU-only Ollama runs. Disk speed affects model load time, not steady-state tokens.

Practical tiers for Nepal and global small-team budgets:

  • Laptop / NUC (8–16 GB RAM, no GPU): Ollama with 3B Q4 models. Expect 5–15 tokens/sec. Fine for demos and personal scripts.
  • Workstation (RTX 4060 Ti 16 GB): 7B–8B models at 30–60 tokens/sec. Sweet spot for a five-person dev team.
  • Server (RTX 4090 / L40S 24–48 GB): 8B fast, 70B quantised, or vLLM with batching for production APIs.
  • Multi-GPU node: 405B-class models or high-QPS vLLM. Overkill until metrics prove you need it.

Budget roughly Rs 350,000–600,000 (~USD 2,600–4,500) for a sensible 4090 build in Kathmandu import scenarios. Cloud GPU rentals from AWS or RunPod can beat ownership below ~500 GPU-hours per month. Our self-hosting cost breakdown walks through the math.

CPU inference on a 16-core Xeon without GPU works for batch overnight jobs. It is a poor fit for interactive chat. If you must go CPU-only, stick to 3B models and aggressive quantisation.

Linux server admin skills matter as much as hardware. GPU drivers, CUDA versions, and systemd units break silently after kernel upgrades. If your team lacks that capacity, factor in Linux system administration support or managed hosting abroad with GPU instances.

How do you monitor and secure local LLM deployments?

Local does not mean safe by default. An exposed Ollama port on a public IP becomes a free GPU mine within hours. Treat inference servers like databases.

Security checklist

  1. Bind to private IPs. Use VPN or Tailscale for remote dev access.
  2. Terminate TLS at a reverse proxy. Issue Let's Encrypt certs the same way you would for Laravel.
  3. Rate-limit at Nginx. Local models can still be DoS'd into uselessness.
  4. Log prompts without storing raw PII longer than needed. Redact before log shipping.
  5. Keep models updated. Pull new Ollama tags or pin Hugging Face revisions in vLLM.

Monitoring belongs in your existing stack. Export request counts, latency p95, and tokens per minute. Alert when queue depth spikes — that usually means you have outgrown Ollama. Read LLMOps monitoring and guardrails for production patterns.

Run evals before swapping models. A newer 8B model can regress on Nepali-language prompts or your JSON schema. Our LLM evaluation guide shows a lightweight golden-set workflow. Pair evals with hallucination reduction techniques when answers feed user-facing legal content.

For privacy-first architecture rationale, see local LLMs for privacy-sensitive apps. Operational maturity maps to LLMOps: ship and operate LLM apps.

Official references worth bookmarking: the Ollama API documentation, the vLLM documentation, and OpenAI API reference for endpoint parity when porting clients.

Key Takeaways

  • Install Ollama first for fast local prototyping; both tools expose OpenAI-compatible HTTP APIs your existing SDKs can reuse.
  • Move to vLLM on an NVIDIA GPU when concurrent users, batching, or sustained API load exceed Ollama's serial queue.
  • Queue LLM calls in Laravel, validate every structured response server-side, and never execute model-suggested tools without PHP checks.
  • Budget hardware by VRAM: 8 GB for 3B models, 16 GB for 7B–8B, 24 GB+ for vLLM production or larger weights.
  • Lock inference servers behind private networking, TLS, and rate limits — an open port 11434 is an open invitation.
  • Run evals and monitor latency before promoting a new local model to production user flows.

People Also Ask

Can Ollama and vLLM use the same models?

Not directly. Ollama consumes GGUF bundles via its registry and Modelfile format. vLLM loads Hugging Face safetensors checkpoints. You can run the same model family — Llama 3.1 8B, for example — but you download separate artefacts for each runtime.

Does Ollama work without a GPU?

Yes. Ollama falls back to CPU inference with AVX-capable processors. Speed drops sharply on large models. Stick to 3B quantised weights on CPU-only machines and expect interactive latency, not chat-app snappiness.

Is vLLM free for commercial use?

vLLM is open source under the Apache 2.0 licence. You pay for hardware, electricity, and ops time — not per-token fees. Model licences are separate; Meta Llama weights require accepting their community licence before download.

Which is easier for a Laravel developer?

Ollama wins on simplicity. One install script, one port, immediate curl tests. vLLM needs Python virtualenvs, CUDA alignment, and VRAM tuning. Laravel integration is identical once both expose /v1/chat/completions — the difference is ops overhead, not PHP code.

Ship local AI without sending data to the cloud

You now have a concrete path to run LLMs locally with Ollama and vLLM: prototype on Ollama today, load-test, then promote to vLLM when concurrency demands it. Keep prompts on your network, wire OpenAI-compatible clients in Laravel, and treat inference nodes with the same security discipline as your database tier.

If you want help designing a private AI layer for a portal, booking system, or internal tool, review our API development services and custom software development offerings. For a scoped architecture review, contact us with your model size, user count, and privacy constraints — we will recommend the smallest stack that actually fits.

Frequently Asked Questions

It means serving language models on hardware you control using Ollama for fast setup or vLLM for GPU throughput, both exposing OpenAI-compatible HTTP APIs without cloud API keys.

Cloud LLM APIs send every prompt to a third party, which is often unacceptable for law-firm portals and document workflows where client names, case notes, and PDFs must stay inside your VPC or office LAN. Cost is the second driver: a busy support bot can burn Rs 50,000 to 150,000 per month on hosted tokens, while a one-time GPU server at Rs 400,000 to 800,000 pays back at moderate volume. Local inference also cuts latency, works offline on UPS-backed hardware, and avoids round trips to distant cloud regions.

On Ubuntu 22.04 or 24.04, run the official curl installer, enable and start the systemd service, then pull a quantised model. Use llama3.2:3b on 8 GB RAM machines for classification and short summaries; pull llama3.1:8b or mistral:7b for better reasoning. Ollama exposes a REST API on port 11434, including OpenAI-compatible /v1/chat/completions. Test with curl against /api/generate or the chat endpoint before wiring your application. Keep models on fast NVMe disk because a 7B Q4 model is roughly 4 to 5 GB and cold starts suffer on spinning rust.

Point Laravel's HTTP client or Guzzle at the local OpenAI-compatible base URL with a dummy API key. Store LOCAL_LLM_BASE_URL and LOCAL_LLM_MODEL in .env so staging hits Ollama on port 11434 and production hits vLLM on port 8000. Set a generous timeout and queue long calls to avoid PHP-FPM timeouts on slow hardware. Validate every structured JSON response server-side before database writes. Never execute model-suggested tool invocations without PHP validation first, because local 7B models hallucinate tool names more often than larger cloud models.

Pick vLLM when you have an NVIDIA GPU with 16 GB VRAM or more, concurrent users or API clients exceed a handful, and you need continuous batching, tensor parallelism, or LoRA hot-swapping at production scale. Ollama queues serially and stalls under concurrent load; vLLM uses PagedAttention to batch requests efficiently and keep latency stable. Stay on Ollama when prototyping, running CPU-only hardware, or serving a single developer workstation. Start every project on Ollama and promote the same prompt templates to vLLM once load testing proves you need throughput.

vLLM requires Python 3.10 or higher and CUDA on a dedicated GPU box. Create a Python virtualenv, pip install vllm, then launch the OpenAI api_server entrypoint with your Hugging Face model name, host, port, dtype, and max-model-len settings. Test with curl against /v1/models and /v1/chat/completions on port 8000. Run vLLM behind systemd or Docker on a dedicated inference node. Do not colocate it with MySQL on a 16 GB RAM VPS or both services will OOM. vLLM has no friendly desktop app; it is server software built for production API serving.

VRAM is the GPU bottleneck; RAM matters for CPU-only Ollama runs; disk speed affects model load time. An 8 to 16 GB laptop without GPU runs 3B Q4 models at 5 to 15 tokens per second. An RTX 4060 Ti 16 GB handles 7B to 8B models at 30 to 60 tokens per second for a small dev team. RTX 4090 or L40S with 24 to 48 GB VRAM suits vLLM production APIs, 70B quantised weights, or larger batching. Budget roughly Rs 350,000 to 600,000 for a sensible 4090 build in Kathmandu import scenarios.

A busy support bot can cost Rs 50,000 to 150,000 per month on hosted tokens. A one-time GPU server at Rs 400,000 to 800,000 pays back quickly at moderate volume.

Not directly. Ollama consumes GGUF bundles via its registry and Modelfile format. vLLM loads Hugging Face safetensors checkpoints. You can run the same model family, such as Llama 3.1 8B, but you download separate artefacts for each runtime.

Yes. Ollama falls back to CPU inference on AVX-capable processors, but speed drops sharply on large models. Stick to 3B quantised weights on CPU-only machines and expect interactive latency rather than chat-app snappiness. A 16-core Xeon without GPU can handle batch overnight jobs but is a poor fit for interactive chat. vLLM strongly recommends an NVIDIA GPU with 16 GB VRAM or more for production workloads. If your team lacks Linux GPU driver and CUDA maintenance skills, factor in system administration support before committing to GPU inference.

vLLM is open source under the Apache 2.0 licence. You pay for hardware, electricity, and operations time rather than per-token API fees. Model licences are separate: Meta Llama weights require accepting their community licence before download from Hugging Face. Cloud GPU rentals from AWS or RunPod can beat hardware ownership below roughly 500 GPU-hours per month. Factor in medium ops complexity for Python virtualenvs, CUDA alignment, and VRAM tuning when comparing vLLM against the simpler Ollama install path for commercial deployments.

Local does not mean safe by default. An exposed Ollama port on a public IP becomes a free GPU mine within hours. Bind inference servers to private IPs and use VPN or Tailscale for remote dev access. Terminate TLS at Nginx or Caddy with Let's Encrypt certificates. Rate-limit requests because local models can still be DoS'd into uselessness. Bind Ollama to localhost unless you trust every device on the network; set OLLAMA_HOST=0.0.0.0:11434 only on isolated VLANs. Log prompts without storing raw PII longer than needed and redact before log shipping.

Ollama wins on simplicity: one install script, one port, immediate curl tests, and minutes from zero to a working model. vLLM needs Python virtualenvs, CUDA driver alignment, and VRAM tuning with medium ops complexity. Laravel integration is identical once both expose /v1/chat/completions; the difference is infrastructure overhead, not PHP code. Store the base URL in .env so staging hits Ollama and production hits vLLM without code changes. Queue long calls and validate responses server-side regardless of which runtime sits behind the API.

Export request counts, latency p95, and tokens per minute into your existing monitoring stack. Alert when queue depth spikes, which usually means you have outgrown Ollama's serial queue and should evaluate vLLM. Run evals before swapping models because a newer 8B model can regress on Nepali-language prompts or JSON schema outputs. Keep models updated by pulling new Ollama tags or pinning Hugging Face revisions in vLLM. Pair evals with hallucination reduction techniques when answers feed user-facing legal content. Log usage for monitoring but redact PII before log shipping.

Ollama queues requests serially, so when ten users hit your app at once latency spikes while vLLM keeps it stable through continuous batching. Colocating vLLM with MySQL on a 16 GB RAM VPS causes OOM for both services. A 70B model on weak hardware can exceed PHP-FPM timeouts unless you dispatch jobs and return results asynchronously. GPU drivers and CUDA versions break silently after kernel upgrades on Linux inference nodes. Queue depth spikes in monitoring usually signal you have outgrown Ollama and should load-test promotion to vLLM on a dedicated GPU box.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: