Skip to content

[InferenceSnippet] If access token is not provided, default to HF_TOKEN environment variable #1361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Wauplin opened this issue Apr 15, 2025 · 2 comments
Labels
inference @huggingface/inference related

Comments

@Wauplin
Copy link
Contributor

Wauplin commented Apr 15, 2025

Originally from @gary149 on slack (private link):

Instead of using dummy values like hf_xxxxxxxxxxxx, it would be good if inference snippets could use the HF_TOKEN env variable by default - if nothing is provided. Would allow to be able to directly copy-paste the snippets and run them if env variable exists.

In practice:

  • curl should use $HF_TOKEN
  • python should use os.environ["HF_TOKEN"] (⚠ requires import os in code snippet)
  • js shoud use process.env.HF_TOKEN

We still want to be able to pass a custom key to getInferenceSnippets and have it work with it (typically for direct calls without routing).
We want it to work with as many clients and tasks as possible but if too difficult to have a 100% coverage, let's focus on the most important ones.

@Wauplin Wauplin added the inference @huggingface/inference related label Apr 15, 2025
@julien-c
Copy link
Member

  • js shoud use process.env.HF_TOKEN

well JS can also run in browser or other envs, but maybe not a big deal, people will know how to change it?

@Wauplin
Copy link
Contributor Author

Wauplin commented Apr 22, 2025

yep true but still better than token="hf_xxxxxxxxxx" in my opinion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inference @huggingface/inference related
Projects
None yet
Development

No branches or pull requests

2 participants