mikeaorlando.com Michael Orlando
  • Home
  • Start Here
  • About
  • Work & Ventures
  • Ideas & Writing
  • Collaborate
  • Search

◉Local Model Serving for Provider Independence

Local Model Serving for Provider Independence

How I run open-weight models on homelab GPUs behind the same kind of API the hosted providers use, so apps can switch between local and cloud models by configuration, and so I understand the hosting problems those providers solve.

Routing Notes

  • Parent Projects for Fun
  • Signal Working Systems

Overview

This project has two goals. The first is provider independence: the apps and agents I use should not depend on any one model provider. They should be able to use a local model, a hosted open-weight model, or a frontier model from a commercial provider, and the choice should be a configuration change, not a code change. The second is understanding how public model providers host models. Running models on my own GPUs in Praxis, my homelab, I have to solve a small version of the same problems they solve at scale. That makes the pricing, limits and behaviour of the large providers (AWS Bedrock, Microsoft Azure, Google Cloud Vertex AI and Gemini, Anthropic and OpenAI) much easier to explain to a client. The other reasons I run models locally are in Why I run AI and infrastructure locally.

Context

Most teams start with one provider’s SDK called directly from their code. That works until they want to compare a second model, control cost, keep some data on their own hardware, or survive an outage or a price change. At that point the provider is built into every call site.

The way out is a gateway that speaks one common API, the OpenAI-compatible chat API that most providers and open-source servers now accept. Apps call the gateway; the gateway decides which provider or server answers.

I wanted to run that pattern myself, with real clients: Open WebUI and SillyTavern for chat, the Hermes agent, and Cline in my editor. Local models were the hard case, because with local models I also run the servers. That is the part a hosted provider normally hides.

The System

One gateway for local and hosted models. LiteLLM is the single OpenAI-compatible endpoint for every client, with a key per client. Behind it are the local model servers. LiteLLM can route to hosted providers in the same way, so adding a provider or moving a workload is a gateway configuration change. In Open WebUI, local models and approved cloud models from OpenRouter sit side by side under “Local” and “Cloud” tags. Per-model access control decides which accounts see which models.

Local servers that behave like a small provider. Each GPU runs its own Ollama instance and holds one model at a time. Every model variant is declared once in the repository, with its context size, and it may load only on a card that can hold it entirely in GPU memory. A load that does not fit fails with an error. It does not spill onto the CPU and run slowly.

Routing to a GPU that already has the model loaded. Loading a model takes far longer than answering a short request with it. The gateway therefore prefers a GPU that already has the requested model loaded. If none does, it prefers a free GPU over evicting another model. This keeps two models in use at the same time from repeatedly unloading each other on one card.

One switch for reasoning. Some models think before they answer. Every model accepts the same request field to turn thinking on or off; a model that cannot think accepts the field and ignores it. Thinking output arrives in a separate reasoning field, never in the reply text.

Tracing. Requests are traced to Langfuse, so I can compare models on the same prompts through the same path. The tracing design is in LLM observability with Langfuse.

What This Shows About Hosted Providers

Running this made several things about public model providers concrete.

Why models are resident and placed carefully. A large model has to sit in GPU memory to answer quickly, and loading it is slow. Providers keep models loaded across many GPUs and route each request to a server that already holds the model. That is why a provider’s model list is curated and why rarely used models are retired or moved to slower tiers.

Why context windows are fixed per model. The context window costs GPU memory on the server, so it has to be planned when the model is placed. A provider publishes a fixed limit for each model for that reason. I also found that a compatibility layer can accept a context setting and silently ignore it: Ollama’s OpenAI-compatible endpoint ignores a per-request context size. A compatible API does not guarantee identical behaviour.

Why reasoning tokens are billed and limited. Thinking uses the same output budget as the answer. With a short reply limit, a thinking model can spend the whole budget reasoning and return an empty answer. Providers bill reasoning as output and expose controls for it for the same reason.

Why GPU capacity is the constraint. My GPUs are shared with image and video generation. A model left loaded forces the image workload to offload, and the reverse, so idle models unload after a short keep-alive period. Providers face the same trade-off between keeping capacity warm and paying for idle GPUs, and it shows up in their rate limits and in the gap between their batch and real-time pricing.

Components and Why I Chose Them

Component What it does here Why I chose it
Ollama (tool page) Runs quantized open-weight models on each GPU and exposes an API Simple model management, a large catalog of quantized models, and an OpenAI-compatible endpoint
LiteLLM (tool page) The one gateway every client calls One API in front of local servers and hosted providers, with per-client keys, model aliases, fallbacks and tracing callbacks; adding a provider is configuration
Open WebUI (tool page) Chat interface for people Self-hosted, works with any OpenAI-compatible endpoint, and supports per-model access control
Langfuse (tool page) Traces every request Open source, self-hostable, and has a model for sessions, traces and generations that fits both chat and agents

Outcomes

Apps and agents now depend on one API, not on a provider. Moving a workload between a local model and a hosted one is a gateway change. Adding a local model is one process: declare it, check that it fits each GPU class, and let the gateway and app configuration follow from that declaration. When I compare models for a recommendation, I compare them through the same path, with the same settings, and with traces I can go back to.

Example Configuration

This is a simplified excerpt of a LiteLLM model_list. The model names and hosts are placeholders. Apps call the alias in model_name; the gateway maps each alias to a local Ollama server or a hosted provider.

model_list:
  - model_name: local-chat            # alias the apps call
    litellm_params:
      model: ollama_chat/example-model
      api_base: http://ollama-gpu-1:11434

  - model_name: cloud-chat            # same API, hosted provider
    litellm_params:
      model: openrouter/example-provider/example-model
      api_key: os.environ/OPENROUTER_API_KEY

Moving an app from local-chat to cloud-chat, or pointing local-chat at a different model, is a change to this file or to the app’s model setting. The app’s code does not change.

Patterns Worth Reusing

Put a gateway between your apps and your model providers before you need a second provider. Switching is then a configuration change.

Check what actually reaches the model. A compatible API can accept a setting and ignore it without an error. Test the setting end to end and read what the server used, not what the client sent.

Declare each model’s properties once and generate everything else from that declaration. Model lists kept by hand in each app drift apart quickly.

Treat reasoning as part of the output budget. If a model thinks before it answers, the reply limit has to account for it.

Explore

  • ✎Posts
  • ○Categories
  • ◉Projects for Fun
  • ▶Projects for Work
  • ◎Systems Across Domains
  • ▪Technical Tools
  • ◆Transferable Skills
  • ✕Value Multipliers
  • ◇Ventures

Michael Orlando

Systems, ventures, writing, and public proof arranged so the right people can find the right next step.

© 2026 Michael Orlando

Privacy & Data Handling

about.me Substack Credly Polywork