Skip to content

Commit 32fe6cc

Browse files
Add tracing guide for non-OpenAI LLMs in docs/tracing.md (#1329)
- Updated docs/tracing.md. - Tested with mkdocs serve, code. --------- Co-authored-by: Kazuhiro Sera <[email protected]>
1 parent d520535 commit 32fe6cc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/tracing.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,34 @@ To customize this default setup, to send traces to alternative or additional bac
9797
1. [`add_trace_processor()`][agents.tracing.add_trace_processor] lets you add an **additional** trace processor that will receive traces and spans as they are ready. This lets you do your own processing in addition to sending traces to OpenAI's backend.
9898
2. [`set_trace_processors()`][agents.tracing.set_trace_processors] lets you **replace** the default processors with your own trace processors. This means traces will not be sent to the OpenAI backend unless you include a `TracingProcessor` that does so.
9999

100+
101+
## Tracing with Non-OpenAI Models
102+
103+
You can use an OpenAI API key with non-OpenAI Models to enable free tracing in the OpenAI Traces dashboard without needing to disable tracing.
104+
105+
```python
106+
import os
107+
from agents import set_tracing_export_api_key, Agent, Runner
108+
from agents.extensions.models.litellm_model import LitellmModel
109+
110+
tracing_api_key = os.environ["OPENAI_API_KEY"]
111+
set_tracing_export_api_key(tracing_api_key)
112+
113+
model = LitellmModel(
114+
model="your-model-name",
115+
api_key="your-api-key",
116+
)
117+
118+
agent = Agent(
119+
name="Assistant",
120+
model=model,
121+
)
122+
```
123+
124+
## Notes
125+
- View free traces at Openai Traces dashboard.
126+
127+
100128
## External tracing processors list
101129

102130
- [Weights & Biases](https://weave-docs.wandb.ai/guides/integrations/openai_agents)

0 commit comments

Comments
 (0)