Azure AI Foundry¶
An openai-compat subclass carrying Azure's parameter renames and its two authentication
modes.
Setup with an API key¶
client = ai.Client([
ai.ProviderSettings.of(
"azure-foundry",
base_url="https://<resource>.services.ai.azure.com/openai/v1",
api_key="env://AZURE_AI_KEY",
),
])
result = client.generate(prompt, target="azure-foundry:gpt-5")
Setup with Entra¶
pip install "anyinfer[azure]"
az login
ai.ProviderSettings.of(
"azure-foundry",
base_url="https://<resource>.services.ai.azure.com/openai/v1",
# no api_key: DefaultAzureCredential is used
)
Aliases: azure, foundry.
Differences from vanilla openai-compat¶
| Azure | |
|---|---|
| Output-token parameter | max_completion_tokens |
| Reasoning effort | flat reasoning_effort field |
| Auth header | api-key, or Authorization: Bearer for Entra |
| API version | optional api-version query parameter |
Sending max_tokens to Azure is rejected outright, which is why the subclass exists.
API versions¶
ai.ProviderSettings.of("azure-foundry", base_url=..., api_version="2024-10-21")
Only needed for deployments that still require it; the newer /openai/v1 surface does not.
The parameter is applied per instance, so it cannot leak onto other adapters.
Troubleshooting¶
could not acquire an Entra token — run az login, or configure a service principal in
the environment. The error names the scope it tried.
azure-foundry requires the base URL of your Foundry resource — the resource endpoint
is deployment-specific and cannot be defaulted.
Wire contract¶
For the exact request/response fields this adapter depends on, see contracts/azure-foundry.md.