Metadata-Version: 2.2
Name: kalibr
Version: 1.2.6
Summary: Adaptive routing for AI agents. Learns which models work best and routes automatically.
Author-email: Kalibr Team <support@kalibr.systems>
License: Apache-2.0
Project-URL: Homepage, https://github.com/kalibr-ai/kalibr-sdk-python
Project-URL: Documentation, https://kalibr.systems/docs
Project-URL: Repository, https://github.com/kalibr-ai/kalibr-sdk-python
Project-URL: Issues, https://github.com/kalibr-ai/kalibr-sdk-python/issues
Keywords: ai,mcp,gpt,claude,gemini,copilot,openai,anthropic,google,microsoft,observability,telemetry,tracing,llm,schema-generation,api,multi-model,langchain,crewai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27.0
Requires-Dist: tiktoken>=0.8.0
Requires-Dist: fastapi>=0.110.1
Requires-Dist: uvicorn>=0.25.0
Requires-Dist: pydantic>=2.6.4
Requires-Dist: typer>=0.9.0
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: rich>=10.0.0
Requires-Dist: requests>=2.31.0
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.20.0
Requires-Dist: opentelemetry-exporter-otlp>=1.20.0
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
Provides-Extra: langchain-openai
Requires-Dist: langchain-core>=0.1.0; extra == "langchain-openai"
Requires-Dist: langchain-openai>=0.1.0; extra == "langchain-openai"
Provides-Extra: langchain-anthropic
Requires-Dist: langchain-core>=0.1.0; extra == "langchain-anthropic"
Requires-Dist: langchain-anthropic>=0.1.0; extra == "langchain-anthropic"
Provides-Extra: langchain-google
Requires-Dist: langchain-core>=0.1.0; extra == "langchain-google"
Requires-Dist: langchain-google-genai>=0.0.10; extra == "langchain-google"
Provides-Extra: langchain-all
Requires-Dist: langchain-core>=0.1.0; extra == "langchain-all"
Requires-Dist: langchain-openai>=0.1.0; extra == "langchain-all"
Requires-Dist: langchain-anthropic>=0.1.0; extra == "langchain-all"
Requires-Dist: langchain-google-genai>=0.0.10; extra == "langchain-all"
Provides-Extra: crewai
Requires-Dist: crewai>=0.28.0; extra == "crewai"
Provides-Extra: openai-agents
Requires-Dist: openai-agents>=0.0.3; extra == "openai-agents"
Provides-Extra: integrations
Requires-Dist: langchain-core>=0.1.0; extra == "integrations"
Requires-Dist: crewai>=0.28.0; extra == "integrations"
Requires-Dist: openai-agents>=0.0.3; extra == "integrations"
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"

# Kalibr

Adaptive routing for AI agents. Kalibr learns which models, tools, and configs work best for each task and routes automatically.

[![PyPI](https://img.shields.io/pypi/v/kalibr)](https://pypi.org/project/kalibr/)
[![Python](https://img.shields.io/pypi/pyversions/kalibr)](https://pypi.org/project/kalibr/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)

## Installation
```bash
pip install kalibr
```

## Quick Start
```python
from kalibr import Router

router = Router(
    goal="book_meeting",
    paths=["gpt-4o", "claude-sonnet-4-20250514", "gpt-4o-mini"],
    success_when=lambda output: "confirmed" in output.lower()
)

response = router.completion(
    messages=[{"role": "user", "content": "Book a meeting with John tomorrow"}]
)
```

Kalibr picks the best model, makes the call, checks success, and learns for next time.

## Paths

A path is a model + optional tools + optional params:
```python
# Just models
paths = ["gpt-4o", "claude-sonnet-4-20250514"]

# With tools
paths = [
    {"model": "gpt-4o", "tools": ["web_search"]},
    {"model": "claude-sonnet-4-20250514", "tools": ["web_search", "browser"]},
]

# With params
paths = [
    {"model": "gpt-4o", "params": {"temperature": 0.7}},
    {"model": "gpt-4o", "params": {"temperature": 0.2}},
]
```

## Manual Outcome Reporting
```python
router = Router(goal="book_meeting", paths=["gpt-4o", "claude-sonnet-4-20250514"])
response = router.completion(messages=[...])

meeting_created = check_calendar_api()
router.report(success=meeting_created)
```

## LangChain Integration
```bash
pip install kalibr[langchain]
```
```python
from kalibr import Router

router = Router(goal="summarize", paths=["gpt-4o", "claude-sonnet-4-20250514"])
llm = router.as_langchain()

chain = prompt | llm | parser
```

## Auto-Instrumentation

Kalibr auto-instruments OpenAI, Anthropic, and Google SDKs when imported:
```python
import kalibr  # Must be first import
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(model="gpt-4o", messages=[...])
# Traced automatically
```

Disable with `KALIBR_AUTO_INSTRUMENT=false`.

## Other Integrations
```bash
pip install kalibr[crewai]        # CrewAI
pip install kalibr[openai-agents] # OpenAI Agents SDK
```

## Configuration

| Variable | Description | Default |
|----------|-------------|---------|
| `KALIBR_API_KEY` | API key | Required |
| `KALIBR_TENANT_ID` | Tenant ID | `default` |
| `KALIBR_AUTO_INSTRUMENT` | Auto-instrument SDKs | `true` |

## Development
```bash
git clone https://github.com/kalibr-ai/kalibr-sdk-python.git
cd kalibr-sdk-python
pip install -e ".[dev]"
pytest
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

## License

Apache-2.0

## Links

- [Docs](https://kalibr.systems/docs)
- [Dashboard](https://dashboard.kalibr.systems)
