LiteLLM with Hugging Face Inference Providers and Endpoints

Connect a self-hosted LiteLLM gateway to Hugging Face serverless Inference Providers and dedicated Inference Endpoints using one token, and decide when to run the same open models on vLLM instead.

On this page

How LiteLLM connects to Hugging Face Inference Providers and Endpoints

Platform teams that want approved teams to reach Hugging Face-hosted open models through one governed gateway can do it with LiteLLM's Hugging Face route, which covers two different kinds of hosting. Serverless Inference Providers route requests to third-party providers such as Together AI and Sambanova, while dedicated Inference Endpoints are deployed by Hugging Face on a cloud you choose. LiteLLM documents both as provider routes, so the gateway does not need a custom connector. Teams call the models through the same OpenAI-format API they already use for other providers, and the gateway handles the upstream call. Before you commit, confirm the exact model identifiers and route prefixes in the LiteLLM Hugging Face documentation, since the prefix determines which backend a request reaches.

The main design decision is where the Hugging Face credential lives. LiteLLM uses one Hugging Face token on the gateway side, stored as a provider credential in the proxy configuration and supplied from your secret manager rather than shared with callers. Application teams then receive LiteLLM virtual keys, which can be limited to specific Hugging Face models, budgeted, and rate limited. This keeps the Hugging Face token out of developer hands and lets you revoke access for one team without rotating the shared credential. Confirm with your security team whether one token for the whole gateway meets your ownership model, or whether separate provider configurations per business unit are needed for chargeback and audit.

The second decision is which serverless and dedicated routes you actually need, because each one has different data handling and cost behavior. Serverless requests pass through a third-party inference provider, so your data review must cover that provider as well as Hugging Face. Dedicated endpoints run on a cloud and region you select, which usually simplifies residency questions but adds a deployed resource that bills while it runs. Test each route with a non-sensitive prompt, confirm that the spend appears against the correct virtual key, and check that a model blocked for one team is refused at the gateway. Serving the same open models on your own infrastructure with vLLM is a separate option, and it fits best when data must never leave your environment or when traffic is steady enough to justify owning the accelerators.

What you need before connecting Hugging Face to LiteLLM

Before you add a Hugging Face route, the LiteLLM gateway itself needs a supported baseline, and the Hugging Face side needs a token and network access that match the route you chose. Each card below is one item to confirm in your own environment before you touch the provider configuration.

LiteLLM release line

Pick the LiteLLM release line you will run and confirm it against the releases page, where v1.105.1 is the latest listed release, published October 14, 2026. LiteLLM maintains support for the four most recent stable minor versions, so an older pin can fall out of support before your rollout finishes. Record the exact image tag so the route syntax and provider behavior you test match the version you deploy.

LiteLLM releases

PostgreSQL as the primary database

Virtual keys need a PostgreSQL database, so Hugging Face keys, budgets and spend history all depend on it. Confirm that the database is provisioned, backed up and reachable from every proxy pod before you add a provider. Ask your DBA to size it for the spend write volume you expect, since LiteLLM batches spend updates to the database every 60 seconds at scale.

Production guide

Redis 7.0 or newer

Once more than one proxy instance runs, Redis holds shared rate limits, router state and cache. Confirm that your Redis deployment is version 7.0 or newer and that every LiteLLM replica points at the same instance. Without shared state, a TPM or RPM limit on a Hugging Face route can be enforced per pod instead of per key.

Master key in a secret manager

LITELLM_MASTER_KEY must start with sk- and should live in a secret manager, not in a values file or a container environment that others can read. Confirm who can read it, how it rotates, and that it is never written to logs. The Hugging Face token you add later should sit in the same managed store, so no provider credential is stored in plain configuration.

Hugging Face token scope

Create a Hugging Face access token that covers the route you plan to use: serverless Inference Providers or a dedicated Inference Endpoint. Check the token's permissions in your Hugging Face account settings, and use a token owned by a service account or team rather than an individual. Confirm which Hugging Face organization or account will be billed, since that determines where usage and charges appear.

LiteLLM Hugging Face docs

Outbound network rules

The LiteLLM proxy must reach the Hugging Face endpoints it calls, and for serverless routes, the downstream providers that Hugging Face routes to, such as Together AI and Sambanova. Confirm egress rules, proxy settings and DNS with your network team in each environment, including any restricted or air-gapped zone. Test the path from the proxy pod itself, because a workstation test does not prove the cluster can reach the service.

Configuring the Hugging Face route in LiteLLM step by step

This sequence takes a self-hosted LiteLLM gateway from a stored Hugging Face token to two tested model routes, one serverless and one dedicated, and then to virtual keys that can only reach those models within set budgets and rate limits. Each step ends with a check you can run before moving on.

  1. Store the Hugging Face token in your secret manager

    The platform team creates a Hugging Face access token with the permissions needed for Inference Providers and, for the dedicated route, the Inference Endpoint. The token goes into the secret manager your organization already uses, never into the config file or Git. The LiteLLM proxy receives it as an environment variable that config references by name, and the master key follows the same pattern. Check: the secret resolves in the proxy container or pod, and a grep of the config repository finds no token value.

  2. Define the serverless Inference Provider model entry

    In the proxy config, the platform engineer adds a model entry that uses the Hugging Face route for serverless Inference Providers, with the model ID you have approved and the token reference from the previous step. Serverless requests are routed to the underlying provider that Hugging Face selects, so confirm in the LiteLLM Hugging Face documentation which provider prefix and parameters apply to your version. Check: the proxy starts without config errors and lists the model name on its model endpoint.

  3. Define the dedicated Inference Endpoint model entry

    The engineer adds a second, separate model entry for the dedicated Inference Endpoint you deployed on your chosen cloud. It points to that endpoint's URL with its own token reference and a distinct model name, so callers and budgets can tell the two routes apart. Confirm the endpoint URL and whether the endpoint needs to be running before requests succeed, since a paused endpoint will fail the same way a misconfigured one does. Check: the proxy lists both model names and the endpoint entry shows the expected base URL.

  4. Test each model directly through the proxy

    Before any virtual key exists, the engineer sends a small test completion to each model name using the master key, through the proxy's OpenAI-compatible endpoint. Run one request per route and record the response status, latency and model name returned. If a route fails, check the token scope, the model ID and the endpoint state before changing routing settings. Check: both test calls return a completion, and the proxy logs show each request under the expected model name.

  5. Confirm spend records reach the database

    With the test calls complete, the engineer queries the PostgreSQL spend records to confirm each request was written with its model name and token counts. Free or unpriced routes can show zero cost, so check how the dedicated endpoint is priced in your own Hugging Face billing before relying on the spend figure for chargeback. Check: the spend table contains one row per test call with the correct model, and the value matches what you expect from your billing setup.

  6. Issue a virtual key restricted to the approved models

    The administrator creates a virtual key that lists only the two Hugging Face model names, so the key cannot call any other model on the gateway. Use the proxy's key management to set a budget and TPM and RPM limits for the key, and optionally assign it to a team. Batch-style budget values should be chosen with the finance owner, since the right limits depend on your expected usage. Check: a call with the new key succeeds for both models and returns an error when it requests a model outside the list.

  7. Test the key's limits and spend attribution

    The engineer runs a call with the new key to each model, then checks that the spend record is attributed to the key and team rather than only to the master key. Next, send requests that exceed the RPM limit on a test key to confirm the proxy rejects the excess calls as designed. Check: spend rows carry the virtual key identifier, the over-limit requests are rejected, and the budget counter reflects the test usage.

  8. Document the routes and hand over the key process

    The platform team records each model name, its route type, the secret reference, the endpoint owner and the key policy in the configuration repository or runbook. They also note which tests must pass after a token rotation or proxy upgrade. Check: a team member who did not build the setup can rotate the token in the secret manager, rerun the three test calls and reach the same results.

How serverless providers and dedicated Endpoints differ at the gateway

The two Hugging Face access patterns look identical in a LiteLLM model list, but they carry different data, availability and cost consequences, so the gateway team should decide which one each team may use before any key is issued. Serverless Inference Providers route a request from Hugging Face to a third-party inference provider, and LiteLLM's Hugging Face integration supports providers such as Together AI and Sambanova. The model and the serving provider can change over time without a change to the caller's code, which is useful for availability but means the processing location is set by the provider behind the route, not by your cloud account. A dedicated Inference Endpoint is different: Hugging Face runs the deployment on a cloud and region you choose, and the gateway calls a URL tied to that deployment. You control the instance size, the region and the lifecycle, and you pay for the deployment while it runs.

Those differences map to four decisions for the gateway. First, data location: if prompts contain regulated data, confirm with Hugging Face and the chosen provider where requests are processed and retained before allowing the serverless route. Second, availability: serverless routes depend on whichever provider currently serves the model, while a dedicated Endpoint depends on your chosen deployment, its scaling settings and any pause behavior, so plan fallbacks in the router rather than assuming both will always answer. Third, cost model: serverless usage is typically billed per request or token by the provider, whereas a dedicated Endpoint bills for running capacity, which affects how you set budgets on virtual keys. Fourth, route permissions: restrict serverless routes to teams whose data classification allows third-party processing, and grant dedicated Endpoint routes to teams that need a fixed deployment.

Before you write the model list, confirm current provider availability, supported model names and the required authentication settings in the LiteLLM Hugging Face docs. Provider coverage changes, so treat any list you copy into an internal runbook as a snapshot to re-check at each upgrade.

Request flow from caller through LiteLLM to Hugging Face

The diagram starts with a caller in the client network holding a LiteLLM virtual key. The LiteLLM proxy checks that key against PostgreSQL for budgets and model access, and uses Redis for shared rate limit and router state when more than one proxy instance runs. The Hugging Face token stays in the secret manager and reaches the proxy at runtime, so callers never handle it. The proxy then forwards each request to either the serverless Inference Providers route or a dedicated Inference Endpoint. Check that the trust boundary matches where your egress controls and logging expect traffic to leave your network.

Caller traffic passes the LiteLLM proxy before reaching either Hugging Face route.

Mapping virtual keys, teams and models to Hugging Face routes

This table maps each caller group to the LiteLLM team, virtual key, model names, Hugging Face route type, limits and approver it needs. Treat it as a design draft the client owns, since the mapping depends on their own callers and budgets, and note that virtual keys require a PostgreSQL database.

Design elementWhat to decideWhere it is set or enforcedWho should approve
Caller groupOne group per team that shares a budget, such as an internal application team or a data science group (illustrative)LiteLLM team, with users or service accounts added to itTeam lead with the platform owner
Virtual keyOne key per application or service account, so spend and revocation stay separateVirtual keys in the proxy, stored in PostgreSQLPlatform owner, with security for key scope
Allowed model namesOnly the Hugging Face model aliases the group has a reviewed use forModel access restriction on the keyData owner and security reviewer
Route typeServerless Inference Providers for shared, variable use; dedicated Endpoint for steady, isolated workloadsModel entry in the LiteLLM configurationPlatform owner with the finance contact
BudgetA spend cap per key, user or team, sized from the group's expected Hugging Face usagePer-key, per-user and per-team budgets in LiteLLMFinance owner, confirmed against the provider bill
TPM and RPM limitsRequest and token ceilings that protect shared capacity and dedicated Endpoint throughputTPM and RPM settings on the key or teamPlatform owner with the application owner
Change ownerNamed person who approves new models, budget increases and temporary raisesChange record in your ticketing systemNamed approver, documented before go-live

Securing the Hugging Face token and outbound model traffic

Once LiteLLM holds a Hugging Face token, that token and every prompt sent through it become part of your security boundary. The cards below cover how to scope and store the token, limit which models each virtual key can reach, control who opens the admin UI, and review what leaves your network on each route.

Scope and rotate the Hugging Face token

Create a fine-grained token for the gateway rather than reusing a personal token, and grant only the permissions the routes you use require. Set a rotation schedule and record who owns it. Before go-live, confirm the token scopes Hugging Face currently offers for Inference Providers and dedicated Endpoints, since these change over time, and test that rotation does not break in-flight traffic.

LiteLLM Hugging Face docs

Keep the token out of config and logs

Store the Hugging Face token in your secret manager and inject it into the proxy at runtime, not in config.yaml, Git repositories or container images. Check that request logging, debug output and error traces do not echo the Authorization header. Also keep LITELLM_MASTER_KEY in the same secret store, since it controls admin access to every provider credential behind the gateway.

Restrict virtual keys to named models

Issue virtual keys that can call only the Hugging Face model names approved for each team, so a key issued for one open model cannot be used to reach an endpoint that serves a different workload. Pair the model restriction with per-key budgets and TPM or RPM limits so a leaked key has a bounded blast radius. Document which keys map to which Hugging Face routes.

Virtual keys docs

Lock down admin UI access with SSO

Require SSO for the admin UI so administrators sign in with your identity provider rather than a shared login. LiteLLM's admin UI SSO is free for up to 5 users from v1.76.0 and needs an Enterprise license beyond that, so count the people who need admin rights before you plan the edition. Map admin roles to a small named group and review it on your normal access review cycle.

Admin UI SSO docs

Enterprise controls for audit and network access

Audit logging, IP allowlisting, organization and team RBAC and JWT authentication are Enterprise features in LiteLLM. If your review requires a record of who changed a Hugging Face route or key, or requires that only approved network ranges reach the gateway, confirm these in the Enterprise scope before you choose the open-source edition. Ask LiteLLM which audit events are captured and how long they are retained.

LiteLLM Enterprise docs

Review what prompt content leaves your network

Serverless Inference Providers route requests to third-party providers such as Together AI and Sambanova, while dedicated Endpoints run on a cloud you choose. Each route therefore sends prompts to a different party. Map every route to the parties that receive prompt content, check whether the data is stored or used for training, and confirm Hugging Face's own data handling terms for each route before approving it for sensitive workloads.

Hugging Face provider docs

When to self-host the same open models on vLLM instead

When one open model receives a steady, high volume of requests all day, the per-token economics of a hosted route can stop favoring you. Hosted serverless and dedicated endpoints bill for usage or for runtime, while a self-hosted vLLM server bills you for accelerator capacity whether or not it is busy. At high utilization, that fixed capacity can cost less per token, but only if the GPUs stay busy. Put the two models side by side with real traffic figures from your LiteLLM spend logs.

  • Utilization is the deciding number: A GPU that sits idle much of the day raises the effective cost of every token it serves.
  • Single model focus: vLLM pays off most when one or two models carry the load, so the server can be tuned for them.
  • Load balancing across replicas: LiteLLM can spread traffic across several vLLM replicas through the hosted_vllm/ route, which you configure once per replica.
  • Fallback to hosted APIs: Keep a hosted route as a fallback so a capacity shortfall does not stop callers.
  • Confirm with your vendor: Ask your cloud or hardware provider for accelerator pricing, reservation terms and lead times before you compare.

Before you commit, check your measured tokens per day, peak concurrency and how much idle capacity you would carry.

Common Hugging Face routing failures and how to fix them

This table lists the failures most likely to appear when LiteLLM routes to Hugging Face Inference Providers or dedicated Endpoints, with the likely cause, the check to run and the fix for each. Work down the rows in order of symptom, and use the LiteLLM operations runbooks for anything the table does not resolve. Most failures trace back to the token, the model string or the network path rather than to LiteLLM itself.

FailureLikely causeCheckFix
Authentication errors on every Hugging Face callThe Hugging Face token is invalid, expired, or missing the inference permission needed for the provider routeCall the provider directly with the same token outside LiteLLM, and confirm the token's scopes in your Hugging Face account settingsCreate a fresh token with the required inference permission, store it in your secret manager, and reference it from the LiteLLM config rather than pasting it inline
Token works for one route but fails for anotherThe token is under-scoped for a dedicated Endpoint, or a provider route requires access the token does not carryCompare the failing route with a working one, noting whether it is serverless or dedicatedIssue a token scoped to the Endpoint or provider, and keep separate credentials for each route so a failure stays contained
Model not found or unsupported model errorThe model string does not match the route prefix or the name the provider expectsCompare the model value in the LiteLLM config with the model ID shown on Hugging Face, and check the route prefix usedCorrect the model string to the exact ID and route prefix from the LiteLLM Hugging Face documentation, then test one call before adding it to a team
Dedicated Endpoint returns connection errors or timeoutsThe Endpoint is paused, scaled to zero, still starting, or its URL has changedCheck the Endpoint status in Hugging Face and confirm the base URL in the LiteLLM config matches itResume or redeploy the Endpoint, update the base URL, and add retries with a sensible timeout so cold starts do not appear as outages
Gateway cannot reach Hugging FaceOutbound firewall, proxy or DNS rules block the gateway's egress to Hugging Face hostsRun a connectivity test from the gateway container or pod to the Hugging Face endpoint, and check egress logs on the firewallOpen egress to the specific hosts your routes require through the approved proxy, and record the change in your network change process
Requests fail with budget exceeded errorsA virtual key with no model restriction sends traffic to paid Hugging Face routes and exhausts its budgetReview the key's budget, spend and allowed models in the LiteLLM admin UI and identify which model drove the spendRestrict the key to approved models, set a per-key or per-team budget, and use a temporary increase only with an owner and an end date
Provider bill differs from LiteLLM spendSpend is priced from LiteLLM's model cost data, which may not match the provider's billing unit, tier or regionCompare the same time window in the provider invoice with LiteLLM spend logs, grouped by model and keyDocument the gap, confirm pricing settings with the provider, and follow the LiteLLM cost tracking and chargeback guidance before using spend for internal charging
Traffic lands on an unexpected provider or modelA serverless route selects an underlying provider the team did not plan for, or a fallback sends calls elsewhereInspect the request logs for the provider and model that served each call, and review router and fallback settingsPin the approved provider where the route allows it, and limit fallbacks to models your data handling review has accepted

Questions buyers ask before connecting Hugging Face to LiteLLM

What drives the cost of connecting Hugging Face to LiteLLM?

The integration cost is the scoped engagement work, which is agreed in writing before it starts. Hugging Face usage is billed by Hugging Face, and dedicated Inference Endpoints bill for the cloud capacity they run on, so those charges recur whether or not traffic is high. The scope drivers are the number of models and providers you approve, whether you use serverless Inference Providers, dedicated Endpoints or both, how many teams need keys and budgets, and whether SSO and audit logging must be in place at go-live. Ask any quote to separate one-time setup, testing and documentation from recurring support or a retainer. Also confirm who pays for Endpoint capacity and who owns the Hugging Face account.

How long does a scoped Hugging Face connection take?

Duration depends on scope and must be agreed in writing before work starts. A connection limited to one token, a short model list and a few LiteLLM routes is much smaller than one that also covers dedicated Endpoints in your cloud, network approvals, per-team budgets and SSO. Timing also depends on how quickly your side approves the token, the network path and the budget owners. Ask for a written plan that lists each milestone, what you must provide and by when, and which tests close the work. Treat any single number you hear without a defined scope as a guess.

What must our team supply before the integration starts?

Four inputs block most engagements: token ownership, network approvals, the model list and budget owners.

  • Token ownership: a named owner for the Hugging Face account and access token, with the token stored in your secret manager and rotation rules agreed in advance.
  • Network approvals: outbound access from the LiteLLM host to the Hugging Face routes you use, and to your cloud if dedicated Endpoints run there.
  • Model list: the open models and versions approved for use, with the LiteLLM route each one should use.
  • Budget owners: the person who sets per-key and per-team limits and approves temporary budget increases.

Identify these owners before scoping starts, since missing approvals are a common cause of delay.

Can an internal team connect Hugging Face to LiteLLM alone?

Yes, a team with container or Kubernetes operations experience, PostgreSQL skills and access to the LiteLLM configuration can usually build the basic route. The proxy presents an OpenAI-compatible interface, so application code changes are often small. Check the production requirements before you start: PostgreSQL is the primary supported database and virtual keys need it, Redis 7.0 or newer is required once more than one proxy instance runs, and the production guide suggests one Uvicorn worker per pod on Kubernetes. The gaps usually appear in failover tests, key rotation, budget enforcement and network approvals. Many teams build the first route in-house and bring in a partner for the parts they have not run before.

Does connecting Hugging Face through LiteLLM require Enterprise for SSO?

Not for a small admin group. The LiteLLM admin UI supports SSO with Google, Microsoft Entra ID, Okta and generic OIDC providers, and from v1.76.0 that SSO is free for up to 5 users. Beyond that limit you need an Enterprise license, which also adds SCIM, JWT authentication with identity provider tokens, audit logs, organization and team RBAC and secret manager integrations. Confirm how many people will sign in to the admin UI, and whether application teams only need virtual keys. Confirm current edition terms with LiteLLM before budgeting, because licensing can change. The admin UI SSO documentation sets out the supported setup.

When is a self-hosted vLLM deployment worth the extra operations work?

Consider vLLM when you must run a model yourself, when data handling requirements favor keeping inference inside your infrastructure, or when steady, predictable traffic makes owned capacity easier to plan than per-request pricing. Hugging Face serverless routes or dedicated Endpoints usually fit better when you need quick access to a model, fewer operations duties and managed scaling. A vLLM deployment adds accelerator capacity planning, model compatibility checks, serving upgrades, monitoring and on-call duties. Model both options for your workload: compare operations hours, accelerator cost and recovery effort against the managed bill. Confirm the model and accelerator fit before you commit to either path.

Where does our prompt data go when LiteLLM routes to Hugging Face?

When a request goes to a Hugging Face route, the prompt and response travel to that route. Serverless Inference Providers may pass the request to the provider serving the model, such as Together AI or Sambanova, while dedicated Endpoints run on the cloud and region you choose. Confirm, for each route, where data is processed, what the provider retains and whether your contract covers it. LiteLLM's own logs can store request content depending on your settings, so set retention and redaction before go-live. Use per-team keys and model restrictions to limit which data reaches which route. The LiteLLM Hugging Face documentation describes the supported routes.

Testing the Hugging Face routes before teams use them

Before any team receives a key that reaches Hugging Face through LiteLLM, run a fixed set of acceptance tests and keep the results. Start with a direct completion against each Hugging Face route you plan to expose, both the serverless Inference Providers model entries and each dedicated Inference Endpoint, using the exact model value that callers will send. Confirm that each response returns through the gateway, that the request appears in LiteLLM logs with the expected model name, and that a dedicated endpoint is reached on the cloud and region you chose. Then test a virtual key restricted to a single model and confirm the gateway refuses a request for any other model with a clear error. Because LiteLLM virtual keys support restricting keys to specific models, this check should fail closed, not pass silently.

Next, test the controls that protect spend and capacity. Create a test key with a small budget and a low TPM or RPM limit, send traffic until each limit is reached, and confirm that requests are rejected at the threshold and that a temporary budget increase restores access only for the period you set. Then simulate an outage: disable or block one Hugging Face route and confirm that the router retries, applies a cooldown, and fails over to the priority route you configured, with no caller-visible change beyond expected latency. Record which route served each request. Note that serverless routes depend on upstream providers, so the failover result reflects your configuration as much as Hugging Face's behavior.

Finish with a spend reconciliation. Pick a test window, export the gateway spend for the test keys, and compare it with the usage shown in your Hugging Face billing view for the same window and endpoints. Differences in token counting, pricing entries for serverless routes or dedicated endpoint runtime charges should be explained and documented, not averaged away. Keep the test scripts, keys used, configuration version, logs and reconciliation output together. This evidence supports internal security and compliance reviews, showing that access, limits, failover and cost data behaved as designed. Confirm with your security and finance teams which artifacts they need and how long they must be retained.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.