PHPackages                             symfony/ai-hugging-face-platform - 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. symfony/ai-hugging-face-platform

ActiveSymfony-ai-platform[API Development](/categories/api)

symfony/ai-hugging-face-platform
================================

HuggingFace platform bridge for Symfony AI

v0.10.0(2w ago)37.0k↑18.4%3MITPHPPHP &gt;=8.2

Since Dec 23Pushed 1w agoCompare

[ Source](https://github.com/symfony/ai-hugging-face-platform)[ Packagist](https://packagist.org/packages/symfony/ai-hugging-face-platform)[ Fund](https://symfony.com/sponsor)[ GitHub Sponsors](https://github.com/fabpot)[ RSS](/packages/symfony-ai-hugging-face-platform/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (8)Dependencies (28)Versions (11)Used By (3)

HuggingFace Bridge
==================

[](#huggingface-bridge)

The HuggingFace bridge provides integration with the [HuggingFace Inference API](https://huggingface.co/docs/inference-api/index), enabling access to thousands of pre-trained models for various AI tasks including natural language processing, computer vision, audio processing, and more.

HuggingFace Documentation
-------------------------

[](#huggingface-documentation)

- [Inference Providers overview](https://huggingface.co/docs/inference-providers/index)
- [Tasks reference](https://huggingface.co/docs/inference-providers/tasks/index)
- [Authentication / access tokens](https://huggingface.co/docs/hub/en/security-tokens)

Features
--------

[](#features)

- **Multi-Provider Support**: Access models through multiple inference providers (HuggingFace Inference, Cerebras, Cohere, Groq, Together, and others)
- **Comprehensive Task Support**: Support for 40+ different AI tasks including:
    - Chat completion and text generation
    - Image classification, object detection, and segmentation
    - Automatic speech recognition and audio classification
    - Text classification, translation, summarization
    - Feature extraction and embeddings
    - And many more...
- **Model Discovery**: Built-in API client to discover and query available models
- **Flexible Input/Output**: Support for text, images, audio, and binary data
- **Type-Safe Results**: Structured result objects for each task type

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

[](#installation)

Install the `symfony/ai-hugging-face-platform` package:

```
composer require symfony/ai-hugging-face-platform
```

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

[](#quick-start)

### Initialize the Platform

[](#initialize-the-platform)

```
use Symfony\AI\Platform\Bridge\HuggingFace\Factory;
use Symfony\AI\Platform\Bridge\HuggingFace\Provider;

$platform = Factory::createPlatform(
    apiKey: 'hf_your_api_key_here',
    provider: Provider::CEREBRAS, // or other providers
    httpClient: $httpClient  // optional, uses default if not provided
);
```

### Chat Completion Example

[](#chat-completion-example)

```
use Symfony\AI\Platform\Bridge\HuggingFace\Task;
use Symfony\AI\Platform\Message\Message;
use Symfony\AI\Platform\Message\MessageBag;

$messages = new MessageBag(
    Message::ofUser('Hello, how are you doing today?')
);

$result = $platform->invoke('HuggingFaceH4/zephyr-7b-beta', $messages, [
    'task' => Task::CHAT_COMPLETION,
]);

echo $result->asText();
```

### Image Classification Example

[](#image-classification-example)

```
use Symfony\AI\Platform\Bridge\HuggingFace\Task;
use Symfony\AI\Platform\Message\Content\Image;

$image = Image::fromFile('/path/to/image.jpg');

$result = $platform->invoke('google/vit-base-patch16-224', $image, [
    'task' => Task::IMAGE_CLASSIFICATION,
]);

$classifications = $result->asObject()->getClassifications();
foreach ($classifications as $classification) {
    echo $classification->getLabel() . ': ' . $classification->getScore() . PHP_EOL;
}
```

### Feature Extraction (Embeddings)

[](#feature-extraction-embeddings)

```
$result = $platform->invoke('sentence-transformers/all-MiniLM-L6-v2', 'Hello world', [
    'task' => Task::FEATURE_EXTRACTION,
]);

$vectors = $result->asVectors();
```

Providers
---------

[](#providers)

The bridge supports multiple inference providers. For a complete list of available providers and their constants, see the [`Provider` interface](./Provider.php).

Specify a provider when creating the platform:

```
use Symfony\AI\Platform\Bridge\HuggingFace\Factory;
use Symfony\AI\Platform\Bridge\HuggingFace\Provider;

$platform = Factory::createPlatform(
    apiKey: 'your_api_key',
    provider: Provider::GROQ,
);
```

Supported Tasks
---------------

[](#supported-tasks)

The bridge supports 40+ AI tasks across multiple categories including:

- **Natural Language Processing**: Chat completion, text generation, classification, translation, summarization, embeddings, and more
- **Computer Vision**: Image classification, object detection, segmentation, depth estimation, and more
- **Audio**: Speech recognition, audio classification, text-to-speech, and more
- **Multimodal**: Visual question answering, document understanding, and more

For the complete list of supported tasks and their constants, see the [`Task` interface](./Task.php).

Model Discovery
---------------

[](#model-discovery)

The bridge includes commands to discover available models without using inference credits. They help to research and use models, and can be registered in a Symfony Console application.

### Command-Line Interface

[](#command-line-interface)

The HuggingFace bridge provides two console commands for model discovery:

#### List Models

[](#list-models)

List available models with optional filtering:

```
ai:huggingface:model-list [options]
```

Options:

- `--provider, -p`: Filter by inference provider (e.g., `inference`)
- `--task, -t`: Filter by task type (e.g., `text-generation`)
- `--search, -s`: Search term to filter models
- `--warm, -w`: Only list models with warm inference (ready without cold start)

Examples:

```
# List all text generation models
ai:huggingface:model-list --task=text-generation

# List warm models for a specific provider
ai:huggingface:model-list --provider=hf-inference --warm

# Search for specific models
ai:huggingface:model-list --search=llama
```

#### Get Model Information

[](#get-model-information)

Retrieve detailed information about a specific model:

```
ai:huggingface:model-info
```

Examples:

```
# Get information about a specific model
ai:huggingface:model-info meta-llama/Llama-2-7b-chat
ai:huggingface:model-info gpt2
```

Output includes:

- Model ID, downloads, and community likes
- Task type (pipeline tag)
- Inference status (warm/cold)
- Inference provider mappings and availability

Options and Configuration
-------------------------

[](#options-and-configuration)

When invoking the platform, you can pass task-specific options:

```
$result = $platform->invoke('model/id', $input, [
    'task' => Task::TEXT_GENERATION,
    'temperature' => 0.7,
    'top_p' => 0.9,
    'top_k' => 50,
    'max_new_tokens' => 256,
    'repetition_penalty' => 1.2,
    // ... other provider-specific parameters
]);
```

You can also override the provider per request:

```
$result = $platform->invoke('model/id', $input, [
    'task' => Task::CHAT_COMPLETION,
    'provider' => Provider::GROQ,  // Override default provider
]);
```

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance97

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69% 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 ~19 days

Recently: every ~25 days

Total

10

Last Release

19d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47313?v=4)[Fabien Potencier](/maintainers/fabpot)[@fabpot](https://github.com/fabpot)

---

Top Contributors

[![chr-hertel](https://avatars.githubusercontent.com/u/2852185?v=4)](https://github.com/chr-hertel "chr-hertel (40 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (12 commits)")[![Guikingone](https://avatars.githubusercontent.com/u/13744329?v=4)](https://github.com/Guikingone "Guikingone (1 commits)")[![nicolas-grekas](https://avatars.githubusercontent.com/u/243674?v=4)](https://github.com/nicolas-grekas "nicolas-grekas (1 commits)")[![VincentLanglet](https://avatars.githubusercontent.com/u/9052536?v=4)](https://github.com/VincentLanglet "VincentLanglet (1 commits)")[![bernard-ng](https://avatars.githubusercontent.com/u/31113941?v=4)](https://github.com/bernard-ng "bernard-ng (1 commits)")[![wachterjohannes](https://avatars.githubusercontent.com/u/1464615?v=4)](https://github.com/wachterjohannes "wachterjohannes (1 commits)")[![DZunke](https://avatars.githubusercontent.com/u/1244235?v=4)](https://github.com/DZunke "DZunke (1 commits)")

---

Tags

aibridgehuggingfacellmplatformsymfonysymfony-aiaiplatformBridgehuggingface

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/symfony-ai-hugging-face-platform/health.svg)

```
[![Health](https://phpackages.com/badges/symfony-ai-hugging-face-platform/health.svg)](https://phpackages.com/packages/symfony-ai-hugging-face-platform)
```

PHPackages © 2026

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