Skip to content

Azure OpenAI ​

OpenAI-compatible capabilities hosted inside your Azure subscription. Use it when data must stay in your Azure tenant or when you already manage Azure OpenAI deployments. Unlike the public OpenAI provider, every model reference is a deployment name you created in the Azure portal — the public model id never appears in calls.

Capabilities ​

Text with streaming, image generation, and embeddings, plus file storage and file-backed stores. Provider tools: code execution, file search, tool search, and web search (details).

Configuration ​

Configure via environment variables. config/ai.php only forwards them with env() — set the values in .env or the host environment, never hardcode keys in the config file.

php
// In config/ai.php
return [
    'Ai' => [
        'providers' => [
            'azure' => [
                'className' => 'Crustum\Ai\Providers\AzureOpenAiProvider',
                'key' => env('AZURE_OPENAI_API_KEY'),
                'url' => env('AZURE_OPENAI_URL'),
                'api_version' => env('AZURE_OPENAI_API_VERSION', '2025-04-01-preview'),
                'deployment' => env('AZURE_OPENAI_DEPLOYMENT', 'gpt-6-sol'),
                'image_deployment' => env('AZURE_OPENAI_IMAGE_DEPLOYMENT', 'gpt-image-2.5-flare'),
                'embedding_deployment' => env('AZURE_OPENAI_EMBEDDING_DEPLOYMENT', 'text-embedding-3-small'),
                'models' => [
                    'embeddings' => [
                        'dimensions' => (int)env('AZURE_OPENAI_EMBEDDINGS_DIMENSIONS', 1536),
                    ],
                ],
            ],
        ],
    ],
];
Config keyEnv varPurpose
className—Provider class. Keep the default unless subclassing.
key (apiKey also accepted)AZURE_OPENAI_API_KEYAzure resource key. Required.
urlAZURE_OPENAI_URLYour Azure OpenAI resource endpoint (e.g. https://<resource>.openai.azure.com/openai/deployments/...). Required — there is no public default.
api_versionAZURE_OPENAI_API_VERSIONAzure REST API version pinned to your resource. Keep the default unless Azure requires a newer one.
deploymentAZURE_OPENAI_DEPLOYMENTText/chat deployment name. Also serves the cheapest and smartest tiers for this provider.
image_deploymentAZURE_OPENAI_IMAGE_DEPLOYMENTImage deployment name.
embedding_deploymentAZURE_OPENAI_EMBEDDING_DEPLOYMENTEmbeddings deployment name.
models.embeddings.dimensionsAZURE_OPENAI_EMBEDDINGS_DIMENSIONSVector width of the embeddings deployment. Must match the deployed model.
headers— (config only)Extra HTTP headers merged into every request. Add as a plain array if needed.

Text tier note: unlike other providers, Azure reads all three text tiers from the single deployment key — set per-call model: to a deployment name to target a different deployment.

Notes ​

Every model reference is a deployment name you created in the Azure portal; the public model id never appears in calls.

See also ​

Released under the MIT License.