Skip to main content
Use Hugging Face Trusted Publishers to exchange a Trigger.dev OIDC token for a Hugging Face token that lasts one hour. Your tasks call Inference Providers, download gated models, or read and write one repo with no HF_TOKEN stored anywhere. The exchanged token covers less than a user access token. Pick the flavor that matches what your task does: A CI/CD identity token can’t read your private repos or write anything; use a repo publisher for those (security model). Follow the OIDC prerequisites, then go to the OIDC page for your environment and copy the issuer URL and subject.

Configure Hugging Face

Add a CI/CD identity or a repo trusted publisher, as in the table above. The settings list presets for CI providers, but any OIDC-compliant provider works:
  • Issuer: the issuer URL copied from the dashboard.
  • Claims: sub set to the complete subject copied from the dashboard. Hugging Face matches claims exactly, so each environment needs its own identity or publisher.
The audience is fixed: Hugging Face only accepts tokens whose aud is https://huggingface.co.

Call Hugging Face in your task

Exchange the OIDC token at Hugging Face’s token endpoint, then use the access token wherever you used HF_TOKEN. resource is your Hugging Face username for a CI/CD identity, or the repo (namespace/name, datasets/namespace/name) for a repo publisher:
/trigger/hugging-face-inference.ts
A failed exchange returns 400 with invalid_grant when the issuer, subject or audience doesn’t match the identity or publisher. The token lasts 60 minutes with no refresh token, so exchange again for longer work.

Remove the old credential

Once runs in every deployed environment authenticate this way, delete HF_TOKEN, HUGGING_FACE_HUB_TOKEN and HUGGINGFACEHUB_API_TOKEN from those environments on the Environment Variables page, then revoke the access token in your Hugging Face token settings. Local Development runs can’t mint OIDC tokens. Use your own Hugging Face token there when ctx.environment.type === "DEVELOPMENT".