aisdk/huggingface

Official HuggingFace provider for the PHP AI SDK.

Maintainers

Package info

github.com/phpaisdk/huggingface

pkg:composer/aisdk/huggingface

Transparency log

Fund package maintenance!

Open Collective

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.8.1 2026-07-22 07:06 UTC

This package is auto-updated.

Last update: 2026-07-22 07:06:55 UTC


README

GitHub Workflow Status Latest Version License

Official Hugging Face provider for the PHP AI SDK. Uses Hugging Face Inference Providers' OpenAI-compatible router.

Installation

composer require aisdk/huggingface

Basic Usage

use AiSdk\Generate;
use AiSdk\HuggingFace;

HuggingFace::create(['apiKey' => $_ENV['HF_TOKEN']]);

$result = Generate::text('Explain this code briefly.')
    ->model(HuggingFace::model('openai/gpt-oss-120b:fastest'))
    ->run();

Configuration

Variable Description Default
HF_TOKEN Hugging Face access token Required
HUGGINGFACE_BASE_URL Base URL for API requests https://router.huggingface.co/v1

Supported Capabilities

Capability Support
Text generation and streaming Native OpenAI-compatible router
Tool calling, structured output, reasoning, image input Passed through for supported routed models

The OpenAI-compatible router package is chat-only. Use a Hugging Face native client for other task types. Use providerOptions('huggingface', ['raw' => [...]]) for native router fields.

Documentation