n4nAI

Ollama on a single GPU vs API latency benchmarks

Compare Ollama on a single GPU vs API latency across capabilities, cost, throughput, and ergonomics with a head-to-head table and verdict.

n4n Team4 min read920 words

Audio narration

Coming soon — every post will get a voice note here.

Running models locally changes your latency profile in ways that surprise teams who only benchmark the API. The Ollama single GPU vs API latency gap is not just about raw token speed—it’s about network hops, queueing, and hardware saturation. This head-to-head breaks down where self-hosted wins and where the API still makes sense for production systems.

Capabilities

Ollama runs GGUF-quantized models from its library on a single GPU, with CPU fallback if you exceed VRAM. You control the weights, the system prompt, and the sampling parameters, but you are constrained by what fits in memory. A 24GB card handles an 8B model at Q8 or a 13B at Q4; larger architectures simply will not load.

API endpoints—whether a single vendor or a gateway—serve models you cannot download. They often expose larger context windows, proprietary training, and features like seeded generation or structured output. Ollama supports tool calling on models that implement it (e.g., llama3.1), and you can bake behavior into a Modelfile. APIs generally give you JSON mode and provider-specific extensions across many families without recompiling anything.

import ollama
# local 8B model with a system prompt baked in Modelfile
resp = ollama.chat(
    model="llama3:8b",
    messages=[{"role": "user", "content": "Summarize this log"}]
)
from openai import OpenAI
client = OpenAI(base_url="https://api.example.com/v1")
resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Summarize this log"}],
    response_format={"type": "json_object"}
)

Price and cost model

Ollama has no per-token fee. You pay for the GPU instance (capital expense or cloud rental) and power. A single A10G or RTX 4090 in the cloud runs about $0.30–$0.60 per hour, which is $220–$430 per month if you keep it hot full time. That buys you unlimited inferences for one model.

APIs charge per input and output token, with cached-token discounts at some vendors. At low volume, API cost is trivial; at millions of tokens per day, self-hosting can be cheaper if your GPU utilization stays high. The break-even point depends on model size and traffic shape.

# approximate cloud GPU cost math
echo "A10G @ $0.40/hr * 730 hr/mo = $292/mo"

Latency and throughput

This is the core of Ollama single GPU vs API latency. Local inference removes the network round-trip entirely. On a single modern GPU, an 8B quantized model produces 40–80 tokens/s with time-to-first-token (TTFT) under 100ms for short prompts. A hosted API adds 20–150ms of regional network latency plus provider queue time that can spike during peak load.

If you route through an OpenAI-compatible gateway such as n4n.ai, you get access to 240+ models with automatic fallback when a provider is rate-limited or degraded, but you still pay the network cost on every call. The gateway does not magically shrink physical distance.

Test setup

We measured with a fixed prompt of 120 input tokens asking for a 200-token completion. Ollama ran llama3:8b on an A10G. The API client hit a regional endpoint with the same model class.

import time, ollama, openai

def bench_ollama():
    t0 = time.time()
    ollama.chat(model="llama3:8b",
                messages=[{"role":"user","content":"Write 200 words about latency"}])
    return time.time() - t0

def bench_api():
    client = openai.OpenAI(base_url="https://api.example.com/v1")
    t0 = time.time()
    client.chat.completions.create(
        model="small-api-model",
        messages=[{"role":"user","content":"Write 200 words about latency"}])
    return time.time() - t0

# run 30 iterations, drop first 3 for warmup, record p50/p99

What the numbers mean

Local TTFT stays flat under load until VRAM is exhausted. API TTFT degrades with shared infrastructure. For streaming, Ollama sends tokens as they decode; APIs stream over HTTP chunks with similar cadence but added jitter from TLS and proxy layers.

Ergonomics

Ollama installs as one binary with a REST API and CLI. You pull, run, and integrate. No auth, no rate limits, no billing dashboard. The downside: you own driver updates, model pruning, and crash recovery.

APIs require a key, retry logic for 429s, and occasional SDK migrations. They scale without ops toil. For local iteration, Ollama is faster; for a team of ten services, a shared API endpoint avoids ten GPU boxes.

ollama pull llama3:8b
ollama run llamama3:8b "explain p99 latency"

Ecosystem

Ollama’s ecosystem includes Modelfile, Open WebUI, and first-class LangChain adapters. It is growing but lacks enterprise audit logs and managed fine-tune pipelines.

APIs plug into every framework (Vercel AI, LlamaIndex, Anthropic SDK) and support batch, embeddings, and reranking under one credential. Gateways add model abstraction so you can swap backends without touching app code, and they forward provider cache-control hints if you set them.

Scaling and observability

Ollama scales vertically only. To serve more concurrent users you duplicate the GPU node behind a load balancer, but each node carries the full model weight. APIs scale horizontally behind the vendor’s fabric; you just raise your quota.

For observability, Ollama emits basic logs; you wire Prometheus yourself. API gateways often provide per-token usage metering out of the box, which simplifies cost attribution across teams.

Hard limits

Single-GPU Ollama is bounded by VRAM. Context length grows memory quadratically; a 32k context on 13B may overflow 24GB. APIs impose rate limits and max token caps but handle scaling invisibly.

Dimension Ollama (single GPU) API endpoint
Capabilities Local weights, custom Modelfiles, VRAM-bound size Huge catalog, JSON mode, seeds, frontier models
Price/cost Fixed GPU cost, no token fee Per-token, scales with usage
Latency (TTFT) <100ms local, zero network +20–150ms network + provider queue
Throughput 40–80 tok/s (8B) Similar small models, higher for 70B+
Ergonomics No auth, self-managed ops Key, quota, zero hardware ops
Ecosystem CLI, Open WebUI, LangChain All frameworks, gateway fallback
Limits VRAM and context memory Rate limits, vendor max tokens

Which to choose

Solo prototype or laptop dev: Use Ollama. The Ollama single GPU vs API latency difference is invisible when you are the only caller, and you skip account setup.

Production with spiky traffic: Use an API or gateway. A single self-hosted GPU is a single point of failure; APIs absorb bursts and fall back automatically.

Privacy-sensitive logs: Ollama keeps data on your disk. APIs may retain prompts unless you have a zero-retention contract.

Steady high-volume small-model serving: Ollama on a dedicated GPU wins on cost after break-even, provided you monitor thermals and OOM.

Need 70B+ or cutting-edge multimodal: API only. One consumer GPU will not fit the weights.

The Ollama single GPU vs API latency decision is ultimately control versus convenience. Benchmark your own p99 before you commit, and keep the fallback path open.

Tagsollamaself-hosted-llmgpu-benchmarkapi-latency

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All self-hosted vs api performance posts →