Chain multiple free-tier LLM APIs with automatic rate limit fallback
Project description
FreeFlow LLM
Chain multiple free-tier LLM APIs with automatic rate limit fallback.
FreeFlow LLM is a lightweight Python package that lets you use powerful LLMs completely free by intelligently chaining multiple free-tier providers (currently Groq and Google Gemini, with more on the way). When one provider hits a rate limit, it automatically switches to the next one, giving you effectively unlimited free usage.
Features
- 100% Free-Tier Only: No paid tiers, no credit card required
- Automatic Fallback: Detects rate limits (HTTP 429) and switches providers instantly
- Multiple API Keys: Rotate through several keys per provider to multiply your limits
- Smart Prioritization: Starts with the fastest providers (Groq), falls back to others
- Clean & Unified API: Simple, consistent
client.chat()interface across all providers - 16,000+ Requests/Day: Aggregate free usage across all providers
Quick Start
Installation
pip install freeflow-llm
Set Up API Keys
Get free API keys from these providers (you only need at least one):
- Groq (Recommended): https://console.groq.com/keys
- Google Gemini: https://makersuite.google.com/app/apikey
Set them as environment variables (or place them in a .env file):
export GROQ_API_KEY="your_groq_key"
export GEMINI_API_KEY="your_gemini_key"
Multiple API Keys per Provider
Configure multiple keys per provider. When a rate limit is hit, FreeFlow rotates through all available keys before moving to the next provider:
# JSON array (recommended for complex keys)
export GEMINI_API_KEY='["key1", "key2", "key3"]'
# Comma-separated (simpler)
export GROQ_API_KEY="groq_key1,groq_key2"
# Single key (traditional)
export GEMINI_API_KEY="single_key"
More keys means a higher effective limit. For example, 3 Gemini keys = 4,500 requests/day instead of 1,500.
Basic Usage
from freeflow_llm import FreeFlowClient
# Context manager ensures HTTP connections are cleaned up (recommended)
with FreeFlowClient() as client:
response = client.chat(
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of Ethiopia?"},
],
temperature=0.7,
max_tokens=100,
)
print(response.content) # "The capital of Ethiopia is Addis Ababa."
print(response.provider) # "groq" (or whichever provider responded)
FreeFlow automatically tries providers in order and handles rate limits transparently.
Error Handling
from freeflow_llm import FreeFlowClient, NoProvidersAvailableError
with FreeFlowClient() as client:
try:
response = client.chat(messages=[{"role": "user", "content": "Hello!"}])
print(response.content)
except NoProvidersAvailableError as e:
print(f"All providers exhausted: {e}")
🔧 Advanced Configuration
from freeflow_llm import FreeFlowClient, config
from freeflow_llm.providers import GeminiProvider, GroqProvider
# Check default models (used when no `model` is specified)
print(config.DEFAULT_MODELS)
# {'groq': 'llama-3.3-70b-versatile', 'gemini': 'gemini-2.5-flash', ...}
# Override the default model per call
with FreeFlowClient() as client:
client.chat(
messages=[{"role": "user", "content": "Hello!"}],
model="gemini-2.5-flash",
)
# Configure providers manually with multiple keys
custom_providers = [
GroqProvider(api_key=["key1", "key2"]),
GeminiProvider(api_key=["key1", "key2", "key3"]),
]
client = FreeFlowClient(providers=custom_providers)
print(client.list_providers()) # ['groq', 'gemini']
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
To set up for development:
git clone https://github.com/thesecondchance/freeflow-llm.git
cd freeflow-llm
pip install -e ".[dev]"
pre-commit install
pytest tests/ -v
License
This project is licensed under the MIT License. See the LICENSE file for details.
Disclaimer
This package is designed for free-tier usage only. Please respect each provider's rate limits and terms of service. FreeFlow LLM is not affiliated with any of the LLM providers.
🔗 Links
Made with ❤️ for the developer community. If this project helps you, please consider giving it a ⭐ on GitHub!
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
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 freeflow_llm-0.1.4.tar.gz.
File metadata
- Download URL: freeflow_llm-0.1.4.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
427257dc0b8c94241f08176b72d0099a9989bf29f4ecaf588499710f208fa290
|
|
| MD5 |
09e2d4b1fea38a0e1b46a7afc05a7523
|
|
| BLAKE2b-256 |
94909480e330cccc9a1aca1f4a8674050cbee834129465ebc160e2ffd586a8c2
|
File details
Details for the file freeflow_llm-0.1.4-py3-none-any.whl.
File metadata
- Download URL: freeflow_llm-0.1.4-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
086b39d60d8b7c221ff29f5c641ae9f912bc089b80215cf31b12daa7c9e8ce85
|
|
| MD5 |
2ee164b7711c95db0badbcb4ea2911d1
|
|
| BLAKE2b-256 |
3b07b98c5ff7899c9706be90e3e6f1a13c181f1a25c7207e892d0572a7a5b3d4
|