This directory contains simplified examples demonstrating key features of the Gentrace Python SDK.
init_simple.py- Basic Gentrace initialization with default OpenTelemetry setupinit_manual_otel.py- Manual OpenTelemetry configuration when you need custom controlinit_with_instrumentation.py- Adding automatic HTTP instrumentation
openai_simple.py- Simple OpenAI integration with Gentrace tracingopenai_instrumentation.py- OpenAI with automatic OpenInference instrumentationopenai_agents_instrumentation.py- OpenAI Agents (Swarm) with OpenInference instrumentationanthropic_simple.py- Anthropic Claude integration examplepydantic_ai_simple.py- Simple Pydantic AI framework integration
eval_simple.py- Basic evaluation example using @eval decorator
# using rye (recommended)
rye sync --all-features
# using uv
cd ..
uv venv
source .venv/bin/activate
uv pip install ".[openai,openai-agents,anthropic,pydantic-ai]" -r requirements-dev.lock
cd examplesOption A: Use the provided .env file (recommended)
- Copy
.env.exampleto.env - Update the values with your API keys and configuration
Option B: Set environment variables manually
export GENTRACE_API_KEY="your-api-key"
export GENTRACE_BASE_URL="https://gentrace.ai/api" # or http://localhost:3000/api
export GENTRACE_PIPELINE_ID="your-pipeline-id"
export OPENAI_API_KEY="your-openai-key" # For OpenAI examples
export ANTHROPIC_API_KEY="your-anthropic-key" # For Anthropic examplespython init_simple.pyEach example focuses on one specific use case:
- Basic init examples show different ways to initialize Gentrace
- LLM examples demonstrate tracing AI model calls
- Evaluation examples show how to run experiments and evaluations
For more comprehensive documentation, see the Gentrace docs.