Ana Sayfa / Kod ve Scriptler / ModelRouter Python Router for Coding Agents

ModelRouter Python Router for Coding Agents

ModelRouter, yapılandırılabilir kalıplar ve günlük bütçe sınırıyla kodlama ajanı isteklerini yerel ve barındırılan modeller arasında yönlendirir.

  • Yayın tarihi11 Kasım 2026
  • Paket içeriği.py, .md, .yml/.yaml
  • Son güncelleme11 Kasım 2026
  • Canlı demoVar
ModelRouter Python Router for Coding Agents

Overview

ModelRouter is a small proxy you run yourself. Your coding agent points at the router's local address instead of at one model, and the router decides which model actually answers each request — a free local model through Ollama, or any OpenAI-compatible API you already have a key for. Which model for which task becomes a config file you control, not a paid IDE feature.

Point an agent at one strong model and you pay strong-model prices to rename variables. Point it at one cheap model and hard problems get weak answers. ModelRouter runs three patterns: Single (one model answers), Cascade (a cheap or local model drafts, simple quality checks judge the draft, only a failed check escalates), and Critique (a second model scores the draft and sends it back below a threshold). Every call is priced from a table you edit, and the daily budget warns at 80% and stops at 100% — an agent loop can't burn a card overnight.

What it does:

- One OpenAI-compatible endpoint for your agent: http://127.0.0.1:4000/v1

- Three routing patterns: Single, Cascade (quality gate escalates), Critique (score and revise, max 2 rounds)

- Works with local Ollama models and any OpenAI-compatible API

- Every decision written to a JSONL routing log — prompt hash only, never prompt text

- Token costs priced from your own editable price table; `modelrouter costs` shows the spend, HTML report included

- Daily budget cap: warns at 80%, hard stop at 100%

- Dry-run any routing decision first: `modelrouter route --explain` calls no backend

- Zero third-party dependencies — Python standard library only; no hosted component, nothing phones home

What's inside the download:

- ModelRouter source code (Python package: router, server, quality gate, cost ledger)

- README.md — what it is and how to run it

- INSTALL.md — step-by-step setup

- config.example.yaml — copy it, list your models, done

- docs/ — agent setup, routing patterns, and the cost model explained

- The full test suite, including a fake backend so the whole loop is testable offline

- LICENSE — MIT license

How you run it: Copy the example config, start the proxy with `python -m modelrouter serve`, and set your agent's base URL to http://127.0.0.1:4000/v1. `modelrouter costs` shows what the day has spent so far.

Open source, stated plainly: ModelRouter is my own code, and the same code is free on GitHub under the MIT license. This package is the supported download — the tested release zipped with its docs, examples, and test suite, and email support from me if something in the package is broken. If you'd rather clone the repo, that door is open. I'd rather you knew before you paid.

You pay once — there is no subscription and no account to create.