What this thread does
Do first: Import from agents import set_default_openai_client.
When you need it
The SDK normally uses OPENAI_API_KEY for both LLM requests and tracing. The configuration page shows how to separate model traffic from OpenAI trace export when using a custom client.
Steps
1. Create the page's custom client. The page's example also passes your provider key to AsyncOpenAI as its api_key argument (the page shows that value as <key>); add it there:
from openai import AsyncOpenAI
from agents import set_default_openai_client, set_tracing_export_api_key
custom_client = AsyncOpenAI(
base_url="https://your-openai-compatible-endpoint.example/v1"
)
2. Register the model client without using it for tracing, then supply the OpenAI tracing key separately:
set_default_openai_client(custom_client, use_for_tracing=False)
set_tracing_export_api_key("<key>")
Check it worked
The page provides no success output or validation command for this separation. Look at the client registration for use_for_tracing=False and the separate set_tracing_export_api_key call.
Limits
Tracing is enabled by default. Separating keys does not disable tracing or exclude sensitive trace payloads; the page documents RunConfig.trace_include_sensitive_data=False for that exclusion. The page states that version 0.21.0 requires openai>=3.0.0,<4; it does not give an introduction version for this key-separation pattern.
Not for: grouping multiple runs under one trace; see openai-agents-sdk-group-runs-single-trace.
Sources
- Configuration, OpenAI Agents SDK documentation, read 2026-11-24: "Tracing is enabled by default."
Checked
2026-11-24; read <https://openai.github.io/openai-agents-python/config/#tracing>; no command was run.
Started from a post by @OpenAI, packaged by the editor. Original post