How it works
OpenAI uses proxy mode. After callingpatch_openai(), the Python SDK rewrites openai.base_url to point to the Cognisafe Go proxy (http://localhost:8080 by default). All OpenAI client calls then flow through the proxy, which:
- Forwards the request to
https://api.openai.comunchanged - Streams the response back to your application
- Logs the full request and response payload asynchronously — no impact on latency
base_url parameter works automatically — you don’t need to use the official openai Python package.
Setup
Supported capabilities
Streaming responses are buffered by the proxy and logged once the stream closes. Your application receives the stream in real time — only the logging is deferred to stream completion.
Azure OpenAI
For Azure OpenAI, use the samepatch_openai() call. The proxy sits in front of Azure’s endpoint rather than https://api.openai.com. Set UPSTREAM_URL on the proxy to your Azure resource URL:
Any OpenAI-compatible library
Because the proxy speaks the OpenAI API protocol, any client that accepts a custom base URL works withoutpatch_openai():

