Hugging Face integration
This documentation provides a concise guide for developers to integrate and use Fireworks.ai inference capabilities via the Hugging Face ecosystem.Authentication and billing
When using Fireworks.ai through Hugging Face, you have two options for authentication:- Direct Requests: Use your Fireworks.ai API key in your Hugging Face user account settings. In this mode, inference requests are sent directly to Fireworks.ai, and billing is handled by your Fireworks.ai account.
- Routed Requests: If you don’t configure a Fireworks.ai API key, your requests will be routed through Hugging Face. In this case, you can use a Hugging Face token for authentication. Billing for routed requests is applied to your Hugging Face account at standard provider API rates. You don’t need an account on Fireworks.ai to do this, just use your HF one!
- Go to your Hugging Face user account settings.
- Locate the “Inference Providers” section.
- You can add your API keys for different providers, including Fireworks.ai
- You can also set your preferred provider order, which will influence the display order in model widgets and code snippets.
You can search for all Fireworks.ai models on the hub and directly try out the available models via the Model Page widget too.
Usage examples
The examples below demonstrate how to interact with various models using Python and JavaScript. First, ensure you have thehuggingface_hub
library installed (version v0.29.0 or later):
- Chat Completion (LLMs) with Hugging Face Hub library
- Vision Language Models (VLMs) with Hugging Face Hub Library
base_url
and model
parameters in the client and call respectively.
The easiest way is to go to a model’s page on the hub and copy the snippet.
- Text-to-Image Generation