ModelBridge
Simple Multi-Provider LLM Gateway
ModelBridge is a Python library that provides unified access to multiple AI providers. It simplifies working with OpenAI, Anthropic, Google, and Groq APIs through a single interface.
✨ What it Does
- Multi-Provider Support: Works with OpenAI, Groq, Google, and Anthropic
- Smart Model Selection: Automatically picks models based on your task
- Cost Tracking: Shows you how much each request costs
- Simple API: One function (
ask) for most use cases - Environment Variables: Secure API key management
🚀 Quick Start
Installation
pip install modelbridge
Basic Usage
import asyncio
from modelbridge.simple import ask
# Set your API keys as environment variables:
# export OPENAI_API_KEY='your_openai_key'
# export GROQ_API_KEY='your_groq_key'
async def main():
response = await ask("What is the capital of France?")
print(f"Answer: {response.content}")
print(f"Model: {response.model_id}")
print(f"Provider: {response.provider_name}")
print(f"Cost: ${response.cost:.4f}")
asyncio.run(main())
Advanced Usage
# Specify a particular model
response = await ask("Write Python code", model="gpt-4")
# Optimize for speed, cost, or quality
response = await ask("Simple math", optimize_for="cost")
response = await ask("Complex analysis", optimize_for="quality")
# Set maximum cost limit
response = await ask("Quick question", max_cost=0.001)
# Other useful functions
from modelbridge.simple import code, translate, summarize
# Generate code
response = await code("Create a sorting function", language="python")
# Translate text
response = await translate("Hello world", "Spanish")
# Summarize text
response = await summarize("Long article text here...", length="short")
Configuration
API Keys
Set your API keys as environment variables:
# Add the providers you want to use
export OPENAI_API_KEY='sk-your-openai-key'
export GROQ_API_KEY='gsk_your-groq-key'
export GOOGLE_API_KEY='your-google-key'
export ANTHROPIC_API_KEY='sk-ant-your-anthropic-key'
You need at least one API key for ModelBridge to work.
Supported Providers
- OpenAI: GPT-4, GPT-3.5-turbo, GPT-5-mini
- Groq: Llama 3.3 (very fast)
- Google: Gemini models
- Anthropic: Claude models
How It Works
- You call
ask("your question") - ModelBridge analyzes your prompt
- It picks the best model for the task
- Returns response with cost tracking
- Automatically handles errors and retries
License
MIT License
Simple AI provider integration.
Metadata
Release files for modelbridge 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| modelbridge-0.1.7.tar.gz | 229.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modelbridge-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 490.2 kB
Release files / modelbridge-0.1.7.tar.gz
| Download URL | modelbridge-0.1.7.tar.gz |
|---|---|
| Size | 229.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8299aadae90a9dfd4f379339f89bfe6132fd4ae7db8c4fffd2cacbd996147c6c
|
|
BLAKE2b-256 checksum How to use checksums |
efa7612f53082d1a8e9dd8d6fc92e59b5430d185cecc189e72c1cd8e18b78bf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.5
|
Release files / modelbridge-0.1.7-py3-none-any.whl
| Download URL | modelbridge-0.1.7-py3-none-any.whl |
|---|---|
| Size | 260.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1795b77961679e267018c47feeb29d3d2f2233ece7f24d0f3d4a81b7d044b867
|
|
BLAKE2b-256 checksum How to use checksums |
9abf6f05953b170fd3a920252ca1d435e0e7b4f727a742644ebf3aca25f0bbb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.5
|