Download the PHP package sferra/delta without Composer
On this page you can find all versions of the php package sferra/delta. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package delta
Short Description HTTP connection for AI providers OpenAI API Compatible with SSE stream type
License MIT
Informations about the package delta
Delta
OpenAI-compatible SSE streaming client for PHP / Laravel.
Stream AI responses token-by-token via a clean, fluent API. Works with
any provider that exposes a /chat/completions endpoint.
Installation
Laravel will auto-discover the service provider. No manual registration needed.
Configuration
Publish the config file (optional):
Or use environment variables:
Usage
Facade (Laravel)
Direct client
Cancelling an in-flight stream
Pass a shouldCancel closure as the third argument. It is checked
before every byte read, so the stream aborts almost instantly when it
returns true. The partial content accumulated up to that point is
returned.
Typical use case: a chat UI that needs to interrupt the AI when the
user clicks a "stop" button. In Livewire, point a public property at
the flag and bind the button with wire:click:
Supported Providers
Any OpenAI-compatible API:
- Hermes Agent
- OpenCode
- Ollama
- OpenAI
- vLLM
- Custom
/chat/completionsendpoints
How It Works
Delta sends a POST request with stream: true and parses the SSE
(Server-Sent Events) response byte-by-byte, extracting
choices[0].delta.content from each chunk.
The $onChunk callback receives each text delta as it arrives,
enabling real-time streaming in Livewire components, console commands,
or any PHP application.
License
MIT
All versions of delta with dependencies
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0