PHPackages                             ubxty/azure-ai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ubxty/azure-ai

ActiveLibrary[API Development](/categories/api)

ubxty/azure-ai
==============

Azure OpenAI integration for Laravel — chat, streaming, multi-key rotation, cost tracking.

1.0.0(1mo ago)010MITPHPPHP ^8.2

Since Apr 18Pushed 1mo agoCompare

[ Source](https://github.com/ubxty/azure-ai)[ Packagist](https://packagist.org/packages/ubxty/azure-ai)[ RSS](/packages/ubxty-azure-ai/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (10)Versions (2)Used By (0)

ubxty/azure-ai
==============

[](#ubxtyazure-ai)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5285323b976a7c3f6875089297c038c5d1981caf732b6c6c71b9494d7fe86d53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75627874792f617a7572652d61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ubxty/azure-ai)[![License](https://camo.githubusercontent.com/2e0702b232e210a7fa08222af7a1ff0be37813e0cfd24c359e96f3115360a6e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f75627874792f617a7572652d61692e7376673f7374796c653d666c61742d737175617265)](LICENSE)

**Azure OpenAI integration for Laravel.** Chat, multi-turn conversations, streaming, multi-key rotation, model syncing, cost tracking, and powerful CLI tools — all built on `ubxty/core-ai`.

---

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12
- An [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service) resource with at least one deployment

---

Installation
------------

[](#installation)

```
composer require ubxty/azure-ai
```

Publish the config file:

```
php artisan vendor:publish --tag=azure-ai-config
```

Run the migrations:

```
php artisan migrate
```

---

Configuration
-------------

[](#configuration)

Add the following to your `.env`:

```
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_API_VERSION=2024-10-21
AZURE_OPENAI_DEFAULT_MODEL=gpt-4o
```

For multi-key rotation, publish the config and define multiple keys under `connections.default.keys`.

---

Usage
-----

[](#usage)

### Facade

[](#facade)

```
use Ubxty\AzureAi\Facades\Azure;

// Single-turn invocation
$result = Azure::invoke(
    modelId: 'gpt-4o',
    systemPrompt: 'You are a helpful assistant.',
    userMessage: 'Explain recursion in simple terms.',
);

echo $result['response'];
echo $result['cost']; // in USD
```

### Multi-turn conversation

[](#multi-turn-conversation)

```
use Ubxty\AzureAi\Facades\Azure;

$result = Azure::converse(
    modelId: 'gpt-4o',
    messages: [
        ['role' => 'user', 'content' => 'What is the capital of France?'],
        ['role' => 'assistant', 'content' => 'Paris.'],
        ['role' => 'user', 'content' => 'And Germany?'],
    ],
    systemPrompt: 'You are a geography expert.',
);
```

### Streaming

[](#streaming)

```
Azure::stream(
    modelId: 'gpt-4o',
    messages: [['role' => 'user', 'content' => 'Tell me a story.']],
    onChunk: function (string $chunk) {
        echo $chunk;
        ob_flush();
    },
);
```

### ConversationBuilder

[](#conversationbuilder)

```
use Ubxty\AzureAi\Facades\Azure;

Azure::conversation()
    ->model('gpt-4o')
    ->system('You are a helpful assistant.')
    ->user('What is PHP?')
    ->send();
```

---

Artisan Commands
----------------

[](#artisan-commands)

CommandDescription`azure:chat`Interactive multi-turn chat session in the terminal`azure:configure`Interactive wizard to write Azure credentials to `.env``azure:models`List available deployments grouped by model family`azure:test`Run a test invocation and display response, tokens, and cost`azure:default-model`Set the default chat/image model in `.env`---

Events
------

[](#events)

EventFired when`AzureInvoked`After every successful invocation`AzureKeyRotated`When a rate-limited key is rotated out`AzureRateLimited`When all keys are rate-limited---

Health Check
------------

[](#health-check)

Enable the built-in health check endpoint in your config:

```
'health_check' => [
    'enabled' => true,
    'path' => '/health/azure-openai',
    'middleware' => ['auth:sanctum'],
],
```

---

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md).

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance90

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

52d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e2de529037b10593205d6c41aa1d5331ef027e398489b74355b6d222ac10f2f1?d=identicon)[ubxty](/maintainers/ubxty)

---

Top Contributors

[![ravdeepsingh22](https://avatars.githubusercontent.com/u/13014642?v=4)](https://github.com/ravdeepsingh22 "ravdeepsingh22 (1 commits)")

---

Tags

laravelaistreamingopenaiazuregptChatGpt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ubxty-azure-ai/health.svg)

```
[![Health](https://phpackages.com/badges/ubxty-azure-ai/health.svg)](https://phpackages.com/packages/ubxty-azure-ai)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.4k](/packages/larastan-larastan)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M120](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76318.2M110](/packages/laravel-mcp)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
