Triage SDK — security-focused observability for AI agents
Project description
Triage Python SDK
Security-focused observability for AI agents. Automatically captures LLM traces with security context for 37+ providers including OpenAI, Anthropic, Cohere, Bedrock, and more.
Installation
pip install triage-sdk
Quick Start
import triage_sdk
triage_sdk.init(api_key="tsk_...")
# That's it — all LLM calls are now automatically traced.
# Optionally, annotate traces with application context:
triage_sdk.set_user(user_id="user_123", role="admin")
triage_sdk.set_tenant(tenant_id="org_456", name="Acme Corp")
Configuration
init() Parameters
triage_sdk.init(
api_key="tsk_...", # Required (or set TRIAGE_API_KEY env var)
app_name="my-agent", # Identifies your application
environment="production", # e.g. development, staging, production
endpoint="https://...", # Triage API endpoint (default: https://api.triageai.dev)
enabled=True, # Kill switch to disable tracing
trace_content=True, # Capture prompt/completion content
instruments={...}, # Allowlist specific LLM providers
block_instruments={...}, # Blocklist specific LLM providers
)
All parameters except api_key have sensible defaults. Configuration resolves in order: explicit argument > environment variable > default.
Environment Variables
| Variable | Description | Default |
|---|---|---|
TRIAGE_API_KEY |
API key for trace ingestion | required |
TRIAGE_ENDPOINT |
Triage API endpoint URL | https://api.triageai.dev |
TRIAGE_APP_NAME |
Application name | Inferred from sys.argv[0] |
TRIAGE_ENVIRONMENT |
Environment tag | development |
TRIAGE_ENABLED |
Enable/disable SDK (true/false) |
true |
TRIAGE_TRACE_CONTENT |
Capture prompt/completion content | true |
Context Helpers
Annotate your traces with application-level metadata. Context propagates automatically to all subsequent LLM calls in the current execution context (thread-safe and async-safe).
set_user — User Identity
triage_sdk.set_user(user_id="user_123", role="admin")
set_tenant — Organization/Tenant
triage_sdk.set_tenant(tenant_id="org_456", name="Acme Corp")
set_session — Conversation Session
triage_sdk.set_session(
session_id="sess_789",
turn_number=3,
history_hash="abc123",
)
set_input — User Input
triage_sdk.set_input(
raw="What's my SSN?",
sanitized="What's my [REDACTED]?",
)
set_template — Prompt Template
triage_sdk.set_template(template_id="summarize-v2", version="1.3")
set_chunk_acls — Retrieved Chunk Access Control
triage_sdk.set_chunk_acls([
{"chunk_id": "c1", "source": "internal-docs", "clearance": "confidential"},
])
Scoped Context
Use triage_sdk.context() to set context for a specific block. Previous context is automatically restored on exit, and unset fields inherit from the outer scope:
triage_sdk.set_user(user_id="user_123")
with triage_sdk.context(tenant_id="org_456"):
# user_id="user_123" is still active here
call_llm(...) # traced with both user and tenant
# tenant_id is no longer active here
call_llm(...) # traced with only user
Shutdown
The SDK registers an atexit handler to flush pending spans automatically. You can also shut down manually:
triage_sdk.shutdown()
Requirements
- Python 3.10+
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 triage_sdk-0.1.0.tar.gz.
File metadata
- Download URL: triage_sdk-0.1.0.tar.gz
- Upload date:
- Size: 178.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10d15f49d463311123999a141822a43db5bc520efa0c3fec194418b0057dca71
|
|
| MD5 |
11a2b92f3003f0f9a68a1e24fa67dd74
|
|
| BLAKE2b-256 |
80d6b786817c6fc48de2a81829908809ed25e81c5d74543534940db1514035f1
|
File details
Details for the file triage_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: triage_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c730ed6d72f35d97a6a4bc625d9d39b8262df89efe325044abbf33e2d1eab12c
|
|
| MD5 |
707b66d1100764de689bcc5468ccd97c
|
|
| BLAKE2b-256 |
d010e33de5d83220e493b66204eae5968223cdb8329cf998d46eb45a441dedcf
|