Hub documentation

推論プロバイダー

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

推論プロバイダー

Hugging Faceのモデルページでは、数千のモデルに対して従量課金制の推論が利用可能であり、ブラウザ上でそのまま試すことができます。このサービスはInference Providersによって提供されており、PROユーザーおよびTeam & Enterprise組織には月間のクレジットが含まれています。

Inference Providersは、最高のサーバーレス推論パートナーによって提供される、数百の機械学習モデルへの簡素化された統合アクセスを、開発者に提供します。👉 完全なドキュメントについては、Inference Providers Documentationをご覧ください。

Hub上の推論プロバイダー

Inference Providers は Hugging Face Hub と深く統合されており、いくつかの方法で使用できます。

  • インタラクティブウィジェット - モデルページ上で、裏側でInference Providersを利用するインタラクティブウィジェットを通じて、モデルを直接テストできます。例として、DeepSeek-R1-0528モデルページをご覧ください。
  • Inference Playground - プロンプトを使用して、チャット補完モデルを簡単にテスト・比較できます。まずはInference Playgroundをご覧ください。
  • 検索 - モデルページで推論プロバイダーによってモデルを絞り込み、特定のプロバイダーを通じて利用可能なモデルを検索します。
  • Data Studio - AI を活用して Hub 上のデータセットを探索します。お気に入りのデータセットで Data Studio を試してみてください。

Inference Providersで構築

Inference Providersは、SDKまたはHTTPクライアントを使用して、ご自身のアプリケーションに統合できます。ここではPythonとJavaScriptでのクイックスタートを説明します。詳細については、Inference Providers Documentationを参照してください。

python
javascript

Python SDK を使用して、Inference Providers とのやり取りを行うことができます。

from huggingface_hub import InferenceClient

import os

client = InferenceClient(
    api_key=os.environ["HF_TOKEN"],
    provider="auto",   # Automatically selects best provider
)

# Chat completion
completion = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3-0324",
    messages=[{"role": "user", "content": "A story about hiking in the mountains"}]
)

# Image generation
image = client.text_to_image(
    prompt="A serene lake surrounded by mountains at sunset, photorealistic style",
    model="black-forest-labs/FLUX.1-dev"
)

または、OpenAI API互換のクライアントをそのまま使用することもできます。

import os
from openai import OpenAI

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

completion = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3-0324",
    messages=[
        {
            "role": "user",
            "content": "A story about hiking in the mountains"
        }
    ],
)

OpenAI API互換クライアントは、画像生成にはサポートされていません。

推論権限を持つ Hugging Face トークンが必要です。Settings > Tokens で作成してください。

Inference Providers の仕組み

Inference Providersについてさらに詳しく知りたい場合は、Inference Providers Documentationをご覧ください。主なリソースは以下の通りです:

HF-Inference APIとは何でしたか?

HF-Inference API は、Inference Providers 経由で利用可能なプロバイダーの一つです。以前は「Inference API (serverless)」と呼ばれており、内部では Inference Endpoints によって提供されています。

HF-Inferenceプロバイダーの詳細については、専用ページをご覧ください。

Update on GitHub