The Python SDK (Documentation Index
Fetch the complete documentation index at: https://docs.trulayer.ai/llms.txt
Use this file to discover all available pages before exploring further.
trulayer on PyPI) is the primary way to send traces to TruLayer from Python code. It supports manual tracing, auto-instrumentation of popular LLM clients, and async/sync usage patterns.
Install
Minimal usage
What’s included
| Import | Purpose |
|---|---|
trulayer.init(...) | Initialise the global client |
trulayer.trace(name) | Context manager for a trace |
trulayer.atrace(name) | Async variant |
trulayer.current_trace() | Get the active trace from async-local context |
trulayer.instrument_openai(client) | Auto-patch an OpenAI client |
trulayer.instrument_anthropic(client) | Auto-patch an Anthropic client |
trulayer.instrument_langchain() | Register a LangChain callback handler |
trulayer.TruLayerClient | Class for explicit multi-instance use |
trulayer.TraceData, SpanData, EventData, FeedbackData | Pydantic models |
Where to go next
Tutorial
Step-by-step: manual tracing → auto-instrumentation → async → feedback → production.
Configuration
Batch size, flush interval, sampling, PII scrubbing, debug mode.
Reference
Every public export, with signatures and examples.
Concepts
Understand the data model before going deep.