Baseten 接入 Hugging Face 推理服务商

原标题:Baseten on Hugging Face Inference Providers 🔥
32AI 研判分

Baseten 正式成为 Hugging Face Hub 的受支持推理服务商,用户可直接通过 HF 接口调用 Baseten 托管模型。该集成采用成本直通模式,无额外加价,PRO 用户每月可获 2 美元跨服务商通用额度。

报道正文

本文目录8 个章节

返回文章列表

Baseten 正式成为 Hugging Face Inference Providers 🔥

发布于 2026 年 8 月 6 日 在 GitHub 上更新 点赞 36

Alex Ker alexker-baseten baseten Roland Crosby rolandcrosby-baseten baseten Sid Shanker squidarth baseten Johan johan-baseten baseten Célina Hanouti celinah Simon Brandeis sbrandeis Lucain Pouget Wauplin merve merve

banner image

我们很高兴地宣布,Baseten 现已成为 Hugging Face Hub 上受支持的 Inference Provider!

Baseten 加入了我们不断壮大的生态系统,进一步拓展了 Hub 模型页面上 serverless inference 的广度与能力。Inference Providers 还无缝集成到了我们的客户端 SDK(支持 JS 和 Python)中,让你能够轻松使用各种模型并选择偏好的 provider。

Baseten 是一个 AI 基础设施平台,涵盖 serverless AI、训练等领域。凭借丰富的前沿模型目录,Baseten 让开发者能够以极少的配置工作,将广泛的 AI 功能集成到其应用中。

Baseten 支持多种类型的模型——从 LLMs 到 text-to-speech 等。作为此次初步集成的一部分,Baseten 正在 Hugging Face 上推出对 conversational 和 text-generation tasks 的支持,从而让用户能够访问诸如 Kimi K3、最新的 DeepSeek V4 Flash、GLM-5.2 等热门开源权重 LLMs。更多任务的支持即将推出!

查看 Baseten 支持的全部模型列表,请点击此处。

在 Hugging Face 上关注 Baseten:https://huggingface.co/baseten。

工作原理

在网站 UI 中

  1. 在你的用户账户设置中,你可以:
  • 为你已注册的提供商设置自己的 API 密钥。如果未设置自定义密钥,你的请求将通过 HF 路由。
  • 按偏好对提供商进行排序。此设置适用于模型页面中的小部件和代码片段。

Inference Providers

  1. 如前所述,调用 Inference Providers 时有两种模式:
  • 自定义密钥(请求直接发送至推理提供商,使用你对应推理提供商的自有 API 密钥)
  • 由 HF 路由(在这种情况下,你无需提供商的令牌,费用将直接计入你的 HF 账户,而非提供商账户)

Inference Providers

  1. 模型页面会展示第三方推理提供商(即与当前模型兼容的提供商,并按用户偏好排序)

Inference Providers

从客户端 SDK

Baseten 可通过 Hugging Face SDKs 使用——Python 需使用 huggingface_hub (>= 1.26.1),JavaScript 需使用 @huggingface/inference。

以下示例展示了如何通过 Baseten 使用最新的 DeepSeek V4 Flash。请使用 Hugging Face token 进行身份验证——请求将自动路由至 Baseten。

从你常用的 Agent Harness

Hugging Face Inference Providers 已集成到大多数 Agent Harness 中——包括 Pi、OpenCode、Hermes Agents、OpenClaw 等。这意味着你可以直接将 Baseten 托管的模型接入你常用的工具,无需额外的胶水代码。浏览完整的集成列表,请点击此处。

从 Python

PYTHON
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://router.huggingface.co/v1",
    api_key=os.environ["HF_TOKEN"],
)

completion = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Flash-0731:baseten",
    messages=[
        {
            "role": "user",
            "content": "Write a Python function that returns the nth Fibonacci number using memoization."
        }
    ],
)

print(completion.choices[0].message)

from JS

JAVASCRIPT
import { OpenAI } from "openai";

const client = new OpenAI({
    baseURL: "https://router.huggingface.co/v1",
    apiKey: process.env.HF_TOKEN,
});

const chatCompletion = await client.chat.completions.create({
    model: "deepseek-ai/DeepSeek-V4-Flash-0731:baseten",
    messages: [
        {
            role: "user",
            content: "Write a Python function that returns the nth Fibonacci number using memoization.",
        },
    ],
});

console.log(chatCompletion.choices[0].message);

Billing

For direct requests, i.e. when you use the key from an inference provider, you are billed by the corresponding provider. For instance, if you use a baseten API key you're billed on your baseten account.

For routed requests, i.e. when you authenticate via the Hugging Face Hub, you'll only pay the standard provider API rates. There's no additional markup from us; we just pass through the provider costs directly. (In the future, we may establish revenue-sharing agreements with our provider partners.)

Important Note ‼️ PRO users get $2 worth of Inference credits every month. You can use them across providers. 🔥