> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/hugging-face.md).

# Hugging Face

Run Hugging Face inference and discover currently served models on the Hub.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector    | Authentication    |
| ------------ | ----------------- |
| Hugging Face | User Access Token |

#### Hugging Face

Connect to Hugging Face to run inference and discover models on the Hub.

**Set up in Hugging Face**

1. Prepare the Hugging Face account or service that the workflow will access. Grant access to the required resources and operations.
2. Create or obtain the API credential identified in the fields below. Use the provider instructions linked with those fields to find its key-management page.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Hugging Face**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field     | Required | What to enter                                                                                                                                                                                                    |
| ----------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| User Access Token | Yes      | A fine-grained Hugging Face token with Inference Providers permission. [Provider instructions](https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write\&tokenType=fineGrained). |

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **Hugging Face** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Run chat completion

Ask a routed Hugging Face chat model to respond to a prompt.

**Inputs**

| Field                 | Type     | Required | Description                                                                        |
| --------------------- | -------- | -------- | ---------------------------------------------------------------------------------- |
| Prompt                | textarea | Yes      | What you want the model to answer or do.                                           |
| System Instructions   | textarea | No       | Optional instructions that guide the model's role and response style.              |
| Model                 | string   | No       | The live Hub chat model to use. Default: openai/gpt-oss-20b.                       |
| Maximum Output Tokens | integer  | No       | The maximum number of tokens the response may contain. Minimum: 1. Default: 512.   |
| Temperature           | number   | No       | How varied the generated response should be. Minimum: 0. Maximum: 2. Default: 0.7. |

**Outputs**

| Field         | Type     | Description                               |
| ------------- | -------- | ----------------------------------------- |
| Response      | textarea | The assistant's response text.            |
| Model         | string   | The model reported by Hugging Face.       |
| Finish Reason | string   | Why generation stopped, when reported.    |
| Input Tokens  | integer  | Input tokens counted by the provider.     |
| Output Tokens | integer  | Generated tokens counted by the provider. |
| Total Tokens  | integer  | Total tokens counted by the provider.     |

#### Generate text embeddings

Convert text into a numeric embedding vector.

**Inputs**

| Field              | Type     | Required | Description                                                                                    |
| ------------------ | -------- | -------- | ---------------------------------------------------------------------------------------------- |
| Text               | textarea | Yes      | The text to convert into an embedding.                                                         |
| Model              | string   | No       | The live HF Inference feature-extraction model to use. Default: microsoft/harrier-oss-v1-0.6b. |
| Normalize          | boolean  | No       | Scale the vector to unit length when the model supports it. Default: true.                     |
| Truncate Long Text | boolean  | No       | Trim text that exceeds the model's input length. Default: true.                                |

**Outputs**

| Field      | Type    | Description                            |
| ---------- | ------- | -------------------------------------- |
| Embedding  | array   | The generated numeric vector.          |
| Dimensions | integer | The number of values in the embedding. |
| Model      | string  | The model used for the embedding.      |

#### Generate image from text

Create an image from a written prompt and return its URL.

**Inputs**

| Field  | Type     | Required | Description                                                                       |
| ------ | -------- | -------- | --------------------------------------------------------------------------------- |
| Prompt | textarea | Yes      | A description of the image to create.                                             |
| Avoid  | textarea | No       | Optional details or qualities to exclude from the image.                          |
| Width  | integer  | No       | The requested image width in pixels. Minimum: 512. Maximum: 1536. Default: 1024.  |
| Height | integer  | No       | The requested image height in pixels. Minimum: 512. Maximum: 1536. Default: 1024. |
| Seed   | integer  | No       | Optional seed for repeatable generation. Minimum: 0.                              |

**Outputs**

| Field        | Type    | Description                                 |
| ------------ | ------- | ------------------------------------------- |
| Image URL    | string  | The URL of the generated image.             |
| Width        | integer | Generated image width when reported.        |
| Height       | integer | Generated image height when reported.       |
| Content Type | string  | Generated image media type when reported.   |
| Seed         | integer | The seed used for generation when reported. |
| Model        | string  | The pinned Hub model used for generation.   |

#### Transcribe audio

Transcribe speech from a public audio or video URL.

**Inputs**

| Field     | Type   | Required | Description                                         |
| --------- | ------ | -------- | --------------------------------------------------- |
| Audio URL | string | Yes      | A public HTTPS URL for the recording to transcribe. |

**Outputs**

| Field      | Type     | Description                                  |
| ---------- | -------- | -------------------------------------------- |
| Transcript | textarea | The recognized speech as text.               |
| Model      | string   | The pinned Hub model used for transcription. |

#### Search models on the Hub

Find Hugging Face Hub models by name, task, author, or live inference provider.

**Inputs**

| Field              | Type            | Required | Description                                                                                                                                            |
| ------------------ | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Search             | string          | No       | Optional words that should appear in the model id.                                                                                                     |
| Task               | select (string) | No       | Only return models for this machine-learning task. Available values: Text Generation, Feature Extraction, Text to Image, Automatic Speech Recognition. |
| Author             | string          | No       | Only return models published by this user or organization.                                                                                             |
| Inference Provider | select (string) | No       | Only return models live on any provider or on exact provider IDs. Available values: Any live provider, HF Inference, Groq, Fal. Default: all.          |
| Sort By            | select (string) | No       | How to order matching models. Available values: Trending, Downloads, Likes, Last Modified. Default: trendingScore.                                     |
| Maximum Results    | integer         | No       | The maximum number of models to return. Minimum: 1. Maximum: 50. Default: 10.                                                                          |
| Cursor             | string          | No       | The continuation cursor from a previous search.                                                                                                        |

**Outputs**

| Field        | Type          | Description                                      |
| ------------ | ------------- | ------------------------------------------------ |
| Models       | object\_array | The matching Hub model summaries.                |
| Next Cursor  | string        | Pass this back as Cursor to continue the search. |
| Result Count | integer       | The number of models returned on this page.      |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/hugging-face.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
