Skip to main content
Azure OpenAI uses a different endpoint shape than the standard OpenAI API: requests go to a per-deployment URL (/openai/deployments/{deployment-id}/chat/completions?api-version=...) rather than the canonical /v1/chat/completions. The Cognisafe proxy handles this transparently — it forwards the request to the upstream URL you configure, preserving the path and query string. The only change required in your application code is setting base_url to the Cognisafe proxy.

The insertion pattern

Replace the Azure OpenAI endpoint with your Cognisafe proxy URL in your SDK or HTTP client configuration. The proxy rewrites nothing — it forwards the full path, including the deployment name and api-version parameter, to the real Azure OpenAI endpoint configured as UPSTREAM_URL.

Environment variable mapping

The Cognisafe proxy does not strip or inspect the api-version query parameter. Whatever your SDK sends is forwarded verbatim to Azure OpenAI. You are responsible for using an api-version that your Azure OpenAI resource supports.

Python: Azure OpenAI SDK

The openai Python package supports Azure OpenAI via AzureOpenAI. Route it through Cognisafe by replacing azure_endpoint with the proxy URL and setting api_key to your PROXY_API_KEY.
The Cognisafe SDK’s patch_openai() function handles proxy routing automatically. For Azure OpenAI, set the standard Azure environment variables and configure the SDK before patching:

Azure OpenAI request path handling

Azure OpenAI endpoints follow this pattern:
The Cognisafe proxy preserves the path and query string. The effective forwarded URL is:
Set UPSTREAM_URL on the proxy deployment to your Azure OpenAI resource base URL — without a trailing slash and without the /openai/deployments/... path:

AAD token authentication (no static key)

Azure OpenAI supports authentication via Azure AD bearer tokens in addition to API keys. If your deployment policy prohibits static API keys on the Azure OpenAI resource, configure the proxy to use workload identity.

Proxy workload identity setup (AKS)

Enable workload identity on the proxy pod (see the AKS blueprint for the full setup). The proxy needs a managed identity with the Cognitive Services User role on the Azure OpenAI resource:
The proxy must then acquire an AAD token and inject it as the Authorization header on outbound requests to Azure OpenAI. The current Go proxy forwards the Authorization header from the incoming request. To use workload identity, implement token acquisition in the proxy using the Azure Identity SDK:
Workload identity eliminates the AZURE_OPENAI_API_KEY secret from your cluster entirely. Clients still authenticate to the Cognisafe proxy using PROXY_API_KEY; the proxy holds the credential for Azure OpenAI internally. This is the recommended pattern for enterprise deployments.

Private endpoint option

For zero-public-egress deployments, place both the Cognisafe proxy and the Azure OpenAI private endpoint in the same VNet. The proxy resolves <resource>.openai.azure.com via private DNS to the private endpoint IP — no traffic leaves the Microsoft backbone.
Full Terraform and NSG configuration is in the Private Endpoint Architecture blueprint.

Testing

Troubleshooting