You can proxy requests to Hugging Face AI models through AI Gateway by creating AI Model Provider and AI Model entities. This reference documents all supported AI capabilities, configuration requirements, and provider-specific details needed for proper integration.
Hugging Face provider
Upstream paths
AI Gateway automatically routes requests to the appropriate Hugging Face API endpoints. The following table shows the upstream paths used for each capability.
|
Capability |
Path template |
Description |
Upstream path or API |
|---|---|---|---|
| Generate |
/chat/completions, /completions, or /responses
|
Text generation for chat completions and responses |
/v1/chat/completions
|
| Embeddings |
/embeddings
|
Vector embeddings from text input |
/hf-inference/models/{model_name}/pipeline/feature-extraction
|
| Image |
/images/generations or /images/edits
|
Image generation and editing |
/v1/images/generations
|
| Audio transcription |
/audio/transcriptions
|
Speech-to-text conversion |
/v1/audio/transcriptions
|
| Video |
/videos
|
Video generation |
/v1/videos
|
Supported capabilities
The following tables show the AI capabilities supported by the Hugging Face provider when configuring AI Models.
By default, AI Gateway uses the path templates shown in the tables below (e.g.,
/chat/completions,/embeddings, etc.). To customize these paths, configure theconfig.pathsfield in your AI Model entity. Custom paths take the form{configured_path}/{template_path}— for example, if you set a custom path of/v2, requests to/embeddingswould be routed to/v2/embeddings.
Text generation
Support for Hugging Face text generation capabilities:
|
Capability |
Streaming |
Model example |
Path template |
Min version |
|---|---|---|---|---|
| generate | Supported | Use the model name for the specific LLM provider |
/chat/completions, /completions, or /responses
|
2.0 |
Embeddings
Support for Hugging Face embeddings generation:
|
Capability |
Model example |
Path template |
Min version |
|---|---|---|---|
| embeddings | Use the embedding model name |
/embeddings
|
2.0 |
Audio
Support for Hugging Face audio capabilities (speech synthesis, transcription, and translation):
|
Capability |
Model example |
Path template |
Min version |
|---|---|---|---|
| transcription | Use the transcription model name |
/audio/transcriptions
|
2.0 |
For requests with large payloads, consider increasing
config.max_request_body_sizeon your AI Model entity to three times the raw binary size.Supported audio formats, voices, and parameters vary by model. Refer to your provider’s documentation for available options.
Image
Support for Hugging Face image generation and editing capabilities:
|
Capability |
Model example |
Path template |
Min version |
|---|---|---|---|
| image | Use the image generation model name |
/images/generations or /images/edits
|
2.0 |
For requests with large payloads, consider increasing
config.max_request_body_sizeon your AI Model entity to three times the raw binary size.Supported image sizes and formats vary by model. Refer to your provider’s documentation for allowed dimensions and requirements.
Video
Support for Hugging Face video generation capabilities:
|
Capability |
Model example |
Path template |
Min version |
|---|---|---|---|
| video | Use the video generation model name |
/videos
|
2.0 |
For requests with large payloads (video generation), consider increasing
config.max_request_body_sizeon your AI Model entity to three times the raw binary size.
Hugging Face base URL
The base URL is https://api-inference.huggingface.co.
AI Gateway uses this URL automatically. You only need to configure a URL if you’re using a self-hosted or Hugging Face-compatible endpoint, in which case set the upstream_url option in your AI Model configuration.
Supported native LLM formats for Hugging Face
By default, AI Gateway uses OpenAI-compatible request formats. Configure a native format in your AI Model to use Hugging Face-specific APIs and features.
The following native Hugging Face formats are supported:
|
LLM format |
Supported APIs |
|---|---|
huggingface
|
|
Configure Hugging Face
To use Hugging Face with AI Gateway, configure a new AI Model Provider. You can then access supported AI Models from Hugging Face.
Here’s a minimal configuration for chat completions: