## The problem
Issue pydantic/logfire#922 (closed, 14 comments): ### Description If I run this code with the correct ENV variables, it sends to logfire, but also has an error like this: ``` Tracing client error 401: { "error": { "message": "Incorrect API key provided: unused. You can find your API key at https://platform.openai.com/account/api-keys.", "type": "invalid_request_error", "param": null, "code": "invalid_api_key" } } ``` code ```python import os import httpx import logfire from agents import Agent, ModelSettings, OpenAIProvider, RunConfig, Runner, function_tool from agents.tracing import...
## The fix
'Tracing client error 401' when instrumenting openai-agents with logfire while using Ollama, Grok, or another OpenAI-emulating provider happens because logfire double-traces by default: it also sends to OpenAI's /traces/ingest endpoint, which those providers don't implement. Fix: avoid the extra OpenAI-side tracing when you only need logfire, since logfire already captures everything. The 401 is the provider rejecting the unknown endpoint, not a bad API key.
## Snippets from the thread
```
Tracing client error 401: {
"error": {
"message": "Incorrect API key provided: unused. You can find your API key at https://platform.openai.com/account/api-keys.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}
```
## Notes
Thread: https://github.com/pydantic/logfire/issues/922. Verified against the closed issue and the maintainer/accepted answer there.