Skip to main content

Quick Start

Get started with Hugging Face in under 2 minutes:
from portkey_ai import Portkey

# 1. Install: pip install portkey-ai
# 2. Add @huggingface provider in model catalog
# 3. Use it:

portkey = Portkey(api_key="PORTKEY_API_KEY")

response = portkey.chat.completions.create(
    model="@huggingface/meta-llama/Llama-3.2-3B-Instruct",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices[0].message.content)

Add Provider in Model Catalog

Before making requests, add Hugging Face to your Model Catalog:
  1. Go to Model Catalog → Add Provider
  2. Select Hugging Face
  3. Enter your Hugging Face access token
  4. (Optional) Add a Custom Host if using a dedicated Hugging Face Inference Endpoint
  5. Name your provider (e.g., huggingface)
If you have a dedicated server hosted on Hugging Face, enter your dedicated endpoint URL in the Custom Host field during provider setup. This allows you to route requests to your private Hugging Face deployment.

Complete Setup Guide

See all setup options and detailed configuration instructions

Supported Models

Hugging Face provides access to thousands of text generation models through their Inference endpoints, including:
  • Meta Llama 3.2, Llama 3.1, Llama 3
  • Mistral, Mixtral
  • Qwen 2.5
  • Phi-3
  • Gemma, Gemma 2
  • And thousands more!
Browse the complete catalog at Hugging Face Models.

Next Steps

For complete SDK documentation:

SDK Reference

Complete Portkey SDK documentation