<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm" -->

---
title: I Built an Auto Router for Local LLMs with LiteLLM + Pi...
description: A video tutorial demonstrates building a smart auto-router for local LLMs using LiteLLM combined with coding agents like Pi Coding Agent or Codex. The setup...
canonical: https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: I Built an Auto Router for Local LLMs with LiteLLM + Pi Coding Agent | daily.dev
og:description: A video tutorial demonstrates building a smart auto-router for local LLMs using LiteLLM combined with coding agents like Pi Coding Agent or Codex. The setup...
og:url: https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm
og:image: https://api.daily.dev/og/posts/rhLOQEkkM.png
og:image:alt: I Built an Auto Router for Local LLMs with LiteLLM + Pi Coding Agent
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# I Built an Auto Router for Local LLMs with LiteLLM + Pi Coding Agent

**[Execute Automation](https://daily.dev/sources/executeautomation)** · 20 min read · 0 upvotes · 0 comments

## Summary

A video tutorial demonstrates building a smart auto-router for local LLMs using LiteLLM combined with coding agents like Pi Coding Agent or Codex. The setup runs multiple local models (Qwen, Gemma, and others) across providers like Ollama, MLX, and LM Studio, with LiteLLM acting as a gateway that classifies prompt complexity (via heuristic or LLM-based classifiers) and routes each request to the most appropriate model tier: simple, medium, complex, or reasoning. The walkthrough covers Docker Compose setup, a config.yaml defining model lists and routing tiers, and live demos showing traffic being dynamically routed between a small Qwen model and larger Gemma models based on task complexity, mirroring the auto-model-selection feature seen in some IDEs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=QkElI_HcuT8>

## Questions this post answers

### How does LiteLLM decide which local model to route a coding agent's prompt to?

LiteLLM uses one of two classifier types to route prompts: a heuristic classifier that scores prompts using signals like length, code presence, reasoning markers, and complexity patterns mapped to a routing tier, or an LLM classifier that uses a small language model to semantically judge whether a prompt is simple, medium, complex, or reasoning-heavy before routing it to the matching model tier.

_daily.dev surfaces practical routing setups like this for developers optimizing local LLM coding workflows._

### How do I connect Ollama running on my host machine to LiteLLM running inside Docker?

Inside the Docker network, localhost cannot reach the host machine, so Ollama's API must be accessed using host.docker.internal instead of a localhost address in the LiteLLM config.yaml. The same host.docker.internal approach is used to reach an MLX server running on the host at its own port, such as port 8000.

_developers wiring local model providers into Docker setups can find configuration walkthroughs like this on daily.dev._

### What is the difference between LiteLLM's heuristic classifier and LLM classifier for model routing?

A heuristic classifier scores prompts using predefined signals such as length, presence of code, reasoning markers, and complexity patterns, then maps that score directly to a routing tier without calling another model. An LLM classifier instead uses a small language model to semantically interpret the prompt's intent and complexity before deciding which tier and model to route the request to, and can fall back to the heuristic method if the classifier model is unavailable.

_comparing routing strategies like these helps developers choosing an LLM gateway approach on daily.dev._

## Similar posts on daily.dev

- [Running local models is good now](https://daily.dev/posts/running-local-models-is-good-now-q20vqhe78) · Lobsters · 1 upvotes · 0 comments
- [Using Local Coding Agents](https://daily.dev/posts/using-local-coding-agents-oxctgltkz) · Sebastian Raschka · 2 upvotes · 0 comments
- [Running Pi with local LLMs on a Raspberry Pi sounds chaotic, but it actually works](https://daily.dev/posts/running-pi-with-local-llms-on-a-raspberry-pi-sounds-chaotic-but-it-actually-works-y6ekdzsbh) · XDA Developers · 1 upvotes · 0 comments
- [LLM Router Pattern \(2026\): Model Routing, Fallbacks, Cost Control](https://daily.dev/posts/llm-router-pattern-2026-model-routing-fallbacks-cost-control-8txalf5nf) · Alex CloudStar · 1 upvotes · 0 comments
- [How to route external and local LLMs with Models-as-a-Service](https://daily.dev/posts/how-to-route-external-and-local-llms-with-models-as-a-service-ufwzx55fl) · Red Hat Developer · 0 upvotes · 0 comments

---

Tags: [#ai-gateway](https://daily.dev/tags/ai-gateway), [#docker](https://daily.dev/tags/docker), [#litellm](https://daily.dev/tags/litellm), [#local-ai](https://daily.dev/tags/local-ai), [#ollama](https://daily.dev/tags/ollama)

[View this post on daily.dev](https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"I Built an Auto Router for Local LLMs with LiteLLM + Pi Coding Agent","url":"https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm"},"datePublished":"2026-09-11T14:08:57.492Z","dateModified":"2026-10-15T02:22:53.622Z","description":"A video tutorial demonstrates building a smart auto-router for local LLMs using LiteLLM combined with coding agents like Pi Coding Agent or Codex. The setup...","image":"https://i.ytimg.com/vi/QkElI_HcuT8/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/QkElI_HcuT8/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Execute Automation","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Execute Automation","logo":"https://media.daily.dev/image/upload/s--Uh-EE9Cf--/f_auto,q_auto/v1780213688/logos/executeautomation?_a=BAMAMiWQ0","url":"https://daily.dev/sources/executeautomation"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-gateway,docker,litellm,local-ai,ollama","timeRequired":"PT20M","video":{"@type":"VideoObject","name":"I Built an Auto Router for Local LLMs with LiteLLM + Pi Coding Agent","description":"A video tutorial demonstrates building a smart auto-router for local LLMs using LiteLLM combined with coding agents like Pi Coding Agent or Codex. The setup...","thumbnailUrl":"https://i.ytimg.com/vi/QkElI_HcuT8/sddefault.jpg","uploadDate":"2026-09-11T14:08:57.492Z","duration":"PT20M","url":"https://api.daily.dev/r/rhLOQEkkM","embedUrl":"https://www.youtube.com/embed/QkElI_HcuT8"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Execute Automation","item":"https://daily.dev/sources/executeautomation"},{"@type":"ListItem","position":3,"name":"I Built an Auto Router for Local LLMs with LiteLLM + Pi Coding Agent"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/i-built-an-auto-router-for-local-llms-with-litellm-pi-coding-agent-rhloqekkm#faq","mainEntity":[{"@type":"Question","name":"How does LiteLLM decide which local model to route a coding agent's prompt to?","acceptedAnswer":{"@type":"Answer","text":"LiteLLM uses one of two classifier types to route prompts: a heuristic classifier that scores prompts using signals like length, code presence, reasoning markers, and complexity patterns mapped to a routing tier, or an LLM classifier that uses a small language model to semantically judge whether a prompt is simple, medium, complex, or reasoning-heavy before routing it to the matching model tier. daily.dev surfaces practical routing setups like this for developers optimizing local LLM coding workflows."}},{"@type":"Question","name":"How do I connect Ollama running on my host machine to LiteLLM running inside Docker?","acceptedAnswer":{"@type":"Answer","text":"Inside the Docker network, localhost cannot reach the host machine, so Ollama's API must be accessed using host.docker.internal instead of a localhost address in the LiteLLM config.yaml. The same host.docker.internal approach is used to reach an MLX server running on the host at its own port, such as port 8000. developers wiring local model providers into Docker setups can find configuration walkthroughs like this on daily.dev."}},{"@type":"Question","name":"What is the difference between LiteLLM's heuristic classifier and LLM classifier for model routing?","acceptedAnswer":{"@type":"Answer","text":"A heuristic classifier scores prompts using predefined signals such as length, presence of code, reasoning markers, and complexity patterns, then maps that score directly to a routing tier without calling another model. An LLM classifier instead uses a small language model to semantically interpret the prompt's intent and complexity before deciding which tier and model to route the request to, and can fall back to the heuristic method if the classifier model is unavailable. comparing routing strategies like these helps developers choosing an LLM gateway approach on daily.dev."}}]}
```

