推理提供商文件

Hub API

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

Hub API

Hub 提供了一些與推理提供商互動的 API。以下是它們的列表:

列出模型

要列出由提供商支援的模型,請使用 inference_provider 查詢引數

# List all models served by Fireworks AI
~ curl -s https://huggingface.co/api/models?inference_provider=fireworks-ai | jq ".[].id"
"deepseek-ai/DeepSeek-V3-0324"
"deepseek-ai/DeepSeek-R1"
"Qwen/QwQ-32B"
"deepseek-ai/DeepSeek-V3"
...

它可以與其他篩選器結合使用,例如只選擇 text-to-image 模型

# List text-to-image models served by Fal AI
~ curl -s https://huggingface.co/api/models?inference_provider=fal-ai&pipeline_tag=text-to-image | jq ".[].id"
"black-forest-labs/FLUX.1-dev"
"stabilityai/stable-diffusion-3.5-large"
"black-forest-labs/FLUX.1-schnell"
"stabilityai/stable-diffusion-3.5-large-turbo"
...

傳遞一個逗號分隔的提供商列表以選擇多個提供商

# List image-text-to-text models served by Novita or Sambanova
~ curl -s https://huggingface.co/api/models?inference_provider=sambanova,novita&pipeline_tag=image-text-to-text | jq ".[].id"
"meta-llama/Llama-3.2-11B-Vision-Instruct"
"meta-llama/Llama-3.2-90B-Vision-Instruct"
"Qwen/Qwen2-VL-72B-Instruct"

最後,您可以選擇由至少一個推理提供商服務的所有模型

# List text-to-video models served by any provider
~ curl -s https://huggingface.co/api/models?inference_provider=all&pipeline_tag=text-to-video | jq ".[].id"
"Wan-AI/Wan2.1-T2V-14B"
"Lightricks/LTX-Video"
"tencent/HunyuanVideo"
"Wan-AI/Wan2.1-T2V-1.3B"
"THUDM/CogVideoX-5b"
"genmo/mochi-1-preview"
"BagOu22/Lora_HKLPAZ"

獲取模型狀態

要為特定模型查詢推理提供商,請在模型資訊端點中請求 inference 屬性

Python
cURL

huggingface_hub 中,使用帶有 expand 引數的 model_info

>>> from huggingface_hub import model_info

>>> info = model_info("google/gemma-3-27b-it", expand="inference")
>>> info.inference
'warm'

推理狀態要麼是“warm”,要麼是未定義

Python
cURL

huggingface_hub 中,使用帶有 expand 引數的 model_info

>>> from huggingface_hub import model_info

>>> info = model_info("manycore-research/SpatialLM-Llama-1B", expand="inference")
>>> info.inference
None

獲取模型提供商

如果您對特定模型感興趣並希望檢查為其提供服務的提供商列表,您可以在模型資訊端點中請求 inferenceProviderMapping 屬性

Python
cURL

huggingface_hub 中,使用帶有 expand 引數的 model_info

>>> from huggingface_hub import model_info

>>> info = model_info("google/gemma-3-27b-it", expand="inferenceProviderMapping")
>>> info.inference_provider_mapping
{
    'hf-inference': InferenceProviderMapping(status='live', provider_id='google/gemma-3-27b-it', task='conversational'),
    'nebius': InferenceProviderMapping(status='live', provider_id='google/gemma-3-27b-it-fast', task='conversational'),
}

每個為模型提供服務的提供商都會顯示狀態(staginglive)、相關任務(此處為 conversational)和提供商 ID。實際上,此資訊與 JS 和 Python 客戶端相關。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.