Following the Haiku example and have everything working except for the tracing not working with this error message : OPENAI_API_KEY is not set, skipping trace export , seems like a bug ? I am loading env variables using dotenv which is the only difference from the example in the repo.
I have the same problem - always get the same message “OPENAI_API_KEY is not set, skipping trace export”
same problem here, even though the rest works fine
Traces are not visible but logs are visible.
from agents import set_tracing_export_api_key
set_tracing_export_api_key(os.getenv(“OPENAI_API_KEY”))
use these 2 lines in the code , the tracing will work
Is there another way to set the api_key for tracing?
I need to manage multiple api_keys with the same backend, so using set_tracing_export_api_key globally is not an option.
If you set up different projects with different API keys, you can build and deploy agents per project and the tracing will be applicable for triaging project based issues.
Thank you for your response.
The issue is that the same backend serves multiple clients (each with their own API key), so I cannot configure set_tracing_export_api_key at a global level, as requests from different clients may arrive simultaneously.
This is different from setting the API key on an instance (for example, using client = AsyncOpenAI(api_key=[api_key])).
I believe a possible solution would be the ability to specify an API key directly within the trace object.
I see , tracing per api key may be a hard problem to solve because currently across different systems/frameworks - OpenAI / LangChain/Google AI , tracing is associated with a project that allows debugging at the project level. Debugging at an API key level for evaluating how any agent performed a certain action may get tricky ?