# Hugging Face Text (`alizarin_refrigerator-owner/hugging-face-text`) Actor

Comprehensive text processing w/Hugging Face models generation, NLP & embeddings.
Text Generations
Chat Completion
Summarization Condense documents
Translation
Sentiment Analysis Classify sentiment
NER Named entity recognition
Q\&A Answer context
Embeddings Semantic search
Zero-Shot without training

- **URL**: https://apify.com/alizarin_refrigerator-owner/hugging-face-text.md
- **Developed by:** [The Howlers](https://apify.com/alizarin_refrigerator-owner) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Hugging Face Text

Text processing with Hugging Face - generation, summarization, translation, sentiment, Q\&A, embeddings, and classification.

**BYOK (Bring Your Own Key)** -- you provide your own API credentials.

***

### Before You Start

This actor requires your own API credentials to fetch real data.

**Where to get your key:** Your Hugging Face API token

Demo Mode is off by default, so runs fetch real data. Set demoMode to true to get free sample data that shows the output format, no key needed.

***

### Quick Start

#### Test with Demo Mode (free, no API key needed)

```json
{
  "demoMode": true
}
```

#### Run with real data

```json
{
  "demoMode": false,
  "task": "text_generation",
  "apiToken": "YOUR_API_KEY_HERE",
  "maxTokens": 256,
  "minTokens": 30,
  "temperature": 0.7,
  "topP": 0.9,
  "topK": 50,
  "repetitionPenalty": 1,
  "doSample": true,
  "waitForModel": true
}
```

***

### Input Parameters

| Parameter | Type | Default | Required | Description |
|-----------|------|---------|----------|-------------|
| `task` | string | `"text_generation"` | Yes\* | The text operation to perform |
| `apiToken` | string | - | Yes\* | Your Hugging Face API token |
| `model` | string | - | No | Hugging Face model ID (leave blank for default) |
| `text` | string | - | No | Text input for processing |
| `texts` | string | - | No | JSON array of texts for batch processing |
| `prompt` | string | - | No | Prompt for generation tasks |
| `systemPrompt` | string | - | No | System prompt for chat completion |
| `context` | string | - | No | Context for question answering |
| `question` | string | - | No | Question for Q\&A tasks |
| `sourceLanguage` | string | - | No | Source language code (e.g., en, es, fr) |
| `targetLanguage` | string | - | No | Target language code |
| `candidateLabels` | string | - | No | Comma-separated labels for zero-shot classification |
| `compareText` | string | - | No | Second text for similarity comparison |
| `maxTokens` | integer | `256` | No | Maximum tokens to generate |
| `minTokens` | integer | `30` | No | Minimum tokens to generate (for summarization) |
| `temperature` | number | `0.7` | No | Sampling temperature (0.0-2.0) |
| `topP` | number | `0.9` | No | Nucleus sampling parameter |
| `topK` | integer | `50` | No | Top-k sampling parameter |
| `repetitionPenalty` | number | `1` | No | Penalty for repetition (1.0 = no penalty) |
| `doSample` | boolean | `true` | No | Use sampling instead of greedy decoding |
| `waitForModel` | boolean | `true` | No | Wait for model to load if not ready |
| `webhookUrl` | string | - | No | URL to receive results via webhook |
| `demoMode` | boolean | `false` | No | Run with sample data (no API calls) |

\*Required when Demo Mode is off.

***

### Pricing

This actor uses **pay-per-event** billing:

| Event | When it is charged | Price |
|-------|--------------------|-------|
| Actor start | Once when the run starts, one event per GB of memory (minimum one). At the default 1 GB of memory that is $0.10 per run | $0.10 per GB |
| Text Generation | Generate text using LLMs like Llama, Mistral, Falcon | $0.01 |
| Chat Completion | Conversational AI with chat-optimized models | $0.01 |
| Summarization | Condense long text into concise summaries | $0.01 |
| Translation | Translate text between 100+ languages | $0.01 |
| Sentiment Analysis | Detect sentiment, emotions, and tone in text | $0.01 |
| Named Entity Recognition | Extract people, places, organizations from text | $0.01 |
| Question Answering | Answer questions based on provided context | $0.01 |
| Fill Mask | Predict masked/missing words in sentences | $0.01 |
| Text Embeddings | Generate semantic vector representations | $0.01 |
| Zero-Shot Classification | Classify text into custom categories without training | $0.01 |
| Text Similarity | Compute semantic similarity between texts | $0.01 |
| Paraphrase | Rewrite text while preserving meaning | $0.01 |
| Result | Each item written to the default dataset | $0.00001 |

**Demo mode is free** -- no charges for sample data.

***

### Troubleshooting

#### "API key is required"

You have Demo Mode turned **off** but didn't provide an API key. Either:

- Turn Demo Mode **on** to test with sample data
- Add your API key in the input

#### "API error 403" or "Unauthorized"

Your API key is invalid, expired, or doesn't have access to this specific API endpoint. Double-check your key and account permissions.

#### "API error 429" or "Rate limit"

Too many requests. Wait a minute and try again, or reduce the number of items per run.

#### No results or empty dataset

Check the run log for error messages. Common causes:

- Invalid input format (check the examples above)
- API key without proper permissions
- The target data doesn't exist or is too small to track

#### How do I test without an API key?

Enable **Demo Mode** in the input. This returns realistic sample data so you can verify the output format works for your workflow.

***

**Built by John Rippy | [Actor Arsenal](https://actorarsenal.com)**

# Actor input Schema

## `task` (type: `string`):

The text operation to perform

## `apiToken` (type: `string`):

Your Hugging Face API token

## `model` (type: `string`):

Hugging Face model ID (leave blank for default)

## `text` (type: `string`):

Text input for processing

## `texts` (type: `string`):

JSON array of texts for batch processing

## `prompt` (type: `string`):

Prompt for generation tasks

## `systemPrompt` (type: `string`):

System prompt for chat completion

## `context` (type: `string`):

Context for question answering

## `question` (type: `string`):

Question for Q\&A tasks

## `sourceLanguage` (type: `string`):

Source language code (e.g., en, es, fr)

## `targetLanguage` (type: `string`):

Target language code

## `candidateLabels` (type: `string`):

Comma-separated labels for zero-shot classification

## `compareText` (type: `string`):

Second text for similarity comparison

## `maxTokens` (type: `integer`):

Maximum tokens to generate

## `minTokens` (type: `integer`):

Minimum tokens to generate (for summarization)

## `temperature` (type: `number`):

Sampling temperature (0.0-2.0)

## `topP` (type: `number`):

Nucleus sampling parameter

## `topK` (type: `integer`):

Top-k sampling parameter

## `repetitionPenalty` (type: `number`):

Penalty for repetition (1.0 = no penalty)

## `doSample` (type: `boolean`):

Use sampling instead of greedy decoding

## `waitForModel` (type: `boolean`):

Wait for model to load if not ready

## `webhookUrl` (type: `string`):

URL to receive results via webhook

## `demoMode` (type: `boolean`):

Run with sample data (no API calls)

## Actor input object example

```json
{
  "task": "text_generation",
  "maxTokens": 256,
  "minTokens": 30,
  "temperature": 0.7,
  "topP": 0.9,
  "topK": 50,
  "repetitionPenalty": 1,
  "doSample": true,
  "waitForModel": true,
  "demoMode": false
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "demoMode": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("alizarin_refrigerator-owner/hugging-face-text").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "demoMode": False }

# Run the Actor and wait for it to finish
run = client.actor("alizarin_refrigerator-owner/hugging-face-text").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "demoMode": false
}' |
apify call alizarin_refrigerator-owner/hugging-face-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alizarin_refrigerator-owner/hugging-face-text"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/lFAnyQdkPKrMZymAc/builds/s2WiHOepqFxzbwnVw/openapi.json
