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]" # bothPython 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| Name | Default | Purpose |
|---|---|---|
api_key | STASO_API_KEY | Required. |
agent_name | STASO_AGENT_NAME | Required. Default for code outside @st.agent. |
base_url | https://api.staso.ai | Override for self-hosted. |
batch_size | 100 | Spans per flush batch. |
flush_interval | 5.0 | Seconds between background flushes. |
max_queue_size | 10_000 | Backpressure cap. Excess spans are dropped. |
enabled | True | False makes the SDK a no-op. |
debug | STASO_DEBUG | Verbose SDK logs. |
environment | STASO_ENVIRONMENT / "default" | prod, staging, etc. |
workspace_slug | STASO_WORKSPACE_SLUG / "default" | Target workspace. |
capture_messages | True | Record LLM message content. False to redact. |
capture_git | True | Auto-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=Falseon 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.