Python SDK for Agent OS — AI agent observability platform
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentos_python-0.1.0.tar.gz.
File metadata
- Download URL: agentos_python-0.1.0.tar.gz
- Upload date:
- Size: 399.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83d8209b8175147dced306da14892e90ccaf14977715f1ee4383798b26e23705
|
|
| MD5 |
c0be0221d43dea19b628870208ceba02
|
|
| BLAKE2b-256 |
81ab2759e8747729bf1e8cd6cd8f9e91e696d0a3b7d8194138e5d3ac8b81fee3
|
Provenance
The following attestation bundles were made for agentos_python-0.1.0.tar.gz:
Publisher:
publish.yml on Amitabh1998/agentos-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentos_python-0.1.0.tar.gz -
Subject digest:
83d8209b8175147dced306da14892e90ccaf14977715f1ee4383798b26e23705 - Sigstore transparency entry: 1258492343
- Sigstore integration time:
-
Permalink:
Amitabh1998/agentos-python@c4c6b88bb7e365eab21d17cb477e4edb9b1710dc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Amitabh1998
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4c6b88bb7e365eab21d17cb477e4edb9b1710dc -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentos_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentos_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5fd8eb8676cb20516ad1d21d127c46dbb2acc9d6afd5aa2a7b2d18e3d8481a2
|
|
| MD5 |
14dec21824d6f156a44c52fe9d71ef8d
|
|
| BLAKE2b-256 |
772f9d3d659d46d9808cd429328b3e34ee6cf55e4e74868af7df00c09ce288c0
|
Provenance
The following attestation bundles were made for agentos_python-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Amitabh1998/agentos-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentos_python-0.1.0-py3-none-any.whl -
Subject digest:
e5fd8eb8676cb20516ad1d21d127c46dbb2acc9d6afd5aa2a7b2d18e3d8481a2 - Sigstore transparency entry: 1258492346
- Sigstore integration time:
-
Permalink:
Amitabh1998/agentos-python@c4c6b88bb7e365eab21d17cb477e4edb9b1710dc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Amitabh1998
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4c6b88bb7e365eab21d17cb477e4edb9b1710dc -
Trigger Event:
push
-
Statement type: