Skip to main content

No project description provided

Project description

Build Status Coverage

llmbroker

Route LLM calls over a pool of free LLMs with automatic round-robin and cooldown.

No LangChain, no heavy deps.

import llmbroker

llms = llmbroker.Broker("llms.toml")
print(llms.ask("Summarize this receipt").text)

llms.toml is a plain list of [[llms]] entries (base_url, model, api_key_ref). Grab the freetier preset from this repo to start with a maintained list of free LLM endpoints.

That one-liner is the whole API for a script — but the same Broker scales up too. Run it inside a server or across a cluster with cooldown state shared between instances, and back it with common databases (connectors for SQLite, Redis, and Postgres covering registry, telemetry, secrets, and state). The calling code stays the same — you just pass a backend.

Why llmbroker:

  • Round-robin with automatic failover — 429/503 cools an endpoint and tries the next; the caller never sees a rate-limit error unless every endpoint fails.
  • No heavy deps — stdlib-only core; optional backends (sqlite, redis, postgres) are submodules you import only when you need them.
  • Dead-simple to start — a TOML file and env vars, one constructor line, done.
  • Fully customisable — swap registry, secrets, and telemetry backends independently: any DB, any secrets manager (AWS, Vault, …), any storage.
  • Cluster-ready — add state_store=llmbroker.redis.StateStore(...) to sync cooldown state across instances; omit for single-process.
  • Sync and asyncllmbroker.Broker for scripts; llmbroker.AsyncBroker for FastAPI, agents, and async workers.

Documentation

llmbroker

Developers

Do not forget to run . ./activate.sh.

For work it need uv installed.

Use pre-commit hooks for code quality:

pre-commit install

Allure test report

Scripts

Install invoke preferably with uv tool:

uv tool install invoke

For a list of available scripts run:

invoke --list

For more information about a script run:

invoke <script> --help

Coverage report

Created with cookiecutter using template

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmbroker-0.0.9.tar.gz (97.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmbroker-0.0.9-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file llmbroker-0.0.9.tar.gz.

File metadata

  • Download URL: llmbroker-0.0.9.tar.gz
  • Upload date:
  • Size: 97.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmbroker-0.0.9.tar.gz
Algorithm Hash digest
SHA256 85e6b322ab044f85746eac99aa79b7483597aa55beb4e11de48e125f94688bdd
MD5 3b9dcb9f3a67c37cad7b7d2fa7eebe2c
BLAKE2b-256 1502a6c5149f1d7c5f209d6f487c8d8592e4dfe19ce04d9d15a8d1794b9a5c13

See more details on using hashes here.

File details

Details for the file llmbroker-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: llmbroker-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmbroker-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 99d954b0c5d845d8ec3ed6f6f05135c8227c119bed42e7cbc1de7ac81a476f75
MD5 18b9af373e0fa16c16e8bbaf4a5ef05f
BLAKE2b-256 96f5b9db7340ec1735283b403741b945ebeb514836e715f159a2378bac8fbbc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page