Skip to main content

Documentation Index

Fetch the complete documentation index at: https://langwatch.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

LangWatch integrates with PydanticAI through its built-in OpenTelemetry support to capture traces of agent runs and model interactions.

Installation

pip install langwatch pydantic-ai

Usage

The LangWatch API key is configured by default via the LANGWATCH_API_KEY environment variable.
Initialize LangWatch and create your PydanticAI agent. PydanticAI’s built-in OpenTelemetry support will automatically send traces to LangWatch.
from pydantic_ai import Agent
import langwatch

langwatch.setup()

agent = Agent(
    "openai:gpt-5",
    instructions="Be funny, but not too funny.",
)

if __name__ == "__main__":
    result = agent.run_sync("Tell me a joke")
    print(result.output)
LangWatch automatically captures all PydanticAI agent runs and model interactions through PydanticAI’s built-in OpenTelemetry support. Use @langwatch.trace() decorators to add custom traces and metadata as needed.