PHPackages                             pointerdev/ai-chat-laravel - 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. pointerdev/ai-chat-laravel

ActiveLibrary

pointerdev/ai-chat-laravel
==========================

Official Laravel client package for PointerDev AI chat APIs.

v0.1.0(2w ago)00MITPHPPHP ^8.1CI passing

Since Mar 5Pushed 1w agoCompare

[ Source](https://github.com/pointerdev-tech/ai-chat-laravel)[ Packagist](https://packagist.org/packages/pointerdev/ai-chat-laravel)[ RSS](/packages/pointerdev-ai-chat-laravel/feed)WikiDiscussions main Synced today

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

pointerdev/ai-chat-laravel
==========================

[](#pointerdevai-chat-laravel)

Official Laravel package for PointerDev AI chat APIs.

Install
-------

[](#install)

```
composer require pointerdev/ai-chat-laravel
```

Publish config (optional)
-------------------------

[](#publish-config-optional)

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

Environment variables
---------------------

[](#environment-variables)

```
AI_CHAT_BASE_URL=https://pointerdev.ai
AI_CHAT_PROJECT_ID=your-project-uuid
AI_CHAT_PUBLISHABLE_KEY=pk_...
AI_CHAT_SECRET_KEY=sk_... # keep server-side only
AI_CHAT_END_USER_TOKEN=   # optional test-only fallback
AI_CHAT_TIMEOUT=20
AI_CHAT_RUNTIME_AUTH_ENABLED=true
AI_CHAT_RUNTIME_SESSION_STORE_KEY=ai_chat.runtime_session
AI_CHAT_RUNTIME_END_USER_TTL_MINUTES=60
AI_CHAT_RUNTIME_REFRESH_LEEWAY_SECONDS=5
```

Quick usage
-----------

[](#quick-usage)

```
use PointerDev\AIChat\Facades\AIChat;

$result = AIChat::chat([
    'message' => 'Hello from Laravel',
    'anon_uid' => 'demo-anon-user',
    'metadata' => ['source' => 'laravel-app'],
]);

$answer = $result['answer'] ?? null;
```

login\_required projects
------------------------

[](#login_required-projects)

```
use PointerDev\AIChat\Facades\AIChat;

$client = AIChat::withEndUserToken('');

// Exchange once for short-lived runtime session token
$client->exchangeSessionToken();

$result = $client->chat([
    'message' => 'Hello from authenticated user',
]);
```

Runtime Session Token Flow (recommended)
----------------------------------------

[](#runtime-session-token-flow-recommended)

```
use PointerDev\AIChat\Facades\AIChat;

$client = AIChat::withEndUserToken($endUserJwtFromYourBackend);

// Exchange end-user token for runtime session token
$sessionAuth = $client->exchangeSessionToken();

// Chat now prefers runtime session token automatically
$result = $client->chat([
    'message' => 'Hello from authenticated user',
    'metadata' => ['source' => 'laravel-app'],
]);

// Optional explicit refresh/revoke
$client->refreshSessionToken();
$client->revokeSessionToken();
```

Phase 3 auth adapter (Laravel middleware)
-----------------------------------------

[](#phase-3-auth-adapter-laravel-middleware)

The package now provides middleware alias `ai-chat.runtime-session` that:

- reads `Auth::user()`
- mints a PointerDev AI end-user token server-side using `AI_CHAT_SECRET_KEY`
- exchanges/refreshes runtime session token
- persists runtime session token in Laravel session storage
- binds stored runtime session state to the authenticated user identity

Identity note: Laravel derives end-user `sub` from the auth identifier. WordPress defaults to `blog_id:user_id` for multisite-aware separation.

Register middleware in your route group:

```
Route::middleware(['web', 'auth', 'ai-chat.runtime-session'])->group(function () {
    Route::get('/chat', function () {
        $result = app(\PointerDev\AIChat\AIChatClient::class)->chat([
            'message' => 'Hello from middleware flow',
            'metadata' => ['source' => 'laravel-runtime-adapter'],
        ]);

        return response()->json($result);
    });
});
```

Optional logout cleanup (revokes runtime token):

```
app(\PointerDev\AIChat\Auth\AIChatRuntimeSessionManager::class)
    ->revokeForRequest(request());
```

Available methods
-----------------

[](#available-methods)

- `createSession(array $options = [])`
- `chat(array $payload)`
- `listSessionsByAnon(string $anonUid, int $limit = 50, ?string $token = null)`
- `listSessionsByUser(int $limit = 50, ?string $token = null)`
- `listMessages(string $sessionUid, int $limit = 200, ?string $token = null)`
- `exchangeSessionToken(array $options = [])`
- `refreshSessionToken(array $options = [])`
- `revokeSessionToken(array $options = [])`
- `withSessionToken(?string $token, ?string $expiresAt = null, ?string $refreshAvailableAt = null, ?string $sessionId = null)`
- `setSessionToken(?string $token, ?string $expiresAt = null, ?string $refreshAvailableAt = null, ?string $sessionId = null)`
- `clearSessionToken()`
- `getSessionTokenState()`
- `withEndUserToken(?string $token)`
- `setEndUserToken(?string $token)`
- `clearEndUserToken()`

Notes
-----

[](#notes)

- Only use publishable keys (`pk_...`) in browser/client flows.
- Keep secret keys server-side only.

Testing
-------

[](#testing)

Run package unit tests locally:

```
composer install
composer test
```

###  Health Score

35

—

LowBetter than 81% of packages

Maintenance97

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

16d ago

### Community

Maintainers

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

---

Top Contributors

[![edioni-h](https://avatars.githubusercontent.com/u/210057943?v=4)](https://github.com/edioni-h "edioni-h (7 commits)")

---

Tags

laravelsdkchatpointerai

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pointerdev-ai-chat-laravel/health.svg)

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

PHPackages © 2026

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