Hugging Face Inference Providers Integration
Hugging Faceは、fal、Replicate、SambaNova、そしてTogether AIの4つのサーバーレス推論プロバイダーをHubのモデルページとクライアントSDKに直接統合しました。これにより、Hubは独自のサーバーレスInference APIをホストするのではなく、専門的なサーバーレスプロバイダーの多様なエコシステムへの統合アクセスを提供する方向に移行しました。
統合サーバーレス推論アクセス
ユーザーは今ではHubから直接、さまざまなモデルのサーバーレス推論にアクセスできます。この統合により、別途インフラストラクチャを管理することなく、DeepSeek-R1やFLUX.1-devなどのモデルの探索とプロトタイピングが容易になります。
ウェブサイトUI統合
Hubのユーザーアカウント設定では、ユーザーは2つの主要な方法で推論体験を管理できます:
- カスタムAPIキー: ユーザーは特定のプロバイダー向けに自分のAPIキーを設定できます。これらのキーを使用したリクエストは直接プロバイダーに送信されます。
- プロバイダーの優先順位: ユーザーは優先順位に従ってプロバイダーを並べ替えることができ、これがモデルページのウィジェットやコードスニペットでの表示方法を決定します。
ルーティングモード
このシステムを通じてInference APIを呼び出すには、2つの異なるモードがあります:
- カスタムキーモード: ユーザーのそのプロバイダー用の独自のAPIキーを使用して、呼び出しは直接推論プロバイダーに送信されます。
- HFによるルーティング: リクエストはHugging Faceを経由してルーティングされます。このモードでは、ユーザーはプロバイダー固有のトークンが必要なく、料金は直接Hugging Faceアカウントに適用されます。
技術的実装とSDK
Python統合
Using the huggingface_hub library (v0.28.0 or later), developers can specify a provider in the InferenceClient:
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="together",
api_key="xxxxxxxxxxxxxxxxxxxxxxxx"
)
completion = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1",
messages=[{"role": "user", "content": "What is the capital of France?"}],
max_tokens=500
)
JavaScript統合
Developers using @huggingface/inference can pass the provider argument within the chatCompletion method:
import { HfInference } from "@huggingface/inference\);\n\nconst client = new HfInference("xxxxxxxxxxxxxxxxxxxxxxxx");\n\nconst chatCompletion = await client.chatCompletion({\n model: "deepseek-ai/DeepSeek-R1",\n provider: "together",\n max_tokens: 500\n});
HTTPルーティングプロキシ
Hugging Face exposes a routing proxy under the huggingface.co domain, enabling OpenAI-compatible API calls via the URL structure: https://router.huggingface.co/{provider}.
請求とクレジット
Billing depends on the chosen routing mode:
- 直接リクエスト: ユーザーは、自分のプロバイダーアカウントを使用して、推論プロバイダーから直接請求されます。
- ルーティングリクエスト: ユーザーは、Hugging Faceによって追加のマークアップなしで渡される標準のプロバイダーAPIレートを支払います。
Hugging Face PROユーザーは、プロバイダー全体で使用できる毎月2ドル分のInferenceクレジットを受け取ります。サインイン済みの無料ユーザーには、少量の無料推論クォータが提供されます。
コミュニティフィードバックと視点
Community discussion on the announcement has highlighted several points of contention and technical hurdles:
"以前のプロは20,000リクエストを提供していました。今ではそれがなくなりました。残念です。"
"これは悪い決定だと思います。9ドルを支払ったのに、わずか2ドルしか使っていません。以前は1日あたり20kの制限がありました。"
Users have reported issues with InferenceClient.__init__() receiving unexpected keyword arguments for those not updated to the latest library version, as well as 403 Forbidden errors regarding permissions when calling Inference Providers on behalf of a user.