Skip to content

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

Closed
@Wauplin

Description

@Wauplin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    inference@huggingface/inference related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions