Hugging Face
Hugging Face is a leading open-source and open-science AI platform. Its core includes the Hugging Face Hub for models/datasets/Spaces, inference and hosting (Inference Providers and Inference Endpoints), and a rich ecosystem of open-source libraries (Transformers, Diffusers, Datasets, Tokenizers, Accelerate, PEFT, TRL, Safetensors, Transformers.js, smolagents, Text Generation Inference, etc.). The platform supports text, image, audio, video and 3D modalities with unified access via Python, JavaScript and REST/OpenAI-compatible endpoints.
支持模型
API 接口列表
Paginated list of models on the Hub with query params like `search`, `author`, `filter`, `sort`, `direction`, `limit`, `full`, `config`.
Return detailed information for a specific model repo. Supports `revision`.
Paginated list of datasets on the Hub with similar filter/sort params as models.
OpenAI-compatible chat completions. `model` requires a provider suffix or `:auto`/`:fastest`/`:cheapest` policy; supports `image_url` in messages. Officially covers Chat Completions only.
{
"model": "deepseek-ai/DeepSeek-R1:fastest",
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
}(Where applicable) OpenAI-compatible Responses API for advanced event streaming, structured outputs, and tool calling (e.g., gpt-oss family).
{
"model": "openai/gpt-oss-120b:cerebras",
"input": "Tell me a fun fact about the Eiffel Tower."
}Serverless Inference API to run inference for a specified model; request/response depends on task (text generation, image generation, ASR, etc.).
curl -s -H 'Authorization: Bearer $HF_TOKEN' -H 'Content-Type: application/json' https://api-inference.huggingface.co/models/{model_id}OpenAI-compatible Chat Completions on dedicated Inference Endpoints (TGI), requires the endpoint-specific `hf_...` API key.
{
"model": "meta-llama/Meta-Llama-3-8B-Instruct",
"messages": [
{
"role": "user",
"content": "Explain transformers in one sentence."
}
]
}Text-to-image generation example. The request is a text prompt; response is image binary or base64.
{
"inputs": "A steampunk airship in the clouds"
}ASR example. Upload audio or bytes and receive transcribed text.
curl -s -H 'Authorization: Bearer $HF_TOKEN' -H 'Content-Type: audio/wav' --data-binary @sample.wav https://api-inference.huggingface.co/models/openai/whisper-large-v3
Hub API OpenAPI specification to generate clients and view all endpoints.