PHPackages                             rezaulhreza/hugging-face-for-laravel - 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. rezaulhreza/hugging-face-for-laravel

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

rezaulhreza/hugging-face-for-laravel
====================================

A Laravel package for integrating HuggingFace AI models

v1.2(1y ago)156[4 PRs](https://github.com/rezaulhreza/hugging-face-for-laravel/pulls)MITPHPPHP ^8.2CI passing

Since Feb 11Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/rezaulhreza/hugging-face-for-laravel)[ Packagist](https://packagist.org/packages/rezaulhreza/hugging-face-for-laravel)[ Docs](https://github.com/rezaulhreza/hugging-face-for-laravel)[ GitHub Sponsors](https://github.com/Rezaulhreza)[ RSS](/packages/rezaulhreza-hugging-face-for-laravel/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (12)Versions (9)Used By (0)

HuggingFace for Laravel
=======================

[](#huggingface-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4626491c5da8054f93b076d5130ce74f01d2bc7e0783b6987a6d0c7d14d01ed3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72657a61756c6872657a612f68756767696e672d666163652d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rezaulhreza/hugging-face-for-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f63890f331ac248d576c4557f4636b0bf2531506e031436cab09f5a0d6c58334/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f72657a61756c6872657a612f68756767696e672d666163652d666f722d6c61726176656c2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/rezaulhreza/hugging-face-for-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/99fc19d8bc087a365a444ca3b048c172efa8dd04347c531c46785ea2aea11705/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72657a61756c6872657a612f68756767696e672d666163652d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rezaulhreza/hugging-face-for-laravel)

A Laravel package that provides seamless integration with HuggingFace AI models for text generation and image creation.

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

[](#installation)

Install the package via composer:

```
composer require rezaulhreza/hugging-face-for-laravel
```

You can publish the config file with:

```
php artisan vendor:publish --tag="hugging-face-config"
```

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

[](#configuration)

Add your HuggingFace API key to your `.env` file:

```
HUGGINGFACE_API_KEY=your-api-key-here
```

Usage
-----

[](#usage)

### Text Generation

[](#text-generation)

```
use Rezaulhreza\HuggingFace\Facades\HuggingFace;
// Generate text
$response = HuggingFace::getResponse(
prompt: "What is artificial intelligence?",
model: "meta-llama/Meta-Llama-3-8B-Instruct"
);
```

// Access the generated text

```
$generatedText = $response['text'];
```

### Image Generation

[](#image-generation)

```
// Generate image
$response = HuggingFace::getResponse(
prompt: "A beautiful sunset",
model: "CompVis/stable-diffusion-v1-4"
);
```

Response will contain a base64 encoded image string.

### Custom Model Types

[](#custom-model-types)

When using a model that's not pre-configured, you can specify the model type:

```
$response = HuggingFace::getResponse(
prompt: "What is artificial intelligence?",
model: "custom-model",
type: "text",
options: ['type' => 'text']
);
```

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

[](#error-handling)

The package includes comprehensive error handling. Failed requests will return `null` and log the error details. You can catch specific exceptions:

```
try {
$response = HuggingFace::getResponse(prompt: "What is artificial intelligence?", model: "unknown-model");
} catch (\Exception $e) {
// Handle the exception
}
```

Supported Model Types
---------------------

[](#supported-model-types)

The package supports various model types out of the box:

- Text Generation (`text-generation`)
- Text-to-Text Generation (`text2text-generation`)
- Question Answering (`question-answering`)
- Summarization (`summarization`)
- Translation (`translation`)
- Text Classification (`text-classification`)
- Image Classification (`image-classification`)
- Image Segmentation (`image-segmentation`)
- Image-to-Text (`image-to-text`)
- Text-to-Image (`text-to-image`)
- Image-to-Image (`image-to-image`)
- Visual Question Answering (`visual-question-answering`)

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance65

Regular maintenance activity

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.9% 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 ~0 days

Total

3

Last Release

507d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/56729226?v=4)[Rezaul H Reza](/maintainers/rezaulhreza)[@rezaulhreza](https://github.com/rezaulhreza)

---

Top Contributors

[![rezaulhreza](https://avatars.githubusercontent.com/u/56729226?v=4)](https://github.com/rezaulhreza "rezaulhreza (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelrezaulhrezahugging-face-for-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/rezaulhreza-hugging-face-for-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/rezaulhreza-hugging-face-for-laravel/health.svg)](https://phpackages.com/packages/rezaulhreza-hugging-face-for-laravel)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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