Current collected state Current
Observed since 20 Oct, 23:17 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Python SDK for AgentScope — AI Agent Observability with OpenTelemetry
Python SDK for AgentScope -- AI Agent Observability.
pip install agentscope-otel
from agentscope_otel import AgentScope
# Initialize once at startup (3 lines!)
scope = AgentScope.init(
endpoint="http://localhost:3001",
project_id="my-project",
)
# Use decorators for automatic span management
@scope.wrap_agent("my-agent", agent_name="researcher", agent_task="Answer questions")
async def run_agent(question: str):
# Nested tool call -- auto-linked via context propagation
with scope.trace_tool("web-search") as span:
results = await search(question)
# LLM call with auto token tracking
@scope.wrap_llm_call("generate", model="claude-sonnet-4-5")
async def call_llm(prompt):
return await llm.complete(prompt) # should have input_tokens, output_tokens attrs
return await call_llm(f"Summarize: {results}")
# Run and clean up
import asyncio
asyncio.run(run_agent("What is AgentScope?"))
scope.flush()
scope = AgentScope.init(
endpoint="http://localhost:3001",
project_id="my-project",
tenant_id="default", # optional
api_key="sk-...", # optional
service_name="my-service", # optional
debug=True, # optional
)
@scope.wrap_agent("name", agent_name="...", agent_task="...")
@scope.wrap_tool("name", agent_name="...")
@scope.wrap_step("name")
@scope.wrap_llm_call("name", model="claude-sonnet-4-5")
with scope.trace_agent("name") as span:
...
with scope.trace_tool("name") as span:
...
with scope.trace_step("name") as span:
...
span = scope.create_agent_span("name", agent_name="...")
# ... work ...
span.end()
llm_span = scope.create_llm_span("name", model="claude-sonnet-4-5")
# ... call LLM ...
scope.end_llm_span(llm_span, LLMResult(input_tokens=100, output_tokens=50))
from agentscope_otel import calculate_cost, MODEL_PRICING
cost = calculate_cost("claude-sonnet-4-5", input_tokens=1000, output_tokens=500)
| Model | Input (cents/1M tokens) | Output (cents/1M tokens) |
|---|---|---|
| gpt-4o | 250 | 1000 |
| gpt-4o-mini | 15 | 60 |
| claude-sonnet-4-5 | 300 | 1500 |
| claude-haiku-4-5 | 80 | 400 |
| claude-opus-4-6 | 1500 | 7500 |
| gemini-2.0-flash | 10 | 40 |
session -- Top-level session groupingagent_run -- Agent executionstep -- Generic step within an agenttool_call -- Tool invocationllm_call -- LLM API callsub_agent -- Nested agent invocationA runnable quickstart is included in examples/quickstart.py:
python examples/quickstart.py
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.2.1 | 7 May 2026 | 6 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 23:17 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:c1bd89e17aec76fe3c5dd2c961a3c42e9dd04c44f3c69c107b199b44fc41ceed