PHPackages                             sergix44/gradio-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sergix44/gradio-client-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sergix44/gradio-client-php
==========================

Gradio client for PHP

0.2.0(3mo ago)165575[3 issues](https://github.com/SergiX44/gradio-client-php/issues)[1 PRs](https://github.com/SergiX44/gradio-client-php/pulls)MITPHPPHP ^8.2CI passing

Since Aug 4Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/SergiX44/gradio-client-php)[ Packagist](https://packagist.org/packages/sergix44/gradio-client-php)[ Docs](https://github.com/SergiX44/gradio-client-php)[ GitHub Sponsors](https://github.com/SergiX44)[ RSS](/packages/sergix44-gradio-client-php/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (8)Dependencies (10)Versions (10)Used By (0)

Gradio Client for PHP
=====================

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/648bbbd522bb3befa7c53df57d139c26cb9adfcf6c70d07d297d06470bff749c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73657267697834342f67726164696f2d636c69656e742d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sergix44/gradio-client-php)[![Tests](https://camo.githubusercontent.com/ee113401a7d3de3410242151a3987b33e151538f34940af9cee2b9cbbe096d1b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73657267697834342f67726164696f2d636c69656e742d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sergix44/gradio-client-php/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/e7e140592718a979f4af960fdb9d709a1f0098db41ea8cefe6048b09f720d1c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73657267697834342f67726164696f2d636c69656e742d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sergix44/gradio-client-php)

A PHP client to call [Gradio](https://www.gradio.app) APIs.

TODO
----

[](#todo)

- HTTP and WS support
- `predict`
- getConfig
- client options
- hf\_token support
- viewApi
- Finish event system
- Add tests

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

[](#installation)

You can install the package via composer:

```
composer require sergix44/gradio-client-php
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use SergiX44\Gradio\Client;

$client = new Client('https://my-special.hf.space');

$result = $client->predict(['arg', 1, 2], apiName: 'myFunction');

$outputs = $result->getOutputs(); // returns array of all outputs
$first = $result->getOutput(0);   // returns a single output by index
```

### Hugging Face Token Authentication

[](#hugging-face-token-authentication)

To access private Hugging Face Spaces, pass your HF token:

```
use SergiX44\Gradio\Client;

$client = new Client('https://my-private.hf.space', hfToken: 'hf_your_token_here');

$result = $client->predict(['hello'], apiName: 'chat');
```

The token is automatically sent as a Bearer token in the `Authorization` header on all HTTP and WebSocket requests.

### Viewing Available API Endpoints

[](#viewing-available-api-endpoints)

Use `viewApi()` to inspect the available API endpoints, their parameters, and return types:

```
use SergiX44\Gradio\Client;

$client = new Client('https://my-special.hf.space');

$apiInfo = $client->viewApi();

// Returns an array with 'named_endpoints' and 'unnamed_endpoints'
// Each endpoint includes parameter and return type information
print_r($apiInfo);
```

### Client Options

[](#client-options)

You can pass custom HTTP client options (Guzzle options) to customize the underlying HTTP client:

```
use SergiX44\Gradio\Client;

$client = new Client('https://my-special.hf.space', httpClientOptions: [
    'timeout' => 30,
    'headers' => [
        'X-Custom-Header' => 'value',
    ],
    'proxy' => 'http://proxy.example.com:8080',
]);
```

### Using Function Index

[](#using-function-index)

If you know the function index instead of the API name, you can use `fnIndex`:

```
$result = $client->predict(['input'], fnIndex: 0);
```

### Raw Response

[](#raw-response)

To get the raw decoded response instead of an `Output` DTO:

```
$result = $client->predict(['input'], apiName: 'myFunction', raw: true);
// $result is an associative array
```

### Event System

[](#event-system)

You can register callbacks for various events during the prediction process:

```
use SergiX44\Gradio\Client;
use SergiX44\Gradio\DTO\Messages\Estimation;
use SergiX44\Gradio\DTO\Messages\ProcessCompleted;

$client = new Client('https://my-special.hf.space');

// Called when a prediction is submitted
$client->onSubmit(function (array $payload) {
    echo "Submitted!\n";
});

// Called when queue position is estimated
$client->onQueueEstimation(function (Estimation $estimation) {
    echo "Queue position: {$estimation->rank}\n";
});

// Called when processing starts
$client->onProcessStarts(function () {
    echo "Processing started\n";
});

// Called when processing completes (success or failure)
$client->onProcessCompleted(function (ProcessCompleted $message) {
    echo "Completed: " . ($message->success ? 'success' : 'failed') . "\n";
});

// Called only on success
$client->onProcessSuccess(function (ProcessCompleted $message) {
    $output = $message->output;
});

// Called only on failure
$client->onProcessFailed(function (ProcessCompleted $message) {
    echo "Failed!\n";
});

// Called when the queue is full
$client->onQueueFull(function () {
    echo "Queue is full!\n";
});

// Called during streaming/generating
$client->onProcessGenerating(function () {
    echo "Generating...\n";
});

$result = $client->predict(['input'], apiName: 'myFunction');
```

### Accessing Config

[](#accessing-config)

```
$config = $client->getConfig();

echo $config->version;   // Gradio version
echo $config->protocol;  // 'sse_v3', 'ws', etc.
echo $config->title;     // App title
```

### File Upload

[](#file-upload)

You can pass file paths or resources as arguments, and they will be automatically encoded as base64:

```
// Using a file path
$result = $client->predict(['/path/to/image.png'], apiName: 'classify');

// Using a resource
$stream = fopen('/path/to/audio.mp3', 'r');
$result = $client->predict([$stream], apiName: 'transcribe');
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Sergio Brighenti](https://github.com/SergiX44)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance79

Regular maintenance activity

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81% 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 ~137 days

Recently: every ~192 days

Total

8

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/08bc14acf1f7db717de09e715047f5b5684841d6b9712129334931fa8833beda?d=identicon)[SergiX44](/maintainers/SergiX44)

---

Top Contributors

[![sergix44](https://avatars.githubusercontent.com/u/4172890?v=4)](https://github.com/sergix44 "sergix44 (34 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")[![ikarolaborda](https://avatars.githubusercontent.com/u/12631361?v=4)](https://github.com/ikarolaborda "ikarolaborda (1 commits)")

---

Tags

sergix44gradio-client-php

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sergix44-gradio-client-php/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

749284.3k35](/packages/civicrm-civicrm-core)[roundcube/roundcubemail

The Roundcube Webmail suite

7.0k1.4k3](/packages/roundcube-roundcubemail)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1232.2k16](/packages/fleetbase-core-api)

PHPackages © 2026

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