Download the PHP package ikarolaborda/azure-openai-sdk-php without Composer
On this page you can find all versions of the php package ikarolaborda/azure-openai-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ikarolaborda/azure-openai-sdk-php
More information about ikarolaborda/azure-openai-sdk-php
Files in ikarolaborda/azure-openai-sdk-php
Package azure-openai-sdk-php
Short Description Azure OpenAI PHP SDK — first-class Azure OpenAI Service support built on top of openai-php/client
License MIT
Informations about the package azure-openai-sdk-php
Azure OpenAI SDK for PHP
A PHP package that brings first-class Azure OpenAI Service support to your applications. Built on top of openai-php/client — the excellent community-maintained PHP client created by Nuno Maduro and contributors.
This package handles Azure-specific deployment-based URL routing, API versioning, and authentication (API keys and Azure AD / Entra ID) so you can work with Azure OpenAI the same way you work with the standard OpenAI API.
Table of Contents
- Installation
- Configuration
- Laravel
- Standalone (non-Laravel)
- Usage
- Chat Completions
- Responses API
- Streaming
- Embeddings
- Multiple Deployments
- Account-Scoped Operations
- Authentication
- API Key
- Azure AD / Entra ID Token
- Azure AD Token Provider
- API Versions
- Available Resources
Installation
Requires PHP 8.2+
If your project doesn't already have a PSR-18 HTTP client, install one:
Configuration
Laravel
The package auto-discovers its service provider and facade. Publish the config file:
This creates config/azure-openai.php. Then add your credentials to .env:
Now you can use the facade anywhere in your application:
Or resolve the client from the container:
Standalone (non-Laravel)
Without Laravel, configure the client directly. Set your environment variables and call client() with no arguments:
Or pass parameters explicitly — any argument takes precedence over its environment variable:
For full control, use the factory:
If you prefer using the resource name instead of the full endpoint URL:
Usage
Because Azure routes requests based on the deployment name in the URL, you don't need to pass a model parameter in your calls — it's determined by the deployment you configured.
Chat Completions
Responses API
The Responses API is OpenAI's newest interface for generating model outputs. It works the same way as the Python client.responses.create():
With tools (web search, file search, or custom functions):
Streamed responses:
Streaming
Embeddings
Multiple Deployments
Each client targets a single deployment. If your application uses multiple models, create a client for each:
Account-Scoped Operations
Some Azure OpenAI operations — like listing models or managing files — don't require a deployment. You can omit the deployment for these:
Authentication
API Key
The most common method. Your key is sent via the api-key header:
Azure AD / Entra ID Token
For production workloads, Azure AD tokens are recommended over API keys:
Azure AD Token Provider
For long-running processes where tokens expire, pass a callable that fetches a fresh token on each request:
API Versions
Azure OpenAI requires an explicit API version on every request. The package provides an enum with known versions:
| Enum Case | Value |
|---|---|
V2024_06_01 |
2024-06-01 |
V2024_10_21 |
2024-10-21 |
V2025_01_01_PREVIEW |
2025-01-01-preview |
V2025_03_01_PREVIEW |
2025-03-01-preview |
Available Resources
This package gives you access to all resources provided by openai-php/client, routed through Azure's deployment-based endpoints. Deployment-scoped resources (chat, completions, embeddings, images, audio, responses) are automatically routed via /deployments/{deployment}/. Account-scoped resources (models, files, fine-tuning, assistants, threads, batches, vector stores, moderations) are routed directly under /openai/.
For full resource documentation, see the openai-php/client README.
Built with care by Ikaro C. Laborda. Licensed under the MIT license.
All versions of azure-openai-sdk-php with dependencies
illuminate/support Version ^11.0|^12.0|^13.0
openai-php/client Version ^0.19