PHPackages                             creativecrafts/laravel-ai-assistant - 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. creativecrafts/laravel-ai-assistant

ActiveLibrary[API Development](/categories/api)

creativecrafts/laravel-ai-assistant
===================================

A handy package to access and interact with OpenAi endpoint

2.1.8(1y ago)141.1k4[2 PRs](https://github.com/CreativeCrafts/laravel-ai-assistant/pulls)MITPHPPHP ^8.3|^8.2CI passing

Since Apr 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/CreativeCrafts/laravel-ai-assistant)[ Packagist](https://packagist.org/packages/creativecrafts/laravel-ai-assistant)[ Docs](https://github.com/creativecrafts/laravel-ai-assistant)[ RSS](/packages/creativecrafts-laravel-ai-assistant/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (65)Used By (0)

Laravel AI Assistant
====================

[](#laravel-ai-assistant)

[![Latest Version on Packagist](https://camo.githubusercontent.com/55e422d6cdbb644e56a6f6e73309a09e9880bce4e6df74afe15786c9bc3e1010/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63726561746976656372616674732f6c61726176656c2d61692d617373697374616e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creativecrafts/laravel-ai-assistant)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d13f90f5478681ba5fb3e159474029cffb4ac0e2ac95aad506b12db276649941/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63726561746976656372616674732f6c61726176656c2d61692d617373697374616e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/creativecrafts/laravel-ai-assistant/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/1d869ad84a295abf6939c196ccc476a32e49e65c5afb1cc7b302198ceefd0166/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63726561746976656372616674732f6c61726176656c2d61692d617373697374616e742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/creativecrafts/laravel-ai-assistant/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/652f3fd08ac0bac382ee6270f0967359e00ca53ab78e1ea85ac61f8cef961c23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63726561746976656372616674732f6c61726176656c2d61692d617373697374616e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creativecrafts/laravel-ai-assistant)

Laravel AI Assistant is a production-ready Laravel package for OpenAI APIs. It uses a Single Source of Truth (SSOT) architecture: **`Ai::responses()`** is the unified entry point for text, audio, image, streaming, and tool-calling workflows, with strong DX and predictable behavior.

---

Highlights
----------

[](#highlights)

- One primary API: `Ai::responses()`
- Automatic routing for audio and image operations
- Streaming, tool calls, and structured output
- Files, conversations, webhooks, and observability
- Advanced endpoints: Moderations, Batches, Realtime Sessions, Assistants, Vector Stores

---

Quick Start
-----------

[](#quick-start)

### 1) Install

[](#1-install)

```
composer require creativecrafts/laravel-ai-assistant
php artisan ai:install
```

### 2) Configure

[](#2-configure)

```
OPENAI_API_KEY=your-openai-api-key-here
```

### 3) Chat (SSOT)

[](#3-chat-ssot)

```
use CreativeCrafts\LaravelAiAssistant\Facades\Ai;

$response = Ai::responses()
    ->input()
    ->message('Explain Laravel queues in simple terms')
    ->send();

echo $response->text;
```

### 4) Streaming

[](#4-streaming)

```
foreach (Ai::responses()->input()->message('Tell me about Laravel')->stream() as $event) {
    // $event is a normalized SSE event
    // You can also use Ai::stream(...) for a simpler chat stream
}
```

### 5) Audio Transcription

[](#5-audio-transcription)

```
$response = Ai::responses()
    ->input()
    ->audio([
        'file' => storage_path('audio/recording.mp3'),
        'action' => 'transcribe',
    ])
    ->send();

echo $response->text;
```

### 6) Image Generation

[](#6-image-generation)

```
$response = Ai::responses()
    ->input()
    ->image([
        'prompt' => 'A futuristic Laravel logo with neon lights',
    ])
    ->send();

$response->saveImages(storage_path('images'));
```

---

Core Usage
----------

[](#core-usage)

### The SSOT Builder (`Ai::responses()`)

[](#the-ssot-builder-airesponses)

Use the unified builder for text, audio, and image operations:

```
$response = Ai::responses()
    ->model('gpt-4o-mini')
    ->temperature(0.3)
    ->input()
    ->message('Write a haiku about Laravel')
    ->send();
```

### Conversations

[](#conversations)

```
$conversation = Ai::conversations()->create();

Ai::responses()
    ->inConversation($conversation['id'])
    ->input()
    ->message('Remember: I like short answers')
    ->send();
```

### Tool Calling (Chat Sessions)

[](#tool-calling-chat-sessions)

```
use CreativeCrafts\LaravelAiAssistant\Support\ToolsBuilder;

$session = Ai::chat('You are a helpful assistant');
$session->tools()
    ->includeFunctionCallTool('getWeather', 'Fetch weather', [
        'properties' => ['city' => ['type' => 'string']],
        'required' => ['city'],
    ]);

$response = $session->send('What is the weather in Paris?');
```

### Audio

[](#audio)

```
// Speech synthesis
$response = Ai::responses()
    ->input()
    ->audio([
        'text' => 'Welcome to Laravel AI Assistant',
        'action' => 'speech',
        'voice' => 'alloy',
    ])
    ->send();

$response->saveAudio(storage_path('audio/welcome.mp3'));
```

### Images

[](#images)

```
// Image editing
$response = Ai::responses()
    ->input()
    ->image([
        'image' => storage_path('images/input.png'),
        'mask' => storage_path('images/mask.png'),
        'prompt' => 'Add a neon glow',
    ])
    ->send();

$response->saveImages(storage_path('images/edited'));
```

---

Files
-----

[](#files)

### Upload

[](#upload)

```
$fileId = Ai::files()->upload(storage_path('docs/guide.pdf'))['id'] ?? null;
```

### Download Content

[](#download-content)

```
$content = Ai::files()->content('file_123');
file_put_contents(storage_path('downloads/file.jsonl'), $content['content']);
```

---

Advanced Endpoints (Low-Level Repositories)
-------------------------------------------

[](#advanced-endpoints-low-level-repositories)

These are thin wrappers around OpenAI endpoints for advanced use cases.

```
// Moderations
$result = Ai::moderations()->create([
    'input' => 'Check this content',
]);

// Batches
$batch = Ai::batches()->create([
    'input_file_id' => 'file_123',
    'endpoint' => '/v1/responses',
    'completion_window' => '24h',
]);

// Realtime Sessions
$session = Ai::realtimeSessions()->create([
    'model' => 'gpt-4o-realtime-preview',
]);

// Assistants (v2 beta)
$assistant = Ai::assistants()->create([
    'model' => 'gpt-4o-mini',
    'name' => 'Support Assistant',
]);

// Vector Stores (v2 beta)
$store = Ai::vectorStores()->create([
    'name' => 'Support Docs',
]);
```

---

Webhooks
--------

[](#webhooks)

Enable in config and set a signing secret. Optional timestamp enforcement is supported.

```
AI_WEBHOOKS_ENABLED=true
AI_WEBHOOKS_SIGNING_SECRET=your-strong-secret
AI_WEBHOOKS_REQUIRE_TIMESTAMP=true
```

---

Testing
-------

[](#testing)

Integration tests are available under `tests/Integration`. They are skipped unless a valid API key is configured.

---

Migration &amp; Upgrade
-----------------------

[](#migration--upgrade)

- Migration guide: `MIGRATION.md`
- Upgrade guide: `UPGRADE.md`

---

Support
-------

[](#support)

See `CHANGELOG.md` for recent changes and `examples/` for additional usage patterns.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance71

Regular maintenance activity

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 88.4% 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

Every ~15 days

Recently: every ~2 days

Total

59

Last Release

209d ago

Major Versions

0.1.9 → 1.0.02023-05-24

0.0.8 → 1.1.02023-06-27

1.3.0 → 2.0.02024-10-07

2.1.8 → 3.0.0-beta2025-06-04

PHP version history (3 changes)0.0.1PHP ^8.1

1.2.0PHP ^8.2

2.1.4PHP ^8.3|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b5e5ba42a2029e0f2fa45bd8d874c98599af2d2a1e77bff012ea07eeb0b65bc?d=identicon)[rockblings](/maintainers/rockblings)

---

Top Contributors

[![rockblings](https://avatars.githubusercontent.com/u/5190259?v=4)](https://github.com/rockblings "rockblings (191 commits)")[![AlvinCoded](https://avatars.githubusercontent.com/u/112624931?v=4)](https://github.com/AlvinCoded "AlvinCoded (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelopenaiChatGptai assistantcreativeCraftslaravel-ai-assistant

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/creativecrafts-laravel-ai-assistant/health.svg)

```
[![Health](https://phpackages.com/badges/creativecrafts-laravel-ai-assistant/health.svg)](https://phpackages.com/packages/creativecrafts-laravel-ai-assistant)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[maestroerror/laragent

Power of AI Agents in your Laravel project

630106.4k](/packages/maestroerror-laragent)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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