A script created a Hugging Face Inference Endpoint with huggingface_hub's create_inference_endpoint and no type argument — who can call it, and how do you restrict it?
answer
- the library default is not the dashboard's
- three access levels
- any Hugging Face account's token
- the old name was removed in v2.0
- update() has no type argument
basics
~20 sIn huggingface_hub 2.1, type defaults to authenticated, so anyone with a Hugging Face account can call it with their own token. Recreate it with type private, the dashboard's default, adding AWS PrivateLink if traffic must stay off the internet.
solid answer
~40 sAn Inference Endpoint has three access levels. **Private** (the dashboard default) accepts personal tokens from you or members of your organization; **Authenticated** accepts any Hugging Face account's token; **Public** needs no token at all. In `huggingface_hub` 2.1.1, `create_inference_endpoint` defaults to `type="authenticated"`, so a scripted endpoint is callable by every Hugging Face user, unlike one created in the dashboard. Pass `type="private"` explicitly; `update_inference_endpoint` takes no `type` argument, so an endpoint created wrongly is recreated rather than patched from code. For network isolation on AWS, add `private_link_account_id` and `private_link_region` for PrivateLink. Code written for 1.x may still pass `type="protected"`: v2.0 removed it in favour of `"authenticated"`.
go deeper
Recall the three access levels, Private, Authenticated and Public, and that Private is the dashboard's default.
Explain who each level admits, and that huggingface_hub's create_inference_endpoint defaults to authenticated, which admits any Hugging Face account.
Show how you find and fix permissive endpoints: list them, recreate with type private because update() cannot change it, wrap the default, and add PrivateLink where needed.
Treat endpoint exposure as a policy: who may deploy, which access level and network path are mandatory, and how deployment code and review enforce it across teams.
## Three access levels, two defaults Every Inference Endpoint has an **access level** that decides which tokens its URL accepts. The Endpoints configuration guide defines three: | Level | Who can call it | Token needed | |---|---|---| | **Private** | you, or members of your Hugging Face organization | their personal access token | | **Authenticated** | anyone with a Hugging Face account | that person's own token | | **Public** | anyone on the internet | none | The dashboard pre-selects **Private**. The Python library does not: in `huggingface_hub` 2.1.1, `create_inference_endpoint(..., type=...)` is declared with `type=InferenceEndpointType.AUTHENTICATED`, and its docstring lists `"authenticated"` as the default. The `hf endpoints deploy` command's `--type` option also defaults to `authenticated`. So the same model, deployed once by hand and once from a CI script that omits `type`, ends up with two different audiences. The name misleads people. "Authenticated" sounds like "only us", yet it only proves that the caller holds *a* Hugging Face token. Any of the platform's users could send prompts to your model and run up your instance's queue. ## Restricting an endpoint created this way 1. **Find them.** `list_inference_endpoints(namespace="*")` returns every endpoint across your organizations, and `hf endpoints ls` lists them from the shell. Inspect each one's `raw` configuration or the dashboard's Auth column. 2. **Recreate with the right type.** `update_inference_endpoint` in 2.1.1 accepts compute, model, route and container changes but no `type`, so from code the fix is a new endpoint created with `type="private"`, then switching callers to its URL and deleting the old one. 3. **Pin the default in your own wrapper.** Put `type="private"` into the one helper every deployment script calls, so the library default never applies by accident. 4. **Add network isolation where needed.** On AWS, `private_link_account_id` and `private_link_region` restrict the endpoint to an AWS PrivateLink connection from that account's VPC. The older `account_id` argument is deprecated and ignored. ## Credentials around the endpoint - **Callers' tokens.** For Private endpoints, callers use personal tokens; prefer fine-grained tokens, which the Endpoints FAQ recommends, and revoke a leaked one in your token settings without deleting the endpoint. - **The container's secrets.** Values the container needs go in `secrets=` (the dashboard's Secret Env), not in `env=`, which holds plain, non-secret variables. - **Public is a choice, not a fix.** A Public endpoint is right only for something like a free demo, because every request runs on hardware you pay for. ## When each level is the right choice - **Private** is the safe default for anything internal: services and CI jobs call it with a token belonging to a member of the owning organization, and removing someone from the organization removes their access. - **Authenticated** is a deliberate choice for sharing a model with outside people who have Hugging Face accounts but no place in your organization, such as an evaluation partner. Treat it as open to the whole platform and size it accordingly. - **Public** suits a free demo or a public widget. Every caller runs on hardware you pay for, so pair it with a modest `max_replica`, which caps how many replicas, and therefore how much spend, traffic can trigger. Whatever the level, the endpoint URL itself is not a secret: it appears in logs, browser tools and client configuration, so access control has to come from the level and the tokens, never from an unguessable URL. ## The renamed value Older scripts pass `type="protected"` or `InferenceEndpointType.PROTECTED`. `huggingface_hub` v2.0 removed both as deprecated APIs and the migration guide names `"authenticated"` as the replacement. The guide presents this as a rename, so switching the string is not a way to tighten access: `authenticated` still admits any Hugging Face account's token, and only `type="private"` narrows the audience to your organization. ## Why this deserves a review step An endpoint is an always-reachable HTTPS service backed by paid hardware. A permissive access level does not fail loudly; nothing breaks, the dashboard shows the endpoint as Running, and the first sign may be traffic or cost you cannot explain. That makes the access level a field to assert in deployment code and to check in review, alongside the instance type and the replica limits. A one-line test that every deployment helper passes an explicit `type` catches the library default before it reaches production, which is far cheaper than discovering it from an unexplained bill.
- Old deployment code passes `type="protected"`. What happens on `huggingface_hub` 2.1, and what should it pass?v2.0 removed the deprecated `PROTECTED` value, and its migration guide says to use `InferenceEndpointType.AUTHENTICATED` or `type="authenticated"` instead. `authenticated` admits any Hugging Face account's token, so if the intent was to keep the endpoint to your organization, pass `type="private"` instead.
- When does AWS PrivateLink matter on top of a Private endpoint?Private still exposes an internet-facing URL protected by tokens. PrivateLink, set with `private_link_account_id` and `private_link_region`, makes the endpoint reachable only through a private connection from that AWS account's VPC, which suits organizations that require traffic never to cross the public internet.
- Authenticated means only members of my organization can call the endpoint.
- create_inference_endpoint defaults to private, just like the dashboard.
- Changing type through update_inference_endpoint locks down an existing endpoint.
- Renaming protected to authenticated in v2.0 made the level stricter.
- Putting an API key in env= is as safe as using secrets=.
Assumes huggingface_hub 2.1.1: create_inference_endpoint defaults type to authenticated, and v2.0 removed the old protected value.