Skip to main content
The vouch-sdk package wraps OpenLLMetry auto-instrumentation and points it at your Trident project. One call to vouch_sdk.init() patches every LLM client loaded in your Python process — OpenAI, Anthropic, LangChain, CrewAI, LlamaIndex, Bedrock, VertexAI, Cohere, and more — and ships the resulting OpenTelemetry spans to app.usetrident.dev. PII redaction runs entirely inside your runtime before any trace data leaves, keeping emails, API keys, credit card numbers, and other sensitive values out of the wire.

Requirements

  • Python 3.10 or later
  • pip

Install

1

Install the base package

pip install vouch-sdk
The base package instruments OpenAI, Anthropic, LlamaIndex, Bedrock, VertexAI, Cohere, MCP, and the OpenAI Agents SDK out of the box.
2

Install optional framework extras (if needed)

Add the [langchain] extra to enable LangChain and CrewAI instrumentation:
pip install "vouch-sdk[langchain]"
ExtraInstallsEnables
langchainlangchain-core>=0.2,<1.0LangChain chains, agents, and CrewAI

Set your environment variables

Add your project keys from Settings → API Keys at app.usetrident.dev to your .env file or deployment secrets manager:
.env
TRIDENT_PROJECT_PUBLIC_KEY=pk-...
TRIDENT_PROJECT_SECRET_KEY=sk-...
The SDK also accepts the legacy VOUCH_PROJECT_PUBLIC_KEY / VOUCH_PROJECT_SECRET_KEY names for backwards compatibility.

Initialize Trident

Call vouch_sdk.init() once, before you create any LLM client. Every LLM call made after init() is automatically traced.
import vouch_sdk

vouch_sdk.init(
    agent_id="prod-rag-bot",  # optional — scopes spans to a named agent
)
When project_pk and project_sk are omitted, init() reads them from TRIDENT_PROJECT_PUBLIC_KEY / TRIDENT_PROJECT_SECRET_KEY automatically.

All options

ParameterTypeDefaultDescription
project_pkstrenvProject public key. Reads TRIDENT_PROJECT_PUBLIC_KEY.
project_skstrenvProject secret key. Reads TRIDENT_PROJECT_SECRET_KEY.
agent_idstrenvLogical agent identifier shown in the dashboard. Reads TRIDENT_AGENT_ID.
endpointstrhttps://app.tryvouch.aiOverride the Trident host. Reads TRIDENT_ENDPOINT.
agent_urlstrenvPublic HTTP endpoint for Red Team auto-targeting. Reads VOUCH_AGENT_URL.
app_namestragent_idOTel resource service.name. Falls back to "vouch-app".
disable_batchboolFalseEmit each span immediately. Useful for short-lived scripts.
instrumentssetNoneRestrict which traceloop instruments are activated.
redact_piibool | dictTrueEdge PII redaction. True uses the built-in rule set; pass {"rules": [...]} for custom rules; False disables.
**traceloop_kwargsExtra keyword arguments forwarded verbatim to Traceloop.init().

Full working example

The snippet below starts Trident tracing and makes a standard OpenAI chat completion. The call is traced automatically — no wrapping required.
import os
import vouch_sdk
from openai import OpenAI

# 1. Start tracing — do this before creating any LLM client.
vouch_sdk.init(
    agent_id="my-chat-agent",
    # project_pk and project_sk are read from env automatically
)

# 2. Create your LLM client exactly as you normally would.
client = OpenAI()  # picks up OPENAI_API_KEY from env

# 3. Make LLM calls — tracing is automatic.
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Summarise the Trident docs in one sentence."}],
)

print(response.choices[0].message.content)

LangChain example

Install the langchain extra, then call init() before building your chain:
import vouch_sdk
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

vouch_sdk.init(agent_id="langchain-agent")

llm = ChatOpenAI(model="gpt-4o")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant."),
    ("human", "{question}"),
])
chain = prompt | llm

result = chain.invoke({"question": "What is prompt injection?"})
print(result.content)
Every chain invocation, LLM call, and retrieval step is automatically captured as a nested OTel span in your Trident project.

Supported LLM frameworks

The SDK auto-instruments all of the following when they are imported in the same process:

OpenAI

Anthropic

LangChain

CrewAI

LlamaIndex

Amazon Bedrock

Google VertexAI

Cohere

MCP (Model Context Protocol)

OpenAI Agents SDK

LangChain and CrewAI require the [langchain] extra: pip install "vouch-sdk[langchain]".

PII redaction defaults

redact_pii=True is the default. Before any span attribute leaves your process, the SDK scans and replaces the following patterns with [REDACTED_<TYPE>] tokens:
  • EMAIL — email addresses
  • AWS_KEY — AWS access key IDs (AKIA…, ASIA…)
  • JWT — JSON Web Tokens
  • API_KEY — API keys (sk-…, sk-ant-…)
  • SSN — US Social Security Numbers (XXX-XX-XXXX)
  • CREDIT_CARD — credit card numbers (Luhn-validated)
  • IBAN — International Bank Account Numbers
  • IP — IPv4 addresses
  • PHONE — phone numbers
Pass redact_pii=False to disable, or redact_pii={"rules": [...]} to supply a custom list of PiiRule objects.

Next steps

Python SDK API Reference

Explore the full API: vouch_sdk.init(), firewall_headers(), redact_text(), redact_value(), and all configuration options.