Skip to main content

Agent OS Python SDK

Python SDK for Agent OS — AI agent observability, experimentation, and security. "PostHog for AI Agents."

Install

pip install agentos

Quick Start

from agentos import wrap_openai
import openai

client = openai.OpenAI()
client = wrap_openai(client, api_key="aos_...", agent_id="my-agent")

# Every LLM call is now automatically traced
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)

That's it. Open your Agent OS dashboard to see traces, token usage, costs, and latency.

Other Ways to Instrument

@observe decorator (Langfuse-compatible)

from agentos import observe

@observe()
def my_agent(query: str) -> str:
    result = search(query)       # auto-traced as child span
    return summarize(result)     # auto-traced as child span

@observe(as_type="generation")
def summarize(text: str) -> str:
    return openai_client.chat.completions.create(...)

Manual event capture

from agentos import AgentOS

client = AgentOS(api_key="aos_...")

client.llm_call("my-agent", model="gpt-4o", system="openai", input_tokens=100, output_tokens=50)
client.tool_call("my-agent", tool_name="web-search", status="success", duration_ms=120)
client.eval("my-agent", eval_name="accuracy", score=0.95)
client.business_event("my-agent", event_name="task_completed")

client.flush()

Environment variable (zero-code)

export AGENTOS_API_KEY=aos_...
export AGENTOS_ENABLED=true
python my_agent.py

Framework Integrations

Framework Integration One-liner
OpenAI wrap_openai(client) from agentos import wrap_openai
Anthropic wrap_anthropic(client) from agentos import wrap_anthropic
LangChain AgentOSCallbackHandler from agentos.integrations.langchain import AgentOSCallbackHandler
LlamaIndex AgentOSCallbackHandler from agentos.integrations.llamaindex import AgentOSCallbackHandler
CrewAI @trace_crew / instrument_crewai() from agentos.integrations.crewai import trace_crew
Pydantic AI wrap_agent() / instrument_pydantic_ai() from agentos.integrations.pydantic_ai import wrap_agent
LiteLLM patch_litellm() from agentos.integrations.litellm import patch_litellm
OpenTelemetry OTLP SpanExporter from agentos.compat.otel import register

Migrating From Another Platform?

Change one import and keep your existing code:

Platform Migration
Langfuse from agentos.compat.langfuse import Langfuse
LangSmith from agentos.compat.langsmith import traceable
Arize Phoenix from agentos.compat.otel import register (swap endpoint)
Helicone from agentos.compat.helicone import get_proxy_config
Braintrust from agentos.compat.braintrust import traced, Eval
W&B Weave from agentos.compat.weave import op

Documentation

Full docs, guides, and API reference: docs.agentos.dev

License

MIT

Release files for agentos-python 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentos-python 0.1.0
File Size Uploaded
agentos_python-0.1.0.tar.gz 399.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentos-python 0.1.0
File Interpreter ABI Platform
agentos_python-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 437.4 kB

Release files / agentos_python-0.1.0.tar.gz

Download URL agentos_python-0.1.0.tar.gz
Size 399.4 kB
Tags Source
SHA-256 checksum
How to use checksums
83d8209b8175147dced306da14892e90ccaf14977715f1ee4383798b26e23705
BLAKE2b-256 checksum
How to use checksums
81ab2759e8747729bf1e8cd6cd8f9e91e696d0a3b7d8194138e5d3ac8b81fee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.

Transparency log

Release files / agentos_python-0.1.0-py3-none-any.whl

Download URL agentos_python-0.1.0-py3-none-any.whl
Size 38.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5fd8eb8676cb20516ad1d21d127c46dbb2acc9d6afd5aa2a7b2d18e3d8481a2
BLAKE2b-256 checksum
How to use checksums
772f9d3d659d46d9808cd429328b3e34ee6cf55e4e74868af7df00c09ce288c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page