Skip to main content

GitHub stars License: MIT PyPI version Python 3.11+

llamux 🦙

A simple router to rotate across your configured LLM endpoints, balancing load and avoiding rate limits. The router selects your preferred provider-model pair based on an implicit preference list, ensuring token and request limits (day/hour/minute) aren't crossed. State persists across sessions, with quotas stored in local cache.

Install

Requires Python 3.11+

pip install llamux

Usage

You need first to set the list of endpoints you want to allow routing on;

$ > endpoints.csv

| provider | model                   | rpm | tpm   | rph   | tph     | rpd   | tpd     |
| -------- | ----------------------- | --- | ----- | ----- | ------- | ----- | ------- |
| cerebras | llama3.3-70b            | 30  | 60000 | 900   | 1000000 | 14400 | 1000000 |
| groq     | llama-3.3-70b-versatile | 30  | 6000  | 14400 |         | 14400 |         |

where rpm, tpm are requests and tokens limits per minutes, and the same follows for hours and days. Important note 🔊 Your implicit preference list is given by the ordering of the endpoints in this table. In the above, we'll always prefer Cerebras over Groq, as long as the quota limits are not exceeded.

Use it as a standalone router;

from llamux import Router

os.environ["CEREBRAS_API_KEY"] = "sk-..."
os.environ["GROQ_API_KEY"] = "sk-..."

router = Router.from_csv("endpoints.csv")
messages = [{"role": "user", "content": "Hello, how are you?"}]

provider, model, id, props = router.query(messages)
# provider: cerebras, model: llama3.3-70b

Or use it directly as a completion endpoint;

from llamux import Router

router = Router.from_csv("endpoints.csv")
messages = [{"role": "user", "content": "hey" * 59999}]

response = router.completion(messages) # calls cerebras
response = router.completion(messages) # calls groq (cerebras quota is out!)

The above builds upon litellm llm proxy

More features

Contributions are welcome :)

  • Add support for speed and cost routing preferences
  • Add other routing strategies (now preferencial ordering only)
  • Avoid getting preference listing from table ordering

Metadata

Release files for llamux 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llamux 0.1.9
File Size Uploaded Provenance
llamux-0.1.9.tar.gz 4.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llamux 0.1.9
File Interpreter ABI Platform
llamux-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / llamux-0.1.9.tar.gz

Download URL llamux-0.1.9.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0ca00469b92fb523a4e905159ac269c53b2146233de10c858f016536c75d68e9
BLAKE2b-256 checksum
How to use checksums
7b2d8bc6a0a7460ed6ab3aac0078f894408bf1e20d4c12f30cf52416bfe29803
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.13.0 Darwin/22.6.0

Release files / llamux-0.1.9-py3-none-any.whl

Download URL llamux-0.1.9-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bd703fc754e78c6d43ad2900bb7ca373df678a41038da4520cd2e539e99fd4d
BLAKE2b-256 checksum
How to use checksums
ca95e48aa86223b5ad5ba3c8a615a90ee202e00202d9212530745c7492829aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.13.0 Darwin/22.6.0

Security for llamux 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page