Framework Integrations
Mantis SDK provides auto-instrumentation for popular AI frameworks via OpenInference (opens in a new tab). This section covers setup and usage for each supported framework.
OpenInference-Powered — mantisdk leverages the OpenInference instrumentation library, providing automatic tracing for all major AI/LLM frameworks with zero code changes.
Supported Frameworks
| Framework | Instrumentor | Status |
|---|---|---|
| Claude Code SDK | claude_code_sdk | Verified |
| DSPy | dspy | Verified |
| Anthropic | anthropic | Verified |
| Google ADK | google_adk | Verified |
| OpenAI | openai | Supported |
| OpenAI Agents SDK | openai_agents | Supported |
| LangChain | langchain | Supported |
| LlamaIndex | llama_index | Supported |
| LiteLLM | litellm | Supported |
| Groq | groq | Supported |
| Mistral | mistral | Supported |
| Instructor | instructor | Supported |
Quick Setup
1. Install Mantis SDK
pip install mantisdk2. Initialize and Instrument
import mantisdk.tracing as tracing
# Initialize tracing
tracing.init(service_name="my-agent", instrument_default=False)
# Instrument your framework
tracing.instrument(names=["your_framework"])3. Import Your Framework
# Import AFTER instrumentation
import your_framework
# Use normally - calls are auto-tracedCommon Pattern
All integrations follow this pattern:
#!/usr/bin/env python3
from dotenv import load_dotenv
load_dotenv()
# 1. Initialize tracing FIRST
import mantisdk.tracing as tracing
from mantisdk.tracing.exporters.insight import is_insight_configured
exporters = []
if is_insight_configured():
exporters.append(tracing.insight_exporter())
tracing.init(
service_name="framework-agent",
exporters=exporters if exporters else None,
instrument_default=False,
)
# 2. Instrument specific framework
tracing.instrument(names=["framework_name"])
# 3. NOW import the framework
import framework
# 4. Use the framework - auto-traced
def main():
with tracing.trace("workflow") as span:
# Framework calls are auto-instrumented
result = framework.do_something()
span.set_attribute(tracing.semconv.TRACE_OUTPUT, result)
# 5. Clean shutdown
if __name__ == "__main__":
try:
main()
finally:
tracing.shutdown()Combining Manual and Auto Tracing
Auto-instrumentation works alongside manual spans:
@tracing.trace
def my_workflow(query: str):
# Manual span
with tracing.span("preprocessing"):
prepared = preprocess(query)
# Auto-instrumented LLM call (child of my_workflow)
response = llm_client.generate(prepared)
# Manual span
with tracing.span("postprocessing"):
result = postprocess(response)
return resultEnvironment Variables
All integrations use the same Insight credentials:
# Insight (required for trace export)
INSIGHT_HOST=https://insight.withmetis.ai
INSIGHT_PUBLIC_KEY=pk-lf-your-public-key
INSIGHT_SECRET_KEY=sk-lf-your-secret-key
# Framework-specific API keys
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=...Direct Insight Ingestion (SDK)
Need to ingest externally generated traces or scores (for example from batch evaluators, CSV processors, or custom agent workers)? Use the dedicated SDK ingestion helper:
This path complements auto-instrumentation. Use auto-instrumentation for runtime tracing, and the ingestion helper for explicit trace/score submission from external pipelines.
Agent Tool Access (MCP)
Need Cursor, Claude Desktop, or another agent to inspect Insight data through tools? Use the Mantis MCP server:
The MCP server exposes read-only project, trace, score, and SQL analytics tools to MCP-compatible AI clients.