Provider Slug.
huggingface
Portkey SDK Integration with Huggingface
Portkey provides a consistent API to interact with models from various providers. To integrate Huggingface with Portkey:1. Install the Portkey SDK
Add the Portkey SDK to your application to interact with Huggingface’s API through Portkey’s gateway.2. Initialize Portkey with the Virtual Key
To use Huggingface with Portkey, get your Huggingface Access token from here, then add it to Portkey to create the virtual key.3. Invoke Chat Completions with Huggingface
Use the Portkey instance to send requests to Huggingface. You can also override the virtual key directly in the API call if needed.Using Virtual Keys
Virtual Keys serve as Portkey’s unified authentication system for all LLM interactions, simplifying the use of multiple providers and Portkey features within your application. For self-hosted LLMs, you can configure custom authentication requirements including authorization keys, bearer tokens, or any other headers needed to access your model:
- Navigate to Virtual Keys in your Portkey dashboard
- Click “Add Key” and enable the “Local/Privately hosted provider” toggle
- Configure your deployment:
- Select the matching provider API specification (typically
OpenAI
) - Enter your model’s base URL in the
Custom Host
field - Add required authentication headers and their values
- Select the matching provider API specification (typically
- Click “Create” to generate your virtual key