Azure OpenAI (gateway)
Azure OpenAI (gateway)
To route Azure OpenAI through the Respan gateway, switch from the AzureOpenAI client to the standard OpenAI client. It is a small, mechanical change: the request and response shapes are identical (both classes live in the same openai package), so only the constructor changes.
The stock AzureOpenAI client cannot point at the Respan gateway. It always rewrites the path to .../deployments/{model}/chat/completions, which the gateway’s OpenAI-compatible router (/api/chat/completions) does not serve, so every request 404s. Use the OpenAI client instead, as shown below.
Migrate from AzureOpenAI to OpenAI
What changes
Nothing else in your call sites changes.
Fallback to another provider
The gateway can fail over automatically. This is the common Azure-primary, Claude-fallback setup:
Switch models
Change model to another Azure deployment or to any other model configured for your Respan gateway account.
See the full model list.
Escape hatch: keep the AzureOpenAI client
Prefer the migration above. Use this only if you genuinely cannot change your AzureOpenAI(...) call sites. It overrides a private method of the openai SDK (_build_request / buildRequest), so it is fragile across SDK versions — pin your openai version and re-test after any major upgrade.
Subclass the Azure client to skip its /deployments/{model} path rewrite, and send auth as a bearer token (the router does not accept the Azure api-key header):