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)155[4 PRs](https://github.com/rezaulhreza/hugging-face-for-laravel/pulls)MITPHPPHP ^8.2CI passing

Since Feb 11Pushed 1mo 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 1mo ago

READMEChangelog (3)Dependencies (12)Versions (8)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

39

—

LowBetter than 86% of packages

Maintenance70

Regular maintenance activity

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

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

454d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c76a13a308db8b3693769c9914502f28134a94cc352ec2e18f0dc08f9a2e991?d=identicon)[rezaulhreza](/maintainers/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-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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