How to hit the Azure OpenAI API

Azure OpenAI's v1 API lives at https://<resource>.openai.azure.com/openai/v1 and no longer needs an api-version parameter. model is your deployment name, not the model's name.

Authentication

Copy a key from your Azure OpenAI resource's Keys and Endpoint page and send it as the api-key header. In the examples it's written {{AZURE_OPENAI_API_KEY}}; {{AZURE_RESOURCE}} is your resource name.

Full reference: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/api-version-lifecycle

Responses API

curl -X POST https://{{AZURE_RESOURCE}}.openai.azure.com/openai/v1/responses \
  -H "api-key: {{AZURE_OPENAI_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"model": "{{DEPLOYMENT_NAME}}", "input": "This is a test"}'
Run in PostTaco

Chat completion

curl -X POST https://{{AZURE_RESOURCE}}.openai.azure.com/openai/v1/chat/completions \
  -H "api-key: {{AZURE_OPENAI_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"model": "{{DEPLOYMENT_NAME}}", "messages": [{"role": "user", "content": "Hello"}]}'
Run in PostTaco