LumoraAI - Make every model smarter, cheaper, and easier to control.
Project description
LumoraAI
Make every model smarter, cheaper, and easier to control.
LumoraAI is an open-source Python library that sits between your application and any LLM provider. It improves prompt quality, routes requests to the right model, caches repeated answers, tracks cost, handles rate limits, and helps developers get better results from cheaper or local models.
- Package name (PyPI):
lumora-ai - Import name:
lumora - License: Apache-2.0
Why LumoraAI?
Building real apps on top of LLMs hits the same wall every time:
- AI bills are unpredictable. A small prompt loop can quietly burn a budget overnight.
- Prompts are weak. Small or local models underperform because users send vague prompts.
- Local models are powerful but inconsistent. They need structure.
- Rate limits are everywhere. Every provider returns 429s at the worst moment.
- Switching providers is painful. OpenAI, OpenRouter, Ollama, vLLM, LM Studio all have slightly different SDKs.
LumoraAI gives you one client, one config, and one mental model.
What it gives you
- Unified
LumoraClient.chat()that works with OpenAI, OpenRouter, Ollama, vLLM, LM Studio, Together-like, or any OpenAI-compatible endpoint. - Smart model router that picks
cheap,balanced, orsmartbased on the prompt. - SQLite cache with optional fuzzy matching (Redis backend is planned).
- Rule-based prompt enhancer that improves vague prompts without calling another expensive model.
- Cost tracker + budget guard with editable per-model pricing.
- Retry/backoff for
429/5xx(no shady key rotation). - Savings report that estimates money saved from cache hits and from routing to cheaper/local models.
- CLI built with Typer + Rich.
Install
pip install lumora-ai
Or, from source (recommended while iterating):
git clone <this-repo>
cd lumora-ai
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
pip install -e ".[dev]"
Quick start
from lumora import LumoraClient
client = LumoraClient(
providers=[
{
"name": "openrouter",
"type": "openai_compatible",
"base_url": "https://openrouter.ai/api/v1",
"api_key": "YOUR_KEY",
"models": {
"cheap": "openai/gpt-4o-mini",
"balanced": "openai/gpt-4o",
"smart": "anthropic/claude-3.5-sonnet",
},
}
],
cache_enabled=True,
budget_limit_usd=5.00,
)
response = client.chat(
messages=[{"role": "user", "content": "Write a professional email asking for payment."}],
quality="balanced",
)
print(response.content)
print(response.model_used)
print(response.estimated_cost)
print(response.cache_hit)
Ollama (local) example
from lumora import LumoraClient
client = LumoraClient(providers=[{
"name": "local",
"type": "ollama",
"base_url": "http://localhost:11434",
"models": {"cheap": "ollama/llama3.1", "balanced": "ollama/llama3.1"},
}])
print(client.chat(messages=[{"role": "user", "content": "3 hike ideas"}]).content)
Prompt enhancement example
from lumora.enhancement import PromptEnhancer
result = PromptEnhancer().enhance("write email payment")
print(result.changed) # True
print(result.enhanced_prompt) # structured, polite, with subject + body
LumoraAI does not rewrite code, legal, or medical prompts, and it leaves already-detailed prompts alone.
Caching example
client.chat(messages=[{"role": "user", "content": "same prompt"}])
again = client.chat(messages=[{"role": "user", "content": "same prompt"}])
assert again.cache_hit is True
Enable fuzzy matching for similar prompts:
client = LumoraClient(providers=[...], cache_fuzzy=True, cache_similarity_threshold=0.92)
Cost tracking & savings
print(client.usage_summary())
print(client.savings_report())
savings_report() estimates:
- how many calls were served from cache,
- approximate USD saved by serving from cache,
- approximate USD saved by routing simple prompts to cheap/local models,
- total estimated spend and total estimated savings.
CLI usage
lumora init # creates .lumora.toml in the current folder
lumora chat "Summarize the OWASP top 10"
lumora cache stats
lumora cache clear
lumora usage # nice Rich tables for usage + savings
The init command produces a config like:
[default]
cache_enabled = true
budget_limit_usd = 5.0
[[providers]]
name = "openrouter"
type = "openai_compatible"
base_url = "https://openrouter.ai/api/v1"
api_key_env = "OPENROUTER_API_KEY"
[providers.models]
cheap = "openai/gpt-4o-mini"
balanced = "openai/gpt-4o"
smart = "anthropic/claude-3.5-sonnet"
Roadmap
- Phase 1 — Python library (this repo). Routing, cache, enhancer, cost, CLI.
- Phase 2 — Paid SaaS dashboard. Hosted analytics, team usage, prompt libraries.
- Phase 3 — Enterprise self-hosted gateway. SSO, audit logs, key vaults, on-prem deploy, controlled key pools.
The current code is intentionally structured so the SaaS dashboard and enterprise gateway can be added as separate packages without changing the public Python API.
Security notes
- API keys are read from environment variables or passed explicitly; they are never written to the cache or logs.
- Error messages are passed through a redactor that strips obvious key/token patterns.
- Prompt logging is off by default (
allow_prompt_logging=False). - LumoraAI does not rotate API keys to bypass provider rate limits. Enterprise users can configure controlled
key_poolfailover in the future. - Retries respect
429/5xxonly and use exponential backoff with jitter.
Contributing
PRs and issues are welcome. Suggested workflow:
pip install -e ".[dev]"
pytest
ruff check lumora tests
When adding a new provider:
- Subclass
lumora.providers.BaseProvider. - Register it in
lumora.providers.build_provider. - Add a test that uses an injected mock provider — do not hit the network in CI.
License
Apache-2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lumora_ai-0.1.0.tar.gz.
File metadata
- Download URL: lumora_ai-0.1.0.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e72872b00b16b055bbbb92c65b9cfd5b598b832e342a867cd5e11ab8cd4e2d6
|
|
| MD5 |
27bcc76c2077253acb04ce2c3c0f0d4f
|
|
| BLAKE2b-256 |
78468ef2573d386e53d0681cd9fdf6e86f66737d644b5fa82cc4e6a5b8847f6f
|
File details
Details for the file lumora_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lumora_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41cc702d10a62cfd3f0c8a004ea1a5f14383e67464614bc37d7eb5626601763f
|
|
| MD5 |
a34c5586b412af4356bf1e0423532e25
|
|
| BLAKE2b-256 |
0fb2b9a349c4debe7d8797a90d00b3b24ad18212233f8b3231241dc7cfa15309
|