PHPackages                             ianrothmann/langserve-php-client - 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. [API Development](/categories/api)
4. /
5. ianrothmann/langserve-php-client

ActiveLibrary[API Development](/categories/api)

ianrothmann/langserve-php-client
================================

A PHP Client for your LangServe project that is able to call API endpoints such as invoke, batch and stream.

1.2.0(1y ago)13.4k1MITPHPPHP &gt;=7.4

Since May 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ianrothmann/langserve-php-client)[ Packagist](https://packagist.org/packages/ianrothmann/langserve-php-client)[ RSS](/packages/ianrothmann-langserve-php-client/feed)WikiDiscussions main Synced 1w ago

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

LangServe PHP Client
====================

[](#langserve-php-client)

Purpose
-------

[](#purpose)

This package provides a PHP client for the LangServe API, allowing you to easily call API endpoints such as `invoke`, `batch`, and `stream`. It simplifies the process of sending requests and handling responses from your LangServe project.

It was designed to work with vanilla PHP so it can be included with any framework (such as Laravel).

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

[](#installation)

To install the package, use Composer:

```
composer require ianrothmann/langserve-php-client
```

Dependencies
------------

[](#dependencies)

This package requires:

- PHP 8.0 or higher
- Symfony HttpClient component, to support communication and streaming capabilities.

Ensure these are included in your project by adding them to your composer.json if not already present:

```
composer require symfony/http-client
```

Usage
-----

[](#usage)

First, instantiate the `RemoteRunnable` with the base URL of your LangServe API:

```
use IanRothmann\LangServePhpClient\RemoteRunnable;

$runnable = new RemoteRunnable('http://localhost:8100/summarize/');
```

You can optionally add a Bearer token as the second parameter (remember to implement it in LangServe):

```
$runnable = new RemoteRunnable('http://localhost:8100/summarize/');
```

You have some different options for adding headers and authentication:

```
$runnable->authenticateWithBearerToken('your-token'); //Add a Bearer token header with the token
$runnable->authenticateWithXToken('your-token'); //Add the X-Token header, if you implemented it according to the LangServe Examples with X-Token
$runnable->addHeader('Key', 'Value'); //Add any other header
```

### Invoke

[](#invoke)

Invoke a single API call:

```
$input = ['text' => 'Hello, this is something for you to summarize'];
$response = $runnable->invoke($inputs);
dd($response->getRunId(), $response->getContent(), $response->getTokenUsage(), $response->getData(), $response->toJson());
```

### Batch

[](#batch)

Invoke multiple API calls in a batch:

```
$input = [['text' => 'Hello, this is something for you to summarize'],['text' => 'Hello, this is more text for you to summarize']];
$batchResponse = $runnable->batch($inputs);

foreach ($batchResponse->getResponses() as $response) {
    //$response->getRunId(),
    //$response->getContent(),
    //$response->getTokenUsage());
}
```

### Stream

[](#stream)

Handle streaming responses:

```
$result = $runnable->stream($input, function($response) {
    //Do something with the content here
    $response->getContent();
});
// Finally, this gives you the full content after everything has been streamed:
$result->getContent();
```

### Response Classes

[](#response-classes)

Responses from `invoke` and `batch` are handled through `RemoteRunnableResponse` and `RemoteRunnableBatchResponse`, respectively. `stream` initially provides `RemoteRunnableStreamEvent` for each received event, and finally, a `RemoteRunnableStreamResponse` aggregates all events to compile the total content.

Exceptions
----------

[](#exceptions)

This client can throw several exceptions based on API response:

- `InternalServerErrorException` for server errors.
- `MalformedInputException` for input schema mismatches.
- `NotFoundException` when the requested resource is not found.
- `RemoteInvocationException` for errors during the remote invocation.

These exceptions help in accurately diagnosing issues with API interactions.

Contributions
-------------

[](#contributions)

Any contributions to this package is welcome. I'm looking to add more functionality to it and will work on it as required.

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

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

Every ~15 days

Recently: every ~27 days

Total

11

Last Release

670d ago

Major Versions

0.0.7 → 1.0.02024-08-19

PHP version history (2 changes)0.0.1PHP &gt;=8.0

1.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4319223?v=4)[Ian Rothmann](/maintainers/ianrothmann)[@ianrothmann](https://github.com/ianrothmann)

---

Top Contributors

[![ianrothmann](https://avatars.githubusercontent.com/u/4319223?v=4)](https://github.com/ianrothmann "ianrothmann (21 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/ianrothmann-langserve-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/ianrothmann-langserve-php-client/health.svg)](https://phpackages.com/packages/ianrothmann-langserve-php-client)
```

###  Alternatives

[storyblok/php-management-api-client

Storyblok PHP Client for Management API

1237.8k5](/packages/storyblok-php-management-api-client)

PHPackages © 2026

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