Machine Learning — entry 007 of 24
Hugging Face
Hugging Face's Inference Providers route requests to a network of partner GPU providers (Groq, Together, Fireworks, Replicate, and more) behind one OpenAI-compatible API and a single HF token, covering chat, image, video, and embedding models. It replaced the older standalone Inference API, offering a free tier plus extra credits for PRO and Enterprise accounts, with no markup added on top of provider rates. The Hub itself still hosts hundreds of thousands of open models and datasets alongside the inference layer.
Hugging Face's Inference Providers route chat, embedding, and image requests to a network of partner GPU providers (Groq, Together, Fireworks, and more) behind one OpenAI-compatible API, authenticated with a single HF token — replacing the older standalone Inference API.
GreatAPIs Score
Auth quickstart
- Create a free Hugging Face account at huggingface.co
- Generate a fine-grained token with the 'Make calls to Inference Providers' permission at hf.co/settings/tokens/new
- Send it as an `Authorization: Bearer YOUR_API_KEY` header on every request
Your key is stored only in this browser (localStorage) and sent directly to the API — never to greatapis.
Chat completion via the OpenAI-compatible endpoint
POSThttps://router.huggingface.co/v1/chat/completions
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"model": "openai/gpt-oss-120b:fastest",
"messages": [
{ "role": "user", "content": "How many G's in huggingface?" }
]
}{
"id": "chatcmpl-abc123",
"model": "openai/gpt-oss-120b",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "There are 2 G's in \"huggingface\"." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 15, "completion_tokens": 12, "total_tokens": 27 }
}Developer reference
Gotchas & limits
- The base URL is `router.huggingface.co/v1`, not the old `api-inference.huggingface.co` — the legacy standalone Inference API has been replaced by Inference Providers
- Append `:fastest`, `:cheapest`, or `:preferred` to the model id to control provider routing (e.g. `openai/gpt-oss-120b:cheapest`) — the default policy is `:fastest`
- The OpenAI-compatible `/v1/chat/completions` endpoint only covers chat tasks — embeddings, image, and audio tasks require the `huggingface_hub` InferenceClient or JS SDK instead