PHPackages                             phalanx/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. [Queues &amp; Workers](/categories/queues)
4. /
5. phalanx/ai

ActiveLibrary[Queues &amp; Workers](/categories/queues)

phalanx/ai
==========

AI agent runtime for Phalanx — providers, tools, streaming, structured output, multi-agent coordination

v0.2.0(1mo ago)01↑2900%MITPHPPHP ^8.4

Since Mar 27Pushed 1mo agoCompare

[ Source](https://github.com/havy-tech/phalanx-ai)[ Packagist](https://packagist.org/packages/phalanx/ai)[ Docs](https://github.com/havy-tech/phalanx-ai)[ RSS](/packages/phalanx-ai/feed)WikiDiscussions main Synced 1mo ago

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

 [![Phalanx](brand/logo.svg)](brand/logo.svg)

phalanx/ai
==========

[](#phalanxai)

An agentic runtime for PHP 8.4+ that treats LLM interactions as scoped, typed, stream-native computations. Define tools as invokable classes, wire providers as services, and let the Phalanx runtime handle concurrency, retries, streaming, and cleanup.

Phalanx/ai brings concurrent tool execution, streaming with backpressure, and multi-agent coordination to PHP -- capabilities that previously required leaving for another language.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Agents](#agents)
    - [Agent Definition](#agent-definition)
    - [Agent Turns](#agent-turns)
    - [Multi-Step Reasoning](#multi-step-reasoning)
- [Tools](#tools)
    - [Tool Classes](#tool-classes)
    - [Tool Results and Dispositions](#tool-results-and-dispositions)
    - [Tool Bundles](#tool-bundles)
- [Providers](#providers)
    - [Provider Configuration](#provider-configuration)
    - [Multi-Provider Strategies](#multi-provider-strategies)
- [Streaming](#streaming)
    - [Event Channel](#event-channel)
    - [SSE Delivery](#sse-delivery)
    - [WebSocket Delivery](#websocket-delivery)
    - [Token Accumulator](#token-accumulator)
- [Structured Output](#structured-output)
- [Pipelines](#pipelines)
- [Conversation Memory](#conversation-memory)
- [CLI Agents](#cli-agents)
- [Observability](#observability)
- [Examples](#examples)

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

[](#installation)

```
composer require phalanx/ai
```

Requires PHP 8.4+, `phalanx/core`, `phalanx/stream`, `phalanx/http`.

Optional: `phalanx/redis` for conversation memory and pub/sub coordination, `phalanx/postgres` for persistent storage, `phalanx/websocket` for real-time delivery, `phalanx/console` for CLI agents.

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

[](#quick-start)

```
