Hugging Face 接入 Fireworks.ai 推理服务
Hugging Face Hub 正式将 Fireworks.ai 纳入其 Inference Providers 体系,允许用户在模型页面直接调用该服务商的高速无服务器推理 API。此举旨在简化开发者在 HF 生态中运行大模型推理的流程,PRO 用户每月可获得 2 美元跨服务商通用的推理额度。
报道正文
本文目录8 个章节
欢迎 Fireworks.ai 入驻 Hub 🎆
发布于 2025 年 2 月 14 日 在 GitHub 上更新 点赞 59
Teo Feliu teofeliu fireworks-ai Shaunak Godbole shaunak-fireworks fireworks-ai Julien Chaumond julien-c
继我们近期发布关于 Hub 上的推理提供商(Inference Providers)的公告后,我们很高兴地宣布:Fireworks.ai 现已成为 HF Hub 支持的推理提供商!
Fireworks.ai 直接在模型页面以及整个 HF 库和工具生态系统中提供极速的无服务器推理服务,使运行你喜爱模型的推理变得前所未有的简单。

从现在起,你可以通过 Fireworks.ai 对以下模型运行无服务器推理:
- deepseek-ai/DeepSeek-R1
- deepseek-ai/DeepSeek-V3
- mistralai/Mistral-Small-24B-Instruct-2501
- Qwen/Qwen2.5-Coder-32B-Instruct
- meta-llama/Llama-3.2-90B-Vision-Instruct
以及更多模型,完整列表可在此处找到。
立即使用 Fireworks.ai 为你的项目注入活力吧!
工作原理
在网站 UI 中
在 HF 此处 搜索所有由 Fireworks 支持的模型。
从客户端 SDK 调用
使用 Python 中的 huggingface_hub
以下示例展示了如何使用 Fireworks.ai 作为推理提供商来调用 DeepSeek-R1。你可以使用 Hugging Face token 通过 Hugging Face 进行自动路由,或者如果你拥有自己的 Fireworks.ai API key,也可以直接使用它。
从源码安装 huggingface_hub:
pip install git+https://github.com/huggingface/huggingface_hub使用 huggingface_hub Python 库调用 Fireworks.ai 端点,只需定义 provider 参数即可。
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="fireworks-ai",
api_key="xxxxxxxxxxxxxxxxxxxxxxxx"
)
messages = [
{
"role": "user",
"content": "What is the capital of France?"
}
]
completion = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1",
messages=messages,
max_tokens=500
)
print(completion.choices[0].message)在 JS 中使用 @huggingface/inference
import { HfInference } from "@huggingface/inference";
const client = new HfInference("xxxxxxxxxxxxxxxxxxxxxxxx");
const chatCompletion = await client.chatCompletion({
model: "deepseek-ai/DeepSeek-R1",
messages: [
{
role: "user",
content: "How to make extremely spicy Mayonnaise?"
}
],
provider: "fireworks-ai",
max_tokens: 500
});
console.log(chatCompletion.choices[0].message);通过 HTTP 请求调用
以下是如何通过 cURL 使用 Fireworks.ai 作为推理提供商来调用 Llama-3.3-70B-Instruct 的示例。
curl 'https://router.huggingface.co/fireworks-ai/v1/chat/completions' \
-H 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
--data '{
"model": "accounts/fireworks/models/llama-v3p3-70b-instruct",
"messages": [
{
"role": "user",
"content": "What is the meaning of life if you were a dog?"
}
],
"max_tokens": 500,
"stream": false
}'计费
对于直接请求(即当你使用 Fireworks key 时),费用将直接在您的 Fireworks 账户中结算。
对于路由请求(即当你通过 hub 进行身份验证时),你只需支付标准的 Fireworks API 费率。我们不会收取任何额外加价,只是直接透传提供商的成本。(未来,我们可能会与我们的合作伙伴建立收入分成协议。)
重要提示 ‼️ PRO 用户每月可获得价值 2 美元的推理(Inference)额度。这些额度可在各服务商之间通用。🔥
