Reference · API
Azure OpenAI chat completions
Last updated
Run **OpenAI-compatible chat** on Microsoft Azure — enterprise SSO, private networking, and regional deployment.
Run **OpenAI-compatible chat** on Microsoft Azure — enterprise SSO, private networking, and regional deployment.
#When to use
Same message shape as OpenAI chat completions; URL and auth differ.
#Endpoint (pattern)
POST https://{resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version=2024-02-15-preview`deployment` is your Azure **deployment name**, not always the raw model name.
#Headers
api-key: $AZURE_OPENAI_API_KEY
Content-Type: application/jsonOr Azure AD bearer token when using managed identity.
#Request shape (sketch)
{
"messages": [
{"role": "system", "content": "You are concise."},
{"role": "user", "content": "Explain vectors simply."}
],
"temperature": 0.2,
"max_tokens": 512,
"stream": false
}#Python sketch
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint="https://YOUR_RESOURCE.openai.azure.com",
api_key="...",
api_version="2024-02-15-preview",
)
resp = client.chat.completions.create(
model="YOUR_DEPLOYMENT_NAME",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)#Common pitfalls
| Pitfall | Fix |
|---------|-----|
| Using public OpenAI base URL | Point SDK at `azure_endpoint` + deployment |
| Confusing deployment vs model name | Create deployment in Azure portal; use that ID |
| Stale `api-version` | Pin version in config; test on upgrade |
| Streaming without SSE proxy | Same server-side streaming rules as OpenAI |