Skip to content

How-ToGPU

How to Set Up a LiteLLM Proxy for Your Local LLMs

How to put Ollama, LM Studio and llama.cpp servers behind one LiteLLM proxy, so every app uses a single OpenAI-compatible address, with load balancing across two GPU PCs, fallbacks and a master key.

By , Systems & Technical Editor

5 min read

How to Set Up a LiteLLM Proxy for Your Local LLMs

The steps and settings come from LiteLLM's documentation and GitHub README, plus the Ollama and LM Studio API docs, all read on 2 December 2026.

Once you run more than one local AI server, every app needs to know which machine, port and model name to use. A desktop with an RTX card might run Ollama, a laptop might run LM Studio, and a second GPU box might run llama.cpp's llama-server. For servers that LiteLLM has no named prefix for, such as llama-server, its docs say to put openai/ in front of the model name and point api_base at the server's OpenAI-compatible endpoint. LiteLLM sits in front of all of them as one gateway. Its developers describe it as an open source AI gateway that lets you call over 100 LLM providers in the OpenAI format, and the same proxy works for servers on your own network.

The result is one address, by default port 4000 in LiteLLM's examples, and one list of model names that chat front ends, coding assistants and scripts can all use.

What you need

  • At least one local model server. Ollama exposes an OpenAI-compatible API at http://localhost:11434/v1/, and LM Studio's server uses http://localhost:1234/v1 in its examples. See our guides to using the LM Studio server and sharing Ollama on your local network if a server needs to be reachable from another PC.

  • Python 3.10 or newer, or the uv tool. LiteLLM's docs say version 1.84.0 and newer need Python 3.10 or higher, and that uv tool install sets up a compatible Python for you, whereas a plain pip install on an older Python quietly installs an older LiteLLM release.

  • A PC to run the proxy on. The proxy forwards requests rather than running the models itself, so the models' GPU needs apply to the machines running Ollama, LM Studio or llama.cpp, not the proxy PC. It can live on one of your GPU machines or a small always-on box.

Step 1: Install the LiteLLM proxy

LiteLLM's quick start installs the proxy with:

uv tool install 'litellm[proxy]'

Use the litellm[proxy] package rather than the plain Python SDK, because the README says the proxy, CLI and optional extras come with litellm.

Step 2: Write a config file

Create a file called config.yaml. Each entry under model_list maps a public model name, which your apps will ask for, to a real model on a real server. Here is an example with Ollama on the same PC and LM Studio on another machine:

model_list:
  - model_name: qwen-chat
    litellm_params:
      model: ollama_chat/qwen3:14b
      api_base: http://localhost:11434
  - model_name: laptop-model
    litellm_params:
      model: lm_studio/your-loaded-model
      api_base: http://192.168.1.50:1234/v1

Three details matter:

  • Use the ollama_chat/ prefix for Ollama chat models. LiteLLM's Ollama page recommends ollama_chat "for better responses" and says it sends requests to Ollama's /api/chat endpoint.

  • Use the lm_studio/ prefix for LM Studio. LiteLLM says it supports all LM Studio models with that prefix. You can also set the server address with the LM_STUDIO_API_BASE environment variable instead of api_base.

  • Change the model names to the ones you actually have. The model names and IP address in the example above are only examples. Use the tag shown by ollama list and the model identifier LM Studio shows for the model you have loaded.

LiteLLM's Ollama docs also show an optional keep_alive setting, such as "8m", that overrides Ollama's default for how long a model stays loaded in graphics memory.

Step 3: Start the proxy and test it

Start the proxy with:

litellm --config config.yaml

Add --detailed_debug if something doesn't work, as LiteLLM's docs suggest. Then send a test request from the same PC:

curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "qwen-chat", "messages": [{"role": "user", "content": "Hello"}]}'

If the reply comes back, any app that accepts a custom OpenAI base URL can now use http://<proxy-pc>:4000 and the model names from your config. That includes front ends such as Open WebUI and coding tools like Continue.

Step 4: Spread one model across two GPU PCs

This is where a gateway starts to help on the hardware side. If two PCs can run the same model, list both under the same model_name:

model_list:
  - model_name: qwen-chat
    litellm_params:
      model: ollama_chat/qwen3:14b
      api_base: http://192.168.1.20:11434
  - model_name: qwen-chat
    litellm_params:
      model: ollama_chat/qwen3:14b
      api_base: http://192.168.1.21:11434
router_settings:
  routing_strategy: least-busy

LiteLLM's load-balancing docs say it automatically spreads requests across multiple deployments of the same model. The default strategy is simple-shuffle, which distributes requests at random. least-busy sends each request to the deployment with the fewest active requests, and latency-based-routing picks the fastest-responding one. For a household or small office sharing two GPU machines, least-busy is a sensible place to start.

This is not the same as splitting one large model across two PCs. Each request still runs entirely on one machine, so every PC needs enough VRAM for the whole model. If the model is too big for any single card, look at llama.cpp RPC or GPUStack instead.

Step 5: Add fallbacks and priorities

LiteLLM can also try another model when the first one fails. Its config docs show a fallbacks setting under litellm_settings, for example fallbacks: [{"qwen-chat": ["laptop-model"]}], plus num_retries and a request timeout. You can also set order on deployments: the docs say lower values have higher priority, and if an order: 1 deployment fails, the router tries order: 2 next. That suits a setup where your main GPU desktop should take every request, with a smaller machine as a backup when the desktop is off.

Step 6: Lock it down before you share it

If anything other than your own PC can reach port 4000, set a master key. LiteLLM's docs say you can set it under general_settings: master_key in the config or with the LITELLM_MASTER_KEY environment variable. Apps then send that key as their API key.

Per-person virtual keys, spend tracking and the Admin UI need more. The docs say virtual keys require a PostgreSQL database set through DATABASE_URL, and that the basic commands above start the proxy without a database. For a single home user, a master key is usually enough. Don't open the proxy to the internet. If you need remote access, use a private network such as Tailscale.

When LiteLLM is the wrong tool

If all your models run on one PC and the problem is that they don't all fit in VRAM at once, LiteLLM won't solve it, because it doesn't start or stop model servers. llama-swap does that job, and our LiteLLM vs llama-swap comparison explains how the two fit together. For other gateway options, see our best LLM gateways for local AI.

The bottom line

Set up LiteLLM when you have more than one local model server and want every app to use one OpenAI-compatible address. Install it with uv, map public model names to your Ollama, LM Studio or llama.cpp servers in config.yaml, and use the ollama_chat prefix for Ollama. Listing the same model on two GPU PCs gives you load balancing and failover, but each PC still needs enough VRAM for the whole model. Set a master key before anything else on your network can reach it. Forge PC hasn't tested LiteLLM, so start with a simple config and check the docs for your version.

Sources

  1. 01LiteLLM, GitHub README
  2. 02LiteLLM docs, LiteLLM Proxy Server (AI Gateway)
  3. 03LiteLLM docs, Quick Start - LiteLLM Proxy CLI
  4. 04LiteLLM docs, Ollama provider
  5. 05LiteLLM docs, LM Studio provider
  6. 06LiteLLM docs, Proxy load balancing
  7. 07LiteLLM docs, Proxy config.yaml
  8. 08LiteLLM docs, Virtual keys
  9. 09LiteLLM docs, OpenAI-compatible endpoints
  10. 10Ollama docs, OpenAI compatibility
  11. 11LM Studio docs, OpenAI compatibility endpoints

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

How to Use DLSS Ray Reconstruction in PC Games

How-To

How to Use DLSS Ray Reconstruction in PC Games

DLSS Ray Reconstruction replaces a game's ray tracing denoisers with an NVIDIA AI model for cleaner reflections and lighting, and it works on every GeForce RTX card. Here's what it does, which cards support it, how to switch it on, how to get the newer model through the NVIDIA app and when it's worth using.

Marcus Thorne5 min

How to Fix THREAD_STUCK_IN_DEVICE_DRIVER on Windows 11

How-To

How to Fix THREAD_STUCK_IN_DEVICE_DRIVER on Windows 11

Windows crashed with THREAD_STUCK_IN_DEVICE_DRIVER, often mid-game? Microsoft says this stop code frequently comes down to the graphics card or its driver. Here's how to confirm which driver is involved, then fix it in a sensible order: undo recent changes, remove GPU tuning, clean-install the driver and check power, heat and seating.

Marcus Thorne5 min

Best Ways to Type Without a Keyboard in Windows 11 (2026)

Best Picks

Best Ways to Type Without a Keyboard in Windows 11 (2026)

Keyboard dead or missing? Windows 11 has five built-in ways to enter text without one. We rank the On-Screen Keyboard, voice access, voice typing, the touch keyboard and the handwriting panel by what each needs and who it suits best.

Hannah Vance4 min