PHPackages                             secondtruth/huggingface - 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. secondtruth/huggingface

ActiveLibrary

secondtruth/huggingface
=======================

v0.1.0(3y ago)17MITPHPPHP ^8.1.0

Since May 8Pushed 2y agoCompare

[ Source](https://github.com/secondtruth/php-huggingface)[ Packagist](https://packagist.org/packages/secondtruth/huggingface)[ Fund](https://paypal.me/secondtruth)[ Fund](https://ko-fi.com/secondtruth)[ RSS](/packages/secondtruth-huggingface/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (3)Used By (0)

 [![GitHub Workflow Status (main)](https://camo.githubusercontent.com/20749b03053e0781b87929129574806931049de401b001a49bb26c818d2e1154/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b616d626f2d3173742f68756767696e67666163652d7068702f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d726f756e642d737175617265)](https://github.com/kambo-1st/huggingface-php/actions) [![Total Downloads](https://camo.githubusercontent.com/56aa5ae57f7e384c2e1955e7904f9dec998f39d5b8ad5d6c02622a8db09141ee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b616d626f2f68756767696e67666163652d706870)](https://packagist.org/packages/kambo/huggingface-php) [![Latest Version](https://camo.githubusercontent.com/aa0c457508febfb3e8705045000ca66b4a18be125ddb866fcbe9323ad85cadce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b616d626f2f68756767696e67666163652d706870)](https://packagist.org/packages/kambo/huggingface-php) [![License](https://camo.githubusercontent.com/6473b294e2d55531a9d3bf30049d02c697538593b98d50eece5c6b6eab46010b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b616d626f2f68756767696e67666163652d706870)](https://packagist.org/packages/kambo/huggingface-php)

---

**Huggingface PHP** is a community-maintained PHP API client that allows you to interact with the [Hugging Face API](https://huggingface.co/inference-api).

Table of Contents
-----------------

[](#table-of-contents)

- [Get Started](#get-started)
- [Usage](#usage)
    - [Inferring](#Inferring)
- [Testing](#testing)

Get Started
-----------

[](#get-started)

> **Requires [PHP 8.1+](https://php.net/releases/)**

First, install OpenAI via the [Composer](https://getcomposer.org/) package manager:

```
composer require kambo/huggingface-php
```

Ensure that the `php-http/discovery` composer plugin is allowed to run or install a client manually if your project does not already have a PSR-18 client integrated.

```
composer require guzzlehttp/guzzle
```

Then, interact with Hugging Face's API:

```
use Kambo\Huggingface\Huggingface;
use Kambo\Huggingface\Enums\Type;

$yourApiKey = getenv('HUGGINGFACE_API_KEY');
$client = Huggingface::client($yourApiKey);

$result = $client->inference()->create([
    'model' => 'gpt2',
    'inputs' => 'The goal of life is?',
    'type' => Type::TEXT_GENERATION,
]);

echo $result['generated_text']."\n";
```

Usage
-----

[](#usage)

### `Inference` Resource

[](#inference-resource)

#### `create`

[](#create)

Execute inference using the chosen model.

```
$response = $client->inference()->create([
    'model' => 'gpt2',
    'inputs' => 'The goal of life is?',
    'type' => Type::TEXT_GENERATION,
]);

$response->toArray(); // ['type' => .., 'generated_text' => ...]
```

Acknowledge
-----------

[](#acknowledge)

This library was inspired at the source level by the PHP OpenAI client. Portions of the code have been directly copied from this outstanding library.

---

Huggingface PHP is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

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

1106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82268b2432ab90f14c62445938bc3cd1340dc66e0463035df57891826b418016?d=identicon)[secondtruth](/maintainers/secondtruth)

---

Top Contributors

[![secondtruth](https://avatars.githubusercontent.com/u/416441?v=4)](https://github.com/secondtruth "secondtruth (4 commits)")[![kambo-1st](https://avatars.githubusercontent.com/u/6493048?v=4)](https://github.com/kambo-1st "kambo-1st (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/secondtruth-huggingface/health.svg)

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

###  Alternatives

[openai-php/client

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

5.8k22.6M232](/packages/openai-php-client)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

963.1M35](/packages/getbrevo-brevo-php)[swisnl/json-api-client

A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.

211473.2k12](/packages/swisnl-json-api-client)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2222.9M248](/packages/open-telemetry-sdk)[deeplcom/deepl-php

Official DeepL API Client Library

2616.2M66](/packages/deeplcom-deepl-php)

PHPackages © 2026

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