Skip to main content

Unified interface for multiple LLM providers with automatic provider detection and seamless switching

Project description

Chimeric Logo

Chimeric

PyPI version Python Versions License: MIT Documentation Status CI codecov

Unified Python interface for multiple LLM providers with automatic provider detection and seamless switching.

🚀 Supported Providers

OpenAI Anthropic Google AI xAI Grok Groq Cohere Cerebras OpenRouter

📖 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

📄 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

chimeric-0.3.0.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chimeric-0.3.0-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

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

Hashes for chimeric-0.3.0.tar.gz
Algorithm Hash digest
SHA256 872f6053441260e0f24fe9077fab3c866e46d2af54f77ed3a7b16442e39358d4
MD5 edab72eb81348964392ba097d979133b
BLAKE2b-256 93a08fcce2d4c817523aea126230d2bd5d5352df045fa7ce2f435ed9c36a4106

See more details on using hashes here.

Provenance

The following attestation bundles were made for chimeric-0.3.0.tar.gz:

Publisher: publish.yml on Verdenroz/chimeric

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for chimeric-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c0ee409b1c32c15b4d0274a22cbad5f53009a0c9df976966e70d722543e55c9
MD5 22f27d5f252dd68dacd5a2d3e4466873
BLAKE2b-256 6a5cb29177f42b3c05e52e6c333b0570efc59d63cbee7f66b9a4404bc60ff126

See more details on using hashes here.

Provenance

The following attestation bundles were made for chimeric-0.3.0-py3-none-any.whl:

Publisher: publish.yml on Verdenroz/chimeric

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page