Unified interface for multiple LLM providers with automatic provider detection and seamless switching
Project description
Chimeric
Unified Python interface for multiple LLM providers with automatic provider detection and seamless switching.
🚀 Supported Providers
📖 Documentation
For detailed usage examples, configuration options, and advanced features, visit our documentation.
📦 Installation
pip install chimeric
Set your API keys as environment variables:
export OPENAI_API_KEY="your-key-here"
export ANTHROPIC_API_KEY="your-key-here"
⚡ Quickstart
Basic Usage
from chimeric import Chimeric
client = Chimeric() # Auto-detects API keys from environment
response = client.generate(
model="gpt-4o",
messages="Hello!"
)
print(response.content)
Streaming Responses
# Real-time streaming
stream = client.generate(
model="claude-3-5-sonnet-latest",
messages="Tell me a story about space exploration",
stream=True
)
for chunk in stream:
print(chunk.content, end="", flush=True)
Function Calling with Tools
@client.tool()
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"Sunny, 72°F in {city}"
@client.tool()
def calculate_tip(bill_amount: float, tip_percentage: float = 18.0) -> dict:
"""Calculate tip and total amount for a restaurant bill."""
tip = bill_amount * (tip_percentage / 100)
total = bill_amount + tip
return {"tip": tip, "total": total, "tip_percentage": tip_percentage}
response = client.generate(
model="gpt-4o",
messages=[
{"role": "user", "content": "What's the weather in NYC?"},
{"role": "user", "content": "Also calculate a tip for a $50 dinner bill"}
]
)
print(response.content)
Structured Output
from pydantic import BaseModel
class Sentiment(BaseModel):
label: str
score: float
reasoning: str
response = client.generate(
model="gpt-4o",
messages="Analyse the sentiment: 'This library is fantastic!'",
response_model=Sentiment,
)
print(response.parsed.label) # "positive"
print(response.parsed.score) # 0.98
Embeddings
# Single text → result.embedding (list[float])
result = client.embed(
model="text-embedding-3-small",
input="Python developer with 5 years experience",
)
print(len(result.embedding)) # e.g. 1536
# Batch → result.embeddings (list[list[float]])
result = client.embed(
model="text-embedding-3-small",
input=["Python developer", "Go engineer", "React developer"],
)
print(len(result.embeddings)) # 3
# Also available via Google and Cohere
result = client.embed(model="gemini-embedding-001", input="Hello")
result = client.embed(model="embed-english-v3.0", input="Hello")
Multi-Provider Switching
# Seamlessly switch between providers
models = ["gpt-4o-mini", "claude-3-5-haiku-latest", "gemini-2.5-flash"]
for model in models:
response = client.generate(
model=model,
messages="Explain quantum computing in one sentence"
)
print(f"{model}: {response.content}")
🔧 Key Features
- Multi-Provider Support: Switch between 8 major AI providers seamlessly
- Automatic Detection: Auto-detects available API keys from environment
- Unified Interface: Consistent API across all providers
- Embeddings: Single and batch text embeddings via OpenAI, Google, and Cohere
- Structured Output: Parse responses directly into Pydantic models
- Streaming Support: Real-time response streaming
- Function Calling: Tool integration with decorators
- Async Support: Full async/await compatibility
- Local AI: Connect to Ollama, LM Studio, or any OpenAI-compatible endpoint
🐛 Issues & Feature Requests
- Found a bug? Use our Bug Report template
- Want a feature? Use our Feature Request template
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
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 chimeric-0.3.0.tar.gz.
File metadata
- Download URL: chimeric-0.3.0.tar.gz
- Upload date:
- Size: 4.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
872f6053441260e0f24fe9077fab3c866e46d2af54f77ed3a7b16442e39358d4
|
|
| MD5 |
edab72eb81348964392ba097d979133b
|
|
| BLAKE2b-256 |
93a08fcce2d4c817523aea126230d2bd5d5352df045fa7ce2f435ed9c36a4106
|
Provenance
The following attestation bundles were made for chimeric-0.3.0.tar.gz:
Publisher:
publish.yml on Verdenroz/chimeric
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chimeric-0.3.0.tar.gz -
Subject digest:
872f6053441260e0f24fe9077fab3c866e46d2af54f77ed3a7b16442e39358d4 - Sigstore transparency entry: 975481551
- Sigstore integration time:
-
Permalink:
Verdenroz/chimeric@1840451a58f836a586170bc9765976302a777ddc -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Verdenroz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1840451a58f836a586170bc9765976302a777ddc -
Trigger Event:
release
-
Statement type:
File details
Details for the file chimeric-0.3.0-py3-none-any.whl.
File metadata
- Download URL: chimeric-0.3.0-py3-none-any.whl
- Upload date:
- Size: 41.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c0ee409b1c32c15b4d0274a22cbad5f53009a0c9df976966e70d722543e55c9
|
|
| MD5 |
22f27d5f252dd68dacd5a2d3e4466873
|
|
| BLAKE2b-256 |
6a5cb29177f42b3c05e52e6c333b0570efc59d63cbee7f66b9a4404bc60ff126
|
Provenance
The following attestation bundles were made for chimeric-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on Verdenroz/chimeric
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chimeric-0.3.0-py3-none-any.whl -
Subject digest:
9c0ee409b1c32c15b4d0274a22cbad5f53009a0c9df976966e70d722543e55c9 - Sigstore transparency entry: 975481574
- Sigstore integration time:
-
Permalink:
Verdenroz/chimeric@1840451a58f836a586170bc9765976302a777ddc -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Verdenroz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1840451a58f836a586170bc9765976302a777ddc -
Trigger Event:
release
-
Statement type: