Most observability tools sit above the model client. Keep your tracing setup the same, then point the underlying OpenAI-compatible or Anthropic-compatible client at AI Stats.
Langfuse with OpenAI SDK
pip install langfuse openai
import os
from langfuse.openai import openai
client = openai.OpenAI(
api_key=os.environ["AI_STATS_API_KEY"],
base_url="https://api.phaseo.app/v1",
)
response = client.responses.create(
model="openai/gpt-5-nano",
input="Reply with only: ok",
)
LangSmith with LangChain
Use the LangChain setup and enable LangSmith through the usual LangChain environment variables:
export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY="your_langsmith_key"
export AI_STATS_API_KEY="your_ai_stats_key"
OpenTelemetry
If your framework emits OpenTelemetry spans, AI Stats does not require a special exporter. Add useful request context yourself:
- model id
- endpoint, such as
responses or chat.completions
- AI Stats request id from response metadata or logs
- selected provider when response metadata is enabled
Notes
- Do not send AI Stats API keys to observability tools as attributes.
- If the observability library wraps the OpenAI SDK, configure the wrapped client with
base_url: "https://api.phaseo.app/v1".
- For LangChain traces, pair the tracing callback with the AI Stats
ChatOpenAI configuration.
Last modified on June 11, 2026