Skip to content

Commit b4bf925

Browse files
committed
change page
1 parent bdce0bc commit b4bf925

File tree

2 files changed

+46
-50
lines changed

2 files changed

+46
-50
lines changed

integrations/agents/openai-agents.mdx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,52 @@ Portkey provides access to over 200 LLMs through a unified interface, including:
819819
See the full list of LLM providers supported by Portkey
820820
</Card>
821821

822+
### 8. Tracing
823+
824+
Portkey provides an opentelemetry compatible backend to store and query your traces.
825+
826+
You can trace your OpenAI Agents using any OpenTelemetry compatible tracing library.
827+
828+
Here is an example of how to trace your OpenAI Agents using the [`logfire`](/integrations/tracing/logfire) library from Pydantic:
829+
830+
```python Python
831+
import logfire
832+
from pydantic import BaseModel
833+
from agents import Agent, Runner, function_tool
834+
import asyncio
835+
import os
836+
837+
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://api.portkeydev.com/v1/logs/otel"
838+
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"x-portkey-api-key={YOUR_PORTKEY_API_KEY}"
839+
840+
class Weather(BaseModel):
841+
city: str
842+
temperature_range: str
843+
conditions: str
844+
845+
@function_tool
846+
def get_weather(city: str) -> Weather:
847+
return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind.")
848+
849+
agent = Agent(
850+
name="Hello world",
851+
instructions="You are a helpful agent.",
852+
tools=[get_weather]
853+
)
854+
855+
async def main():
856+
logfire.configure(
857+
service_name='my_agent_service',
858+
send_to_logfire=False,
859+
)
860+
logfire.instrument_openai_agents()
861+
result = await Runner.run(agent, input="What's the weather in Tokyo?")
862+
print(result.final_output)
863+
864+
if __name__ == "__main__":
865+
asyncio.run(main())
866+
```
867+
822868

823869
## Tool Use in OpenAI Agents
824870

integrations/libraries/openai-agents.mdx

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)