PHPackages                             aisdk/transport - 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. aisdk/transport

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

aisdk/transport
===============

Ready-made Live transport implementations for the PHP AI SDK.

v0.8.0(1mo ago)019MITPHPPHP ^8.3CI passing

Since Jul 15Pushed 1mo agoCompare

[ Source](https://github.com/phpaisdk/transport)[ Packagist](https://packagist.org/packages/aisdk/transport)[ Docs](https://github.com/phpaisdk/transport)[ RSS](/packages/aisdk-transport/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

aisdk/transport
===============

[](#aisdktransport)

[![GitHub Workflow Status](https://camo.githubusercontent.com/3c181fb8ae5ed09c7c5e0d1d92138be84619e6d3bf28691fab777ecb422d1877/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706870616973646b2f7472616e73706f72742f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)](https://github.com/phpaisdk/transport/actions)[![Total Downloads](https://camo.githubusercontent.com/de6aa59cbbbecabdb108f18acce37d09248642890583ca437d3ea1e817902ef2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616973646b2f7472616e73706f7274)](https://packagist.org/packages/aisdk/transport)[![Latest Version](https://camo.githubusercontent.com/4ffe7f17299971673cfa6c99d434149f12cbb45890a0376c1c736a113a639151/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616973646b2f7472616e73706f7274)](https://packagist.org/packages/aisdk/transport)[![License](https://camo.githubusercontent.com/91670855facdd8e4361cad3a4cec487c151ff4a8ac850106083263e538f5da83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616973646b2f7472616e73706f7274)](https://packagist.org/packages/aisdk/transport)[![Why PHP in 2026](https://camo.githubusercontent.com/d2b9305e630caf7daae4ca023de39ece0b885c37461629d42961533f00868b76/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5768795f5048502d696e5f323032362d3741383645383f7374796c653d666c61742d737175617265266c6162656c436f6c6f723d313831383162)](https://whyphp.dev)

---

Ready-made network transports for the provider-neutral Live API in `aisdk/core`. Provider packages continue to own authentication, endpoint construction, and event codecs; this package only moves text and binary frames over the network.

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

[](#installation)

```
composer require aisdk/transport
```

Automatic selection
-------------------

[](#automatic-selection)

```
use AiSdk\Live;
use AiSdk\OpenAI;
use AiSdk\Transport;

$session = Live::voice()
    ->model(OpenAI::model('gpt-realtime-2.1'))
    ->voice('marin')
    ->connect(Transport::auto());
```

`Transport::auto()` selects the implementation from the endpoint prepared by the provider adapter:

- WebSocket endpoints use `amphp/websocket-client`.
- Bidirectional HTTP/2 endpoints use `amphp/http-client`.

Use an explicit transport when you want to restrict the connection type:

```
$webSocket = Transport::webSocket(
    maximumMessageBytes: 16_777_216,
    connectTimeout: 10,
    tlsHandshakeTimeout: 10,
);

$http2 = Transport::http2(
    requestBufferBytes: 65_536,
    inactivityTimeout: 0,
    transferTimeout: 0,
    maximumRequestChunkBytes: 16_777_216,
    maximumResponseChunkBytes: 16_777_216,
);
```

Both explicit factories accept an Amp connector/client for applications that need custom proxy, DNS, socket, or TLS behavior. Their public constructors are also available when composing `AutoTransport` manually.

Concurrent audio and events
---------------------------

[](#concurrent-audio-and-events)

`LiveSession::events()` waits for incoming data, so a full-duplex voice agent should send audio and consume events in separate Amp tasks. Core remains free of Amp types; concurrency is an application concern:

```
use AiSdk\Live\AudioDelta;
use AiSdk\Live\ResponseCompleted;
use function Amp\async;
use function Amp\delay;

$sender = async(function () use ($session, $pcmBytes): void {
    foreach (str_split($pcmBytes, 3_200) as $chunk) {
        $session->sendAudio($chunk);
        delay(0.02);
    }

    $session->commitAudio();
});

$receiver = async(function () use ($session, $speaker): void {
    foreach ($session->events() as $event) {
        if ($event instanceof AudioDelta) {
            $speaker->write($event->bytes);
        }

        if ($event instanceof ResponseCompleted) {
            $session->close();

            return;
        }
    }
});

$sender->await();
$receiver->await();
```

For an open-ended microphone session, keep both tasks alive until the application's own stop signal, then call `$session->close()` and await them.

Bidirectional HTTP/2
--------------------

[](#bidirectional-http2)

The HTTP/2 implementation writes the streaming request body and reads the streaming response independently. It supports request-body half-close, applies backpressure through an Amp pipe, disables whole-transfer and inactivity timeouts by default for long-lived sessions, and refuses HTTP/1.1 fallback.

Transport configuration such as timeouts, TLS, buffers, and message limits belongs here. Provider JSON, AWS signing, EventStream framing, WebRTC, and SIP logic deliberately do not.

Applications can still connect with any implementation of core's `TransportInterface`; installing this package is a convenience, not a requirement of `AiSdk\Live`.

Testing
-------

[](#testing)

```
composer test
```

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

[](#documentation)

- [PHP AI SDK documentation](https://phpaisdk.com/docs)
- [Transport documentation](https://phpaisdk.com/docs/live/transports)

Community
---------

[](#community)

- [Contributing](https://github.com/phpaisdk/.github/blob/main/CONTRIBUTING.md)
- [Support](https://github.com/phpaisdk/.github/blob/main/SUPPORT.md)
- For private security reports, email .

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

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

46d ago

### Community

Maintainers

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

---

Top Contributors

[![RanaMoizHaider](https://avatars.githubusercontent.com/u/58527494?v=4)](https://github.com/RanaMoizHaider "RanaMoizHaider (8 commits)")

---

Tags

http2aiwebsocketrealtimeaisdk

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aisdk-transport/health.svg)

```
[![Health](https://phpackages.com/badges/aisdk-transport/health.svg)](https://phpackages.com/packages/aisdk-transport)
```

###  Alternatives

[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.5k943.4k24](/packages/danog-madelineproto)[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k9.2M131](/packages/amphp-http-server)[amphp/websocket-client

Async WebSocket client for PHP based on Amp.

1657.4M74](/packages/amphp-websocket-client)[pestphp/pest-plugin-browser

Pest plugin to test browser interactions

1375.9M292](/packages/pestphp-pest-plugin-browser)[centrifugal/phpcent

PHP library to communicate with Centrifugo HTTP API

1872.6M5](/packages/centrifugal-phpcent)[amphp/websocket

Shared code for websocket servers and clients.

467.5M12](/packages/amphp-websocket)

PHPackages © 2026

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