PHPackages                             tetrixdev/laravel-ai-bridge - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tetrixdev/laravel-ai-bridge

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tetrixdev/laravel-ai-bridge
===========================

Laravel package for AI Bridge — unified streaming interface for CLI Bridge, BYOK, and managed AI modes

v0.5.1(2w ago)032↓50%[10 issues](https://github.com/tetrixdev/laravel-ai-bridge/issues)[1 PRs](https://github.com/tetrixdev/laravel-ai-bridge/pulls)MITPHPPHP ^8.2CI passing

Since May 16Pushed 1w agoCompare

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

READMEChangelog (10)Dependencies (9)Versions (19)Used By (0)

Laravel AI Bridge
=================

[](#laravel-ai-bridge)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e5dfa661248f24133bd4f6231fd58e29240301a42f869281c09db00e982627e5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465747269786465762f6c61726176656c2d61692d6272696467652e737667)](https://packagist.org/packages/tetrixdev/laravel-ai-bridge)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![PHP 8.2+](https://camo.githubusercontent.com/0f16581d1180dbfd4c0e13166ec1267d4ad2f2fab8281ea6d6b284cf5c65d921/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c75652e737667)](https://php.net)[![Laravel 11+](https://camo.githubusercontent.com/5c5576721d3a9233c218b8d6db0f2ea626aee0ab821ffd60b59a9e1d0e942daa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312532422d7265642e737667)](https://laravel.com)

A unified AI streaming interface for Laravel. Connect any Chat Completions-compatible provider (OpenAI, Anthropic, Groq, Ollama, etc.) or local CLI tools (Codex, Claude, Gemini) to your app through a single, normalized streaming pipeline.

What is this?
-------------

[](#what-is-this)

Laravel AI Bridge provides a unified streaming pipeline: **provider -&gt; normalized events -&gt; browser**. No matter where the AI response originates, your application receives the same `StreamEvent` objects through the same callback API. Three modes of operation cover every use case:

- **BYOK (Bring Your Own Key)** -- User provides an API key and endpoint. No local install needed.
- **Managed** -- Your app provides the API key. Same code path as BYOK, different config source.
- **CLI Bridge** -- User runs `npx @tetrixdev/ai-bridge` locally. Their CLI tools (Codex, Claude, Gemini) connect to your app via a dedicated WebSocket server.

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

[](#installation)

```
composer require tetrixdev/laravel-ai-bridge
```

Publish the config file:

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

Publish the JavaScript client (optional):

```
php artisan vendor:publish --tag=ai-bridge-js
```

Add to your `.env`:

```
# Required for all modes
AI_BRIDGE_TOKEN_SECRET=your-random-secret-here

# For BYOK / Managed mode
AI_BRIDGE_MODE=byok
AI_BRIDGE_ENDPOINT=https://api.openai.com
AI_BRIDGE_API_KEY=sk-...
AI_BRIDGE_MODEL=gpt-4o

# For CLI Bridge mode
AI_BRIDGE_MODE=bridge
AI_BRIDGE_SERVER_HOST=0.0.0.0
AI_BRIDGE_SERVER_PORT=8085
```

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

[](#quick-start)

A minimal BYOK example in three steps.

### 1. Configure `.env`

[](#1-configure-env)

```
# Generate with: openssl rand -hex 32
AI_BRIDGE_TOKEN_SECRET=REPLACE_WITH_OUTPUT_OF_openssl_rand_hex_32
AI_BRIDGE_MODE=byok
AI_BRIDGE_ENDPOINT=https://api.openai.com
AI_BRIDGE_API_KEY=sk-your-key
AI_BRIDGE_MODEL=gpt-4o
```

### 2. Create a Controller

[](#2-create-a-controller)

```
