Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging in the Open AI python library

Tags:

openai-api

I am using the open-ai python library. How can I enable logging of HTTP request/response/headers for all calls made to open-ai?

I am not able to find anything specific in the API docs.

like image 372
codesalsa Avatar asked Jun 14 '26 09:06

codesalsa


1 Answers

You can enable debug logging through an environment variable:

export OPENAI_LOG=debug

Note that this also enables httpx logging. If you want to log response data, you'll need to customize the http_client (example here)

like image 150
iloveitaly Avatar answered Jun 18 '26 00:06

iloveitaly