↓ Skip to main content
Point Your OpenAI Client at a Local Ollama Model in One Sitting
Techfastly by Vin Patel 2 min read

Point Your OpenAI Client at a Local Ollama Model in One Sitting

Point your existing OpenAI client at a local Ollama model by changing one base URL, then test whether local models really are good enough.

In a single sitting you will point your existing OpenAI client at a model running on your own machine, with no rewrite and no per-token bill.

Why now: a Hacker News post titled “Local models are good enough now” makes the argument in its title. The fastest way to test it is on your own prompts, not someone else’s benchmark.

The trick is boring, which is why it works. Ollama serves an OpenAI-compatible endpoint. Any SDK that lets you set a base URL cannot tell a hosted model from the one on your laptop. Your prompts, message format and response parsing stay exactly as they are.

  1. Install Ollama and start it with ollama serve. Read the address it logs on startup.
  2. Pull a small model with ollama pull llama3.2.
  3. Export that address, plus /v1, as an environment variable.
  4. Point your client’s base URL at it. The SDK demands an API key, and any string works locally.
  5. Replay a real prompt from your production logs and compare the answer with your hosted model’s.

Paste this, swapping in the address from your Ollama log:

ollama pull llama3.2
export LOCAL_LLM_URL="<address from the ollama log>/v1"
curl "$LOCAL_LLM_URL/models"
import os
from openai import OpenAI

client = OpenAI(base_url=os.environ["LOCAL_LLM_URL"], api_key="ollama")
r = client.chat.completions.create(
 model="llama3.2",
 messages=[{"role": "user", "content": "Summarize:..."}],
)
print(r.choices[0].message.content)

One thing will bite you: the model string. Your client sends whatever name you give it, and Ollama only answers to names it has pulled. If you get a saying the model was not found, run ollama list and copy the name exactly, tag included. The hosted model’s name does not carry over.

My read: summarization, extraction, classification and routing will hold up locally, and you should move them first. Multi-step tool calling is where small models drift. Keep a hosted model for that tail, and expect the routing between the two, not the model, to be your real engineering work. Test with the ugliest, most representative prompts you have, not a demo prompt. If the simple tasks fail, I’m wrong, and you learned it for free.

The split matters beyond cost. Prompts containing customer data stop leaving your machine during development, and a loopback call does not depend on anyone’s rate limits.

If the small model stumbles on agentic work, the Forge Show HN write-up covers guardrails that lift a small model on those tasks without swapping it out.

Subscribe at /subscribe/ and the next one lands in your inbox.