-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we access request headers (OpenAI) ? #511
Comments
Sorry, are you asking to be able to set request headers or read response headers, or both? |
I think you can have a look with OpenAIModel from Pydantic Ai. That will solve your issue. |
@samuelcolvin I want to be able to READ response headers. @YanSte Thank you, in OpenAIModel documentation I see we can provide our own existing http_client, so I guess this is the way to do it ! |
If you want to observe the headers (and not use them in your application code), you can use the httpx instrumentation in logfire - https://logfire.pydantic.dev/docs/integrations/http-clients/httpx/ If you want to use the values at runtime, pass your own httpx client as @YanSte suggests. |
Thank you to both of you. I succeeded by following your advice: I created a custom AsyncClient class that I use as the http_client of my OpenAIModel. |
Hi, im wondering if pydantic-ai allows to access request response headers ?
OpenAI for example provides informations in headers like so:
Which I absolutely need in my app to be able to temporarily disable the Agent if we get close to the limits.
Is there a way to get this information ?
Thank you !
The text was updated successfully, but these errors were encountered: