,

How to Run a Hugging Face Model: Inference Providers vs Endpoints vs Self-Host (Hugging Face Series, Part 11)

Three ways to serve a Hugging Face model: the serverless Inference Providers proxy, dedicated Inference Endpoints, or self-hosting TGI on your own GPUs. A build-vs-buy verdict for the infra team that owns the bill.

Hugging Face Series · Part 11 of 17

TL;DR

There are three ways to run a model from the Hub. Inference Providers (the serverless proxy that used to be called the Inference API) is a single HF token in front of Groq, Together, Fireworks and others; you pay per token and own nothing. Inference Endpoints gives you a dedicated, autoscaling instance HF manages for you, billed by the minute at a fixed hourly rate whether or not traffic arrives. Self-host with Text Generation Inference puts the model on GPUs you own and operate. The decision is build-vs-buy plus one question most teams forget to ask: where does the request data go. My default: prototype on Providers, ship steady production on a dedicated Endpoint or self-hosted TGI, and self-host the moment data residency or sustained GPU load makes the math obvious.

Who this is for: The platform or infrastructure engineer who has been handed a working model and the question ‘how do we serve this’. You already reason about build-vs-buy, egress, quotas and capacity. This part maps those instincts onto the three Hugging Face serving paths. No data-science background needed; if you have run a container behind a load balancer, you have the mental model.

A model that runs on your laptop is not a service. The moment something else has to call it ten thousand times a day, you are no longer doing machine learning, you are doing capacity planning, cost control and access management. That is your job already. The only new vocabulary is the three doors Hugging Face gives you to walk through, and each door hands the GPU bill, the uptime and the data path to a different owner.

Think of it the way you already think about compute. You can rent a function that runs on someone else’s pool and bills per call. You can rent a dedicated VM that bills whether or not it is busy. Or you can buy the hardware and run it in your own rack. Inference Providers, Inference Endpoints and self-hosting are those same three choices, applied to a model instead of a web app. Get the analogy right and the rest is arithmetic.

Tested on: Python 3.11+, huggingface_hub 1.21 (InferenceClient). These are the versions this walkthrough was checked against in mid-2026. The Hugging Face stack moves quickly, so pin the version you install rather than pulling latest, and expect a major release to shift some defaults.

Three ways to serve, side by side

Before the detail, here is the whole decision on one screen. Read it as an infra person reads an instance-type table: who owns the box, how billing behaves when idle, and where the data goes.

 Inference ProvidersInference EndpointsSelf-host (TGI)
Who owns the GPUProviderHugging Face (managed)You
Billing modelPer token / per requestPer minute at instance rateYour hardware + ops
Cost when idleZeroFull rate (unless scaled to zero)Full (you bought it)
Where data goesThird-party providerHF-managed cloud VPCYour network
Cold startNone to noticeSeconds to minutes from zeroYou control it
Best forPrototypes, spiky/low volumeSteady production, no ops teamScale, compliance, data residency
The three serving paths compared on the axes an infra owner cares about.
From Hub to served: three owners of the GPUModel onthe HubInference Providers (serverless)GPU owned by the providerInference Endpoints (dedicated)GPU managed by Hugging FaceSelf-host TGI / vLLMGPU owned and run by youpay per tokenpay per minutepay for hardware
Same model, three owners of the bill and the data path.

Door one: Inference Providers, the serverless proxy

If you remember the old ‘Inference API’, this is its replacement and it is a bigger idea. Inference Providers is a router. You send one request with one Hugging Face token, and Hugging Face forwards it to a real inference provider behind the scenes: Groq, Together, Fireworks, Cerebras, SambaNova, HF Inference and more. You do not pick a server, a region or a GPU. You pick a model, and optionally a policy for how the router chooses among providers.

For an infra reader the useful framing is an API gateway with upstream failover. The router gives you unified authentication and one bill across many upstreams, and with automatic selection it reroutes to another provider when the primary is flagged unavailable. The endpoint is OpenAI-compatible, so existing client code mostly just changes its base URL. You can steer the routing with a suffix on the model id: append :fastest for highest throughput (the default), :cheapest for lowest price per output token, or :preferred to follow your own order.

Worked example: one call, two ways

Install the client, log in once, and hit a model. The same token works for every provider behind the router.

pip install huggingface_hub
hf auth login   # paste a token from hf.co/settings/tokens

# python
from huggingface_hub import InferenceClient
client = InferenceClient()
out = client.chat.completions.create(
    model='openai/gpt-oss-120b:cheapest',
    messages=[{'role':'user','content':'Ping'}],
)
print(out.choices[0].message.content)

Or skip the SDK and use the OpenAI-compatible route directly:

curl https://router.huggingface.co/v1/chat/completions 
  -H 'Authorization: Bearer '$HF_TOKEN 
  -H 'Content-Type: application/json' 
  -d '{"model":"openai/gpt-oss-120b:fastest","messages":[{"role":"user","content":"Ping"}]}'

Expected: a JSON chat completion with a short reply. Failure mode: a 401 means the token is missing or lacks the ‘Make calls to Inference Providers’ permission; once your free allowance is spent, requests stop until you are on a paid plan with credit on file. Fix the token scope first, then the plan.

The router: one token, many upstreamsYour app1 HF tokenHF routerauth + failoverGroqTogether / FireworksHF Inference, others
Inference Providers is a gateway with upstream failover. You manage one credential, not many.
In practice: the killer feature here is not speed, it is that you stop being on the hook for capacity. No GPU to size, no replica to scale, nothing to patch. The cost is control: you do not choose the exact hardware, your data transits a third party, and per-token pricing that looks tiny in a demo becomes the dominant line item once traffic is real. Providers is where you start, rarely where a high-volume workload ends.

Door two: Inference Endpoints, dedicated but still managed

Inference Endpoints is the rented dedicated VM of the three. You pick a model, a cloud, a region and an instance type, and Hugging Face stands up a dedicated deployment that only serves you. It autoscales between a minimum and maximum replica count, can scale to zero when idle, and runs proven engines under the hood: TGI, vLLM, SGLang and Text Embeddings Inference. You get logs, analytics, and on the enterprise tier private networking such as AWS PrivateLink. You do not manage the host, the driver stack or the serving container.

The billing is the part an infra owner has to internalize, because it does not work like Providers. You pay the instance hourly rate, by the minute, for every replica that is up, whether or not a single request arrives. An always-on T4 is not free between requests. The published formula makes it concrete:

cost = instance hourly rate * ((hours * min replicas) + (scale-up hrs * extra replicas))
Instance (single GPU)VRAMHourly rate~Monthly always-on
AWS T4 x114 GB$0.50~$365
AWS L4 x124 GB$0.80~$584
AWS A10G x124 GB$1.00~$730
AWS A100 x180 GB$2.50~$1,825
GCP H100 x180 GB$10.00~$7,300
Sample dedicated instance rates (always-on figure = rate × 730 hrs). Confirm current rates before you commit; instance menus change.

Worked example: the idle tax

Take an always-on T4 at $0.50/hr with one replica and an hourly traffic spike that adds two replicas for 15 minutes. The base is 730 hrs × 1 replica; the spikes add 182.5 hrs × 2 replicas. That is $0.50 × (730 + 365) = roughly $547.50/month. Notice that more than half the bill is the base replica that runs all night serving nobody. That single fact decides whether scale-to-zero or self-hosting is the smarter move for your traffic shape.

What this means if you run the platform: a dedicated Endpoint is a fixed monthly commitment that looks like a reserved instance, not a function. Budget it as a standing line item, set the max replica count as a hard cost ceiling the same way you cap an autoscaling group, and turn on scale-to-zero only if your latency budget can absorb a cold start. The trap is leaving a forgotten Endpoint running; a paused Endpoint costs nothing, a scaled-to-zero one still counts against quota. Put a tag and an owner on every Endpoint exactly as you would an orphaned VM.

Door three: self-host with Text Generation Inference

The third door is the one infra teams underrate because it sounds like the most work. It is also the one that gives you everything the other two take away: the hardware, the network, the data path and the unit economics. Text Generation Inference is the open-source serving container Hugging Face itself runs inside Endpoints. You can pull the same image and run it on a GPU you already own, on-prem or in your own cloud account. It is a container behind a port. You have deployed a hundred of those.

Worked example: TGI on your own GPU

One container, one model, an OpenAI-compatible endpoint on localhost:

docker run --gpus all --shm-size 1g -p 8080:80 
  -v $PWD/data:/data 
  ghcr.io/huggingface/text-generation-inference:latest 
  --model-id mistralai/Mistral-7B-Instruct-v0.3

# then call it
curl http://localhost:8080/v1/chat/completions 
  -H 'Content-Type: application/json' 
  -d '{"model":"tgi","messages":[{"role":"user","content":"Ping"}]}'

Expected: after the weights download to the mounted /data volume, a chat completion comes back on port 8080. Failure mode: a CUDA out-of-memory error means the model does not fit the card; quantize it or move to a bigger GPU. NCCL or shared-memory errors on multi-GPU usually mean --shm-size is too small. Pin the image to a tested version tag in production rather than tracking latest.

Self-hosting is where this series connects to the rest of your stack. Fitting the model on the GPUs you have is a quantization problem, covered next in Part 13. The cost-per-token math that decides whether self-hosting beats renting is the same arithmetic the NVIDIA series works through in Inference Economics. And if the driver is data residency rather than cost, running TGI inside your own VMware estate is exactly the path the Private AI series lays out. The HF model becomes the artifact; your platform becomes the runtime.

Cost vs traffic: where each door winsrequest volume →monthly cost →Providers (per token)Endpoint (flat floor)Self-host (capex amortized)
Serverless is cheapest at low volume and worst at high volume; the flat options invert that. The crossover is where your decision lives.

How to choose

Two questions settle most decisions before cost ever comes up. First: can the request data leave your boundary? If a contract, a regulator or a data-residency rule says no, doors one and two are off the table and you self-host. That is not a preference, it is a constraint, and it is the same constraint that governs where you allow any other workload to run. Second: do you have anyone to operate a GPU service? If the honest answer is no, a managed Endpoint buys you an ops team you do not have to hire. Only after those two do you reach for the cost crossover.

Must data stayinside your boundary?yesnoSelf-host TGISteady, high volume,or low and spiky?spiky/lowsteadyInference ProvidersInference Endpoint(or self-host if ops exist)Constraints first (residency, ops), cost crossover second.
The order matters: rule out paths on constraints before you optimize on price.

This is the same Hub-as-registry mental model the series opened with. The model is an artifact you pulled and vetted, the way you would push and version it on the Hub in Part 10. Serving is just deciding which runtime that artifact lands on. For the underlying concepts behind the model itself, the vendor-neutral GenAI series covers them; here we are only deciding where it runs.

Disclaimer: instance menus, rate limits and pricing on managed services change without notice, and a dedicated Endpoint bills continuously once it is running. Confirm current rates in your own account, set a max-replica cost ceiling, and test scale-to-zero behavior in a non-production project before you point real traffic at any of these paths.

Where I land

I do not treat these as three equal options to weigh fresh each time. I treat them as a ramp. Start on Inference Providers because it costs you nothing to stand up and proves the model does the job; it is the right answer for prototypes, internal tools and any workload too spiky to justify a standing GPU. It is the wrong answer the moment per-token cost crosses what a dedicated instance would cost flat, or the moment your data cannot leave your boundary. Validate that crossover with your real token volume before you assume it.

Move to a dedicated Inference Endpoint when traffic is steady, latency matters and you have no one to run GPUs. It is the wrong answer when traffic is bursty enough that you pay mostly for idle replicas, or when you do have a platform team, because at that point you are renting at a markup something you could run yourself. And self-host with TGI when scale, unit economics or data residency make it the obvious call. It is the wrong answer if you have no GPU capacity and no one to operate it, in which case you are inventing an ops burden to save money you have not yet proven you are spending.

Run the cost crossover for your own traffic this week. Take your real or projected token volume, price it on Providers, then compare it to a flat T4 or A10G Endpoint and to TGI on a GPU you already own. The number will tell you which door you are standing in front of, and it is almost never the one you assumed when you started.

Hugging Face Series · Part 11 of 17
« Previous: Part 10  |  Hugging Face Guide  |  Next: Part 12

References

About The Author


Discover more from Journal of Intelligent Infrastructure – By Dr Pranay Jha

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Architect’s Toolkit

About the Author

Dr. Pranay Jha is a Cloud and AI Consultant with 18+ years of experience in hybrid cloud, virtualization, and enterprise infrastructure transformation. He specializes in VMware technologies, multi-cloud strategy, and Generative AI solutions. He holds a PhD in Computer Applications with research focused on Cloud and AI, has published multiple research papers, and has been a VMware vExpert since 2016 and a VMUG Community Leader.

Discover more from Journal of Intelligent Infrastructure - By Dr Pranay Jha

Subscribe now to keep reading and get access to the full archive.

Continue reading