Cloud
Azure OpenAI
OpenAI models on your own Azure resource.
Quick start
import polygate response = polygate.chat( provider="azure", base_url="...", model="your-deployment-name", messages=[{"role": "user", "content": "Say hi in one word."}],) print(response.content) # "Hi!"print(response.usage) # Usage(prompt_tokens=..., completion_tokens=...)Names
Any of these work as provider. They all reach the same adapter, so pick whichever reads best in your code.
azureazure_openaiConfiguration
| Variable | Holds |
|---|---|
| AZURE_OPENAI_API_KEY | your API key |
| AZURE_OPENAI_ENDPOINT | your resource host, e.g. https://my-resource.openai.azure.com |
| AZURE_OPENAI_API_VERSION | overrides the pinned default |
Any of these may hold a comma-separated list. polygate rotates across them, parks a rate-limited one for its Retry-After, and drops one the provider rejects — so a key pool is configuration, not code.
Endpoint
There is no fixed host: the URL contains your own account, workspace or project, so base_url is required. Omit it and polygate raises MissingEndpointError naming the variable to set, rather than letting the request fail somewhere less informative.
Models
Examples that work today. Model names change; the provider's own list is the authority.
your-deployment-nameThings worth knowing
- The `model` is your deployment name, not a vendor model id. Your deployment can be called anything, so
model: "gpt-4o"only works if you named the deploymentgpt-4o. - The key goes in an
api-keyheader, not as a Bearer token. Sending a Bearer token returns a 401 that is indistinguishable from a wrong key — polygate handles this for you. - An
api-versionquery parameter is mandatory; omitting it is a 404. polygate pins a known-good version rather than tracking latest, because Azure's versions change model behaviour and a drifting default would turn a library upgrade into a silent change in output.
Batch
Azure OpenAI has no offline batch API. To run many requests at once, use map_chat — full price, but it works everywhere and returns in seconds. See Batching & concurrency.