PHPackages                             token27/nexus-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. [HTTP &amp; Networking](/categories/http)
4. /
5. token27/nexus-ai

ActiveLibrary[HTTP &amp; Networking](/categories/http)

token27/nexus-ai
================

Framework-agnostic AI communication engine with middleware pipeline architecture

v1.0.0(2w ago)024↓100%3MITPHPPHP ^8.3CI passing

Since May 22Pushed 2w agoCompare

[ Source](https://github.com/token27/nexus-ai)[ Packagist](https://packagist.org/packages/token27/nexus-ai)[ Docs](https://github.com/token27/nexus-ai)[ RSS](/packages/token27-nexus-ai/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (11)Versions (2)Used By (3)

NexusAI
=======

[](#nexusai)

[![CI](https://github.com/token27/nexus-ai/actions/workflows/ci.yml/badge.svg)](https://github.com/token27/nexus-ai/actions)[![Latest Version](https://camo.githubusercontent.com/c58f114be85f48da0ed484479f2060a6fcf1155d8f49943c82925b3a67600215/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6b656e32372f6e657875732d61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/token27/nexus-ai)[![PHP 8.2+](https://camo.githubusercontent.com/ccaa43fc634d348cffccb1d8db7b55d9f17c5d46944bc99a15c3c982724b387d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php.net)[![PHPStan Level 6](https://camo.githubusercontent.com/1059b5a6c744b29e090cbcf5f750006499ebca59b01b4be2f0dc547bd0ec5f34/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230362d316636666562)](https://phpstan.org/)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)

A framework-agnostic PHP 8.2+ library for communicating with AI providers. Supports text generation, image generation, embeddings, speech synthesis, transcription, streaming, tool calling, and structured output — through a unified, PSR-18 compliant interface.

Supported Providers
-------------------

[](#supported-providers)

OpenAI · Anthropic · Google Gemini · Ollama · DeepSeek · Groq · Mistral · xAI · Perplexity

Features
--------

[](#features)

- **Text generation** with full conversation history support
- **Image generation** (DALL-E 3, Imagen)
- **Text embeddings** with batch support
- **Text-to-Speech** and **Speech-to-Text** (Whisper)
- **Streaming** via Server-Sent Events with typed chunks
- **Structured output** — maps LLM responses directly to PHP DTOs
- **Tool calling** with multi-step execution loops
- **Chat history** — in-memory and file-based persistence
- **Middleware pipeline** — Retry, Cache, Cost tracking, Rate limiting, Circuit breaker, Logging
- **Observability** — EventBus with pluggable observers and metrics
- **FakeDriver** for unit testing without API calls

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

[](#installation)

```
composer require token27/nexus-ai
```

Requires a PSR-18 HTTP client:

```
composer require guzzlehttp/guzzle
```

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

[](#quick-start)

```
use Token27\NexusAI\NexusAI;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;

$factory = new HttpFactory();

NexusAI::setHttpClient(new Client());
NexusAI::setFactories($factory, $factory);
NexusAI::configure([
    'openai' => ['api_key' => $_ENV['OPENAI_API_KEY']],
]);

$response = NexusAI::using('openai', 'gpt-4o')
    ->withSystemPrompt('You are a helpful assistant.')
    ->withPrompt('What is PHP?')
    ->asText();

echo $response->text;
```

Documentation
-------------

[](#documentation)

Full documentation is available in the [`docs/`](docs/) directory:

- [Installation &amp; Setup](docs/installation.md)
- [Configuration](docs/configuration.md)
- [Text Generation](docs/text-generation.md)
- [Image Generation](docs/image-generation.md)
- [Embeddings](docs/embeddings.md)
- [Audio — TTS &amp; STT](docs/audio.md)
- [Structured Output](docs/structured-output.md)
- [Streaming](docs/streaming.md)
- [Tool Calling](docs/tool-calling.md)
- [Chat History](docs/chat-history.md)
- [Middleware Pipeline](docs/middleware.md)
- [Observability](docs/observability.md)
- [Testing](docs/testing.md)
- [Troubleshooting](docs/troubleshooting.md)

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

[](#requirements)

- PHP 8.2 or higher
- A PSR-18 HTTP client
- PSR-17 HTTP factories

Contributing
------------

[](#contributing)

Please see [docs/contributing.md](docs/contributing.md) for details.

License
-------

[](#license)

MIT. Please see [LICENSE](LICENSE) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance96

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

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

19d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/78189912?v=4)[Token27](/maintainers/token27)[@token27](https://github.com/token27)

---

Top Contributors

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

---

Tags

phpmiddlewarepsr-18aiopenaiGeminillmanthropic

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/token27-nexus-ai/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69534.4M144](/packages/algolia-algoliasearch-client-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.7k371.6k5](/packages/theodo-group-llphant)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

317117.1k1](/packages/cognesy-instructor-php)[mimmi20/browser-detector

Library to detect Browsers and Devices

48156.1k4](/packages/mimmi20-browser-detector)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)

PHPackages © 2026

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