PHPackages                             jasontame/langgraph-client-php - 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. jasontame/langgraph-client-php

ActiveLibrary[API Development](/categories/api)

jasontame/langgraph-client-php
==============================

An unofficial PHP client SDK for the LangGraph Platform API.

0.1.0(11mo ago)5618↓92.9%MITPHPPHP ^8.3CI passing

Since Jul 19Pushed 11mo agoCompare

[ Source](https://github.com/JasonTame/langgraph-client-php)[ Packagist](https://packagist.org/packages/jasontame/langgraph-client-php)[ Docs](https://github.com/jasontame/langgraph-client-php)[ RSS](/packages/jasontame-langgraph-client-php/feed)WikiDiscussions main Synced yesterday

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

LangGraph Client for PHP
========================

[](#langgraph-client-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/adaf0eca0b5f1597ff9a2141acddfb62f8b93458c45b4f240b707165a8545e15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61736f6e74616d652f6c616e6767726170682d636c69656e742d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jasontame/langgraph-client-php)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6d2eaf088e0c17c2a9b1eccd872e39273073461a59b929c78179036b9eb90c1f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a61736f6e74616d652f6c616e6767726170682d636c69656e742d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jasontame/langgraph-client-php/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/106f4e4d0c79176321460697eb1cf07ae0acea95d1782e475bc8bf5ff0a06c5f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a61736f6e74616d652f6c616e6767726170682d636c69656e742d7068702f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/jasontame/langgraph-client-php/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/2d2f9ca895ca4691baf3fd4776471fde37ab43e75d7dd391753538ffd20b826b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a61736f6e74616d652f6c616e6767726170682d636c69656e742d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jasontame/langgraph-client-php)

An unofficial PHP client SDK for interacting with the [LangGraph Platform API](https://langchain-ai.github.io/langgraph/cloud/reference/api/api_ref.html). This package provides a clean, Laravel-friendly interface for building AI agents and workflows using LangGraph's powerful platform.

Features
--------

[](#features)

- ✅ **Complete API Coverage** - Assistants, Threads, Runs, Crons, and Store operations
- ✅ **Laravel Integration** - Service provider, facade, and configuration
- ✅ **Streaming Support** - Real-time Server-Sent Events (SSE) streaming
- ✅ **Webhook Support** - Async operations with webhook callbacks
- ✅ **Error Handling** - Comprehensive exception classes with detailed error information
- ✅ **HTTP Client** - Built on Guzzle with retry logic and timeout handling
- ✅ **Type Safety** - Full PHP 8.3+ type declarations

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

[](#installation)

Install the package via Composer:

```
composer require jasontame/langgraph-client-php
```

### Laravel Setup

[](#laravel-setup)

Publish the configuration file:

```
php artisan vendor:publish --tag="langgraph-client-php-config"
```

Add your LangGraph Platform API credentials to your `.env` file:

```
LANGGRAPH_API_KEY=your-api-key-here
LANGGRAPH_BASE_URL=https://api.langchain.com
```

For local development, you can use:

```
LANGGRAPH_API_KEY=fake-api-key
LANGGRAPH_BASE_URL=http://localhost:8124
```

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

[](#quick-start)

### Using the Facade (Laravel)

[](#using-the-facade-laravel)

```
use JasonTame\LangGraphClient\Facades\LangGraphClient;

// Create an assistant
$assistant = LangGraphClient::assistants()->create([
    'graph_id' => 'my-graph',
    'name' => 'My Assistant',
    'config' => ['recursion_limit' => 10],
    'metadata' => ['version' => '1.0']
]);

// Create a thread
$thread = LangGraphClient::threads()->create([
    'metadata' => ['user_id' => 'user123']
]);

// Run the assistant
$run = LangGraphClient::runs()->create($thread['thread_id'], [
    'assistant_id' => $assistant['assistant_id'],
    'input' => ['message' => 'Hello, world!']
]);

echo "Run status: " . $run['status'];
```

### Using the Client Directly

[](#using-the-client-directly)

```
use JasonTame\LangGraphClient\LangGraphClient;

// Create client instance
$client = new LangGraphClient([
    'api_key' => 'your-api-key',
    'base_url' => 'https://api.langchain.com',
    'timeout' => 30,
    'retries' => 3
]);

// Or use environment variables
$client = LangGraphClient::fromEnvironment();
```

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

The SDK can be configured using environment variables:

- `LANGGRAPH_API_KEY`: Your LangGraph Platform API key (use `fake-api-key` for local development)
- `LANGGRAPH_BASE_URL`: Custom base URL (defaults to `https://api.langchain.com`)
- `LANGGRAPH_TIMEOUT`: Request timeout in seconds (default: 30)
- `LANGGRAPH_RETRIES`: Number of retry attempts (default: 3)

### Client Configuration

[](#client-configuration)

```
$client = new LangGraphClient([
    'api_key' => 'your-api-key',
    'base_url' => 'https://custom-api.example.com',
    'timeout' => 60,
    'retries' => 5
]);

// Or configure after initialization
$client->configure([
    'timeout' => 60,
    'retries' => 5
]);
```

Usage Examples
--------------

[](#usage-examples)

### Assistants

[](#assistants)

```
// Create an assistant
$assistant = $client->assistants()->create([
    'graph_id' => 'my-graph',
    'name' => 'My Assistant',
    'config' => ['recursion_limit' => 10],
    'metadata' => ['version' => '1.0']
]);

// Find an assistant
$assistant = $client->assistants()->find('assistant-id');

// Search assistants
$assistants = $client->assistants()->search([
    'metadata' => ['version' => '1.0'],
    'limit' => 10
]);

// Update an assistant
$client->assistants()->update('assistant-id', [
    'name' => 'Updated Name'
]);

// Delete an assistant
$client->assistants()->delete('assistant-id');
```

### Threads

[](#threads)

```
// Create a thread
$thread = $client->threads()->create([
    'metadata' => ['user_id' => 'user123']
]);

// Get thread state
$state = $client->threads()->state($thread['thread_id']);

// Update thread state
$client->threads()->updateState($thread['thread_id'], [
    'values' => ['key' => 'value']
]);

// Get thread history
$history = $client->threads()->history($thread['thread_id'], [
    'limit' => 10
]);

// Search threads
$threads = $client->threads()->search([
    'status' => 'idle',
    'limit' => 10
]);
```

### Runs

[](#runs)

```
// Create a run
$run = $client->runs()->create($thread['thread_id'], [
    'assistant_id' => $assistant['assistant_id'],
    'input' => ['message' => 'Hello!']
]);

// Create a run with webhook
$run = $client->runs()->create($thread['thread_id'], [
    'assistant_id' => $assistant['assistant_id'],
    'input' => ['message' => 'Hello!'],
    'webhook' => 'https://your-app.com/webhooks/langgraph'
]);

// Stream a run
foreach ($client->runs()->stream($thread['thread_id'], [
    'assistant_id' => $assistant['assistant_id'],
    'input' => ['message' => 'Hello!']
]) as $event) {
    echo "Event: " . $event['type'] . "\n";
    print_r($event['data']);
}

// Wait for a run to complete
$result = $client->runs()->wait($thread['thread_id'], [
    'assistant_id' => $assistant['assistant_id'],
    'input' => ['message' => 'Hello!']
]);

// List runs
$runs = $client->runs()->list($thread['thread_id']);

// Cancel a run
$client->runs()->cancel($thread['thread_id'], $run['run_id']);
```

### Crons

[](#crons)

**Note: Cron functionality requires LangGraph Platform Enterprise**

```
// Create a cron job
$cron = $client->crons()->create([
    'assistant_id' => $assistant['assistant_id'],
    'schedule' => '0 */6 * * *', // Every 6 hours
    'payload' => ['task' => 'periodic_task']
]);

// List cron jobs
$crons = $client->crons()->list([
    'assistant_id' => $assistant['assistant_id']
]);

// Enable/disable cron jobs
$client->crons()->enable($cron['cron_id']);
$client->crons()->disable($cron['cron_id']);
```

### Store Operations

[](#store-operations)

```
// Store data
$client->store()->put('namespace', 'key', ['data' => 'value']);

// Retrieve data
$item = $client->store()->get('namespace', 'key');

// List items in namespace
$items = $client->store()->list('namespace', ['prefix' => 'user_']);

// Delete data
$client->store()->delete('namespace', 'key');

// Batch operations
$client->store()->batchPut([
    ['namespace' => 'ns1', 'key' => 'key1', 'value' => 'value1'],
    ['namespace' => 'ns1', 'key' => 'key2', 'value' => 'value2']
]);
```

Streaming
---------

[](#streaming)

The SDK supports Server-Sent Events (SSE) streaming for real-time responses:

```
foreach ($client->runs()->stream($threadId, [
    'assistant_id' => $assistantId,
    'input' => ['message' => 'Tell me a story']
]) as $event) {
    switch ($event['type']) {
        case 'data':
            echo "Data: " . json_encode($event['data']) . "\n";
            break;
        case 'message':
            echo "Message: " . json_encode($event['data']) . "\n";
            break;
        case 'error':
            echo "Error: " . json_encode($event['data']) . "\n";
            break;
        case 'done':
            echo "Stream ended\n";
            break;
    }
}
```

Webhooks
--------

[](#webhooks)

The SDK supports webhooks that are called after LangGraph API calls complete:

```
// Thread-based runs with webhooks
$run = $client->runs()->create($threadId, [
    'assistant_id' => $assistantId,
    'input' => ['message' => 'Process this data'],
    'webhook' => 'https://your-app.com/webhooks/langgraph'
]);

// Stateless runs with webhooks
$client->runs()->createStateless([
    'assistant_id' => $assistantId,
    'input' => ['message' => 'Process this data'],
    'webhook' => 'https://your-app.com/webhooks/langgraph'
]);
```

**Webhook Requirements:**

- Must be a valid URI (up to 65,536 characters)
- Should handle HTTP POST requests from LangGraph Platform
- Called after the API call completes

Error Handling
--------------

[](#error-handling)

The SDK provides specific exception classes for different API errors:

```
use JasonTame\LangGraphClient\Exceptions\LangGraphException;
use JasonTame\LangGraphClient\Exceptions\NotFoundException;
use JasonTame\LangGraphClient\Exceptions\UnauthorizedException;

try {
    $assistant = $client->assistants()->find('nonexistent-id');
} catch (NotFoundException $e) {
    echo "Assistant not found: " . $e->getMessage();
} catch (UnauthorizedException $e) {
    echo "Authentication failed: " . $e->getMessage();
} catch (LangGraphException $e) {
    echo "API error: " . $e->getMessage();

    // Get additional error details
    $response = $e->getResponse();
    $responseData = $e->getResponseData();
    $errorType = $e->getErrorType();
}
```

Available exception classes:

- `LangGraphException` - Base error class
- `BadRequestException` - 400 errors
- `UnauthorizedException` - 401 errors
- `NotFoundException` - 404 errors
- `ConflictException` - 409 errors
- `ValidationException` - 422 errors
- `ServerException` - 500+ errors

Testing
-------

[](#testing)

Run the tests with:

```
composer test
```

Run with coverage:

```
composer test-coverage
```

Code Style
----------

[](#code-style)

Fix code style issues:

```
composer format
```

Run static analysis:

```
composer analyse
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Jason Tame](https://github.com/jasontame)
- Inspired by the [Ruby LangGraph Platform SDK](https://github.com/gysmuller/langgraph-platform)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance51

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97% 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

349d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15672948?v=4)[Jason Tame](/maintainers/JasonTame)[@JasonTame](https://github.com/JasonTame)

---

Top Contributors

[![JasonTame](https://avatars.githubusercontent.com/u/15672948?v=4)](https://github.com/JasonTame "JasonTame (32 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

clientlaravelsdkaiagentslangchainJason Tamelanggraph-client-phplanggraph

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jasontame-langgraph-client-php/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M318](/packages/openai-php-client)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)

PHPackages © 2026

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