Framework Integrations
CrewAI, LangChain, OpenAI Agents SDK, HuggingFace, OpenClaw, and Hermes.
Overview
Kalibr integrates with popular agent frameworks and supports any model across any modality. Use router.as_langchain() for LangChain, or auto-instrument HuggingFace's InferenceClient for 17 task types.
CrewAI
Install
pip install kalibr[crewai] crewai openai anthropic
Code (Python only)
from kalibr import Router from crewai import Agent, Task, Crew # Create Kalibr router router = Router( goal="research_task", paths=["gpt-4o-mini", "claude-sonnet-4-20250514"] ) # Get LangChain-compatible LLM llm = router.as_langchain() # Use with CrewAI researcher = Agent( role="Researcher", goal="Find accurate information", backstory="You are a research assistant.", llm=llm, # Kalibr handles model selection verbose=True ) task = Task( description="Research the history of Python programming language.", expected_output="A summary of Python's history.", agent=researcher ) crew = Crew(agents=[researcher], tasks=[task]) result = crew.kickoff() # Report outcome to Kalibr router.report(success=len(str(result)) > 100)
Note: CrewAI requires Python 3.10+.
LangChain
Install
pip install kalibr[langchain] langchain langchain-openai langchain-anthropic
Code (Python only)
from kalibr import Router
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
router = Router(
goal="summarize_text",
paths=["gpt-4o-mini", "claude-sonnet-4-20250514"]
)
llm = router.as_langchain()
prompt = ChatPromptTemplate.from_template("Summarize this: {text}")
chain = prompt | llm | StrOutputParser()
result = chain.invoke({"text": "Long article text here..."})
router.report(success=len(result) > 50)
OpenAI Agents SDK
Install
pip install kalibr[openai-agents] openai-agents
Code (Python only)
from kalibr import Router router = Router( goal="agent_task", paths=["gpt-4o", "gpt-4o-mini"] ) # Get routing decision from kalibr import get_policy policy = get_policy(goal="agent_task") model = policy["recommended_model"] # Use with OpenAI Agents SDK from agents import Agent, Runner agent = Agent( name="Assistant", instructions="You are a helpful assistant.", model=model, ) result = Runner.run_sync(agent, "Your task here") # Report outcome router.report(success=len(result.final_output) > 0)
HuggingFace
Install
pip install kalibr huggingface_hub
Code (Python only)
import kalibr # instruments InferenceClient automatically from huggingface_hub import InferenceClient client = InferenceClient() # All 17 task methods are now traced with cost tracking # Route between HuggingFace models from kalibr import Router router = Router( goal="transcribe_call", paths=["openai/whisper-large-v3", "facebook/seamless-m4t-v2-large"], success_when=lambda output: len(output) > 50 ) result = router.execute(task="automatic_speech_recognition", input_data=audio_bytes)
Note: HuggingFace instrumentation covers 17 task types across text, audio, image, embedding, and classification. Set HF_API_TOKEN or HUGGING_FACE_HUB_TOKEN to access private models or avoid free-tier rate limits.
Supported task types
Pass any of these as the task argument to router.execute():
| Modality | Tasks |
|---|---|
| Text | chat_completion, text_generation, summarization, translation, fill_mask, table_question_answering |
| Audio | automatic_speech_recognition, text_to_speech, audio_classification |
| Image | text_to_image, image_to_text, image_classification, image_segmentation, object_detection |
| Embedding | feature_extraction |
| Classification | text_classification, token_classification |
DeepSeek
DeepSeek uses the OpenAI Python SDK with a different endpoint. No separate SDK needed, just set your API key and use deepseek-* model names in your paths.
Install
pip install kalibr openai
Setup
export DEEPSEEK_API_KEY=sk-... # from platform.deepseek.com
Code (Python only)
import kalibr
from kalibr import Router
# Route between DeepSeek models
router = Router(
goal="classify_icp",
paths=["deepseek-chat", "deepseek-reasoner"],
success_when=lambda output: len(output) > 0
)
response = router.completion(messages=[{"role": "user", "content": "Is this company a good ICP fit?"}])
# Mix DeepSeek with other providers, Kalibr learns which works best
router = Router(
goal="classify_icp",
paths=["gpt-4o-mini", "deepseek-chat", "claude-sonnet-4-20250514"],
)
response = router.completion(messages=[...])
Models: deepseek-chat (DeepSeek-V3, fast and cheap), deepseek-reasoner (DeepSeek-R1, for complex reasoning), deepseek-coder (code tasks). Kalibr tracks cost and attributes spans correctly for each.
Nebius AI
Nebius AI Studio runs open-source models (Llama, Qwen, Mistral) on their own GPU infrastructure. OpenAI-compatible. No separate SDK needed. Use nebius/ model prefix in your paths.
Install
pip install kalibr openai
Setup
export NEBIUS_API_KEY=... # from studio.nebius.ai
Code (Python only)
import kalibr
from kalibr import Router
router = Router(
goal="research",
paths=["nebius/meta-llama/Llama-3.3-70B-Instruct", "deepseek-chat"],
)
response = router.completion(messages=[{"role": "user", "content": "Summarize the latest in AI"}])
Models: nebius/meta-llama/Llama-3.3-70B-Instruct, nebius/Qwen/Qwen2.5-72B-Instruct, nebius/mistralai/Mistral-Nemo-Instruct-2407. Any Nebius-hosted model works, prefix it with nebius/.
Tavily Search
Tavily is a search API built for AI agents. Kalibr wraps Tavily results in an OpenAI-compatible response so Kalibr can route between it and other providers based on which produces better results.
Install
pip install kalibr httpx
Setup
export TAVILY_API_KEY=tvly-... # from app.tavily.com
Code (Python only)
import kalibr
from kalibr import Router
# Compete Tavily against an LLM on web research
router = Router(
goal="web_scraping",
paths=["tavily/advanced", "deepseek-chat"],
success_when=lambda out: len(out) > 100,
)
response = router.completion(messages=[{"role": "user", "content": "Latest AI benchmark results 2025"}])
Paths: tavily/basic (faster, cheaper) and tavily/advanced (deeper search). Kalibr wraps results in a ChatCompletion shim response.choices[0].message.content contains the answer plus source links.
Voice AI (ElevenLabs, Deepgram, OpenAI Audio)
Install
pip install kalibr[voice] # ElevenLabs + Deepgram + OpenAI Audio pip install kalibr[elevenlabs] # ElevenLabs only pip install kalibr[deepgram] # Deepgram only
TTS routing with router.synthesize()
import kalibr # instruments ElevenLabs + OpenAI Audio automatically
from kalibr import Router
# Route between TTS providers, Kalibr learns which sounds better / costs less
router = Router(
goal="narrate",
paths=["tts-1", "eleven_multilingual_v2"],
success_when=lambda _: True # or evaluate audio quality downstream
)
result = router.synthesize("Your agent completed the task.", voice="alloy")
audio_bytes = result.audio
# result.cost_usd, result.model, result.kalibr_trace_id also available
STT routing with router.transcribe()
router = Router( goal="transcribe_calls", paths=["whisper-1", "nova-2"], # OpenAI Whisper or Deepgram Nova success_when=lambda text: len(text) > 20 ) result = router.transcribe(audio_bytes, audio_duration_seconds=30.0) print(result.text) # transcribed text
Auto-instrumentation: ElevenLabs and Deepgram SDKs are patched automatically on import kalibr. All TTS/STT calls are traced with cost tracking (per-character for TTS, per-second for STT).
Voice agent frameworks
from kalibr_voice import KalibrLiveKitInstrumentor, KalibrPipecatInstrumentor KalibrLiveKitInstrumentor().instrument() # LiveKit Agents pipeline KalibrPipecatInstrumentor().instrument() # Pipecat processors
Required env vars: OPENAI_API_KEY for Whisper/TTS-1 / ELEVENLABS_API_KEY for ElevenLabs / DEEPGRAM_API_KEY for Deepgram
Voice AI (ElevenLabs, Deepgram, OpenAI Audio)
Route TTS and STT calls across providers using router.synthesize() and router.transcribe(). Same outcome-based learning loop as text routing.
Install
pip install kalibr[voice] # ElevenLabs + Deepgram pip install kalibr[elevenlabs] # ElevenLabs only pip install kalibr[deepgram] # Deepgram only
TTS routing
import kalibr
from kalibr import Router
# Route between ElevenLabs and OpenAI TTS
router = Router(
goal="narrate",
paths=["eleven_multilingual_v2", "tts-1"],
success_when=lambda audio: len(audio) > 0,
)
result = router.synthesize("Hello, welcome to Kalibr.", voice="alloy")
audio_bytes = result.audio
# result.cost_usd, result.model, result.kalibr_trace_id
STT routing
import kalibr from kalibr import Router # Route between OpenAI Whisper and Deepgram Nova router = Router( goal="transcribe_calls", paths=["whisper-1", "nova-2"], success_when=lambda text: len(text) > 10, ) result = router.transcribe(audio_bytes, audio_duration_seconds=30.0) transcript = result.text # result.cost_usd, result.kalibr_trace_id
Voice agent frameworks
from kalibr_voice import KalibrLiveKitInstrumentor, KalibrPipecatInstrumentor KalibrLiveKitInstrumentor().instrument() # LiveKit Agents pipeline KalibrPipecatInstrumentor().instrument() # Pipecat processors
Install: pip install kalibr[livekit] or pip install kalibr[pipecat]
Provider detection (automatic from model prefix):
- tts-1, tts-1-hd, whisper-1 -- OpenAI Audio
- eleven_* -- ElevenLabs (requires ELEVENLABS_API_KEY)
- nova-*, aura-*, enhanced, base -- Deepgram (requires DEEPGRAM_API_KEY)
When to Use as_langchain() vs get_policy()
| Method | Use When |
|---|---|
| as_langchain() | Framework expects a LangChain LLM (CrewAI, LangChain chains) |
| get_policy() | You need the model name to pass to another SDK |
| router.completion() | Direct text LLM calls without a framework |
| router.execute() | Any HuggingFace task (transcription, image gen, embeddings, etc.) |
Claude Code Plugin
The Kalibr Claude Code plugin instruments your project automatically from within Claude Code.
Install
/plugin add kalibr
Instrument an existing project
/kalibrize
This scans all Python files for bare OpenAI, Anthropic, LangChain, and CrewAI calls, shows each call with a proposed Router replacement, and applies changes with your approval.
What it does automatically
- Injects Kalibr context so Claude Code generates Router-based code when building agents
- Adds kalibr to requirements.txt
- Adds KALIBR_API_KEY and KALIBR_TENANT_ID to .env.example
Claude Managed Agents
Running your agent on Anthropic's Claude Managed Agents platform? Kalibr works inside Managed Agents containers via auto-instrumentation or native MCP integration.
- Auto-instrumentation: Add kalibr to container packages + import kalibr before any SDK import. Every LLM call is instrumented automatically.
- MCP native: Add Kalibr as an MCP server at kalibr-mcp.fly.dev/mcp. Your agent gets get_policy, report_outcome, decide, and more as first-class tools.
Full Claude Managed Agents integration guide →
run_pipeline: server-side execution
The primary MCP tool for non-SDK integrations. Claude or any MCP host calls run_pipeline to execute a pipeline step server-side. Kalibr handles routing, structural eval, prompt variant retry on failure, and model swap healing, the caller just gets the result.
run_pipeline(
goal="summarization",
messages=[{"role": "user", "content": "Summarize: ..."}]
)
# Returns: result, model_used, healed, heal_count, models_tried, latency_msBefore using run_pipeline: add your provider API keys in Settings → Provider Keys at dashboard.kalibr.systems. Without stored keys, model calls will fail.
Next
- Claude Managed Agents. Container + MCP integration
- API Reference. Full Router API
- Production Guide. Error handling, monitoring