Staso Docs
Python SDK

Setup

pip install staso                   # core
pip install "staso[anthropic]"      # + Anthropic auto-instrument
pip install "staso[openai]"         # + OpenAI auto-instrument
pip install "staso[all]"            # both

Python 3.11+. Get an API key from Settings -> API Keys.

Initialize

Call st.init() once at process start. Everything else has a default.

import staso as st

st.init(api_key="ak_...", agent_name="my-agent")

Signature

st.init(
    *,
    api_key: str | None = None,
    agent_name: str | None = None,
    base_url: str | None = None,
    batch_size: int = 100,
    flush_interval: float = 5.0,
    max_queue_size: int = 10_000,
    enabled: bool = True,
    debug: bool | None = None,
    environment: str | None = None,
    workspace_slug: str | None = None,
    capture_messages: bool = True,
    capture_git: bool = True,
) -> Client
NameDefaultPurpose
api_keySTASO_API_KEYRequired.
agent_nameSTASO_AGENT_NAMERequired. Default for code outside @st.agent.
base_urlhttps://api.staso.aiOverride for self-hosted.
batch_size100Spans per flush batch.
flush_interval5.0Seconds between background flushes.
max_queue_size10_000Backpressure cap. Excess spans are dropped.
enabledTrueFalse makes the SDK a no-op.
debugSTASO_DEBUGVerbose SDK logs.
environmentSTASO_ENVIRONMENT / "default"prod, staging, etc.
workspace_slugSTASO_WORKSPACE_SLUG / "default"Target workspace.
capture_messagesTrueRecord LLM message content. False to redact.
capture_gitTrueAuto-detect commit, branch, repo.

All env var fallbacks are listed in the environment variables reference.

Disable in development

st.init(api_key="ak_...", agent_name="my-agent", enabled=os.getenv("ENV") != "dev")

Tune batching

Raise batch_size for high-volume agents. Lower flush_interval for short-lived workloads. Raise max_queue_size if you see drop warnings.

st.init(
    api_key="ak_...",
    agent_name="my-agent",
    batch_size=500,
    flush_interval=2.0,
    max_queue_size=50_000,
)

Redact payloads

  • capture_messages=False — stops recording LLM message content.
  • capture_input=False / capture_output=False on any decorator — per-function control.

Disable git capture

st.init(api_key="ak_...", agent_name="my-agent", capture_git=False)

See git tracking for what gets attached and how to override in containers.

Shutdown

st.shutdown()

Registered via atexit, so you rarely need to call it. Use it in short-lived scripts or serverless handlers.

Next