Hugging Face

huggingface.co

Integrate advanced NLP models for text analysis and generation.

Using the Hugging Face API with Trigger.dev

You can use Trigger.dev with any existing Node SDK or even just using fetch. Using io.runTask makes your Hugging Face background job resumable and appear in our dashboard.

  • Use io.runTask() and the official SDK or fetch.

  • Use our HTTP endpoint to subscribe to webhooks

  • Example code using Hugging Face

    Below are some working code examples of how you can use Hugging Face with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

    import { TriggerClient } from "@trigger.dev/sdk";
    import { createHash } from "crypto";
    // Go to Hugging Face Dashboard > Click on Profile > Settings
    // Go to Webhooks > Add a new webhook
    // Select yourself as the target
    // Add the webhook URL
    // Add the secret as "Test" (for example)
    // Create a model from the dashboard to trigger the webhook
    const huggingFace = client.defineHttpEndpoint({
    id: "hugging-face",
    source: "huggingface.co",
    icon: "huggingface",
    verify: async (request) => {
    if (
    request.headers.get("x-webhook-secret") ===
    process.env.HUGGING_FACE_WEBHOOK_SECRET
    )
    return { success: true };
    return { success: false, reason: "Webhook Secret Match Failed" };
    },
    });
    client.defineJob({
    id: "http-hugging-face",
    name: "HTTP Hugging Face",
    version: "1.0.0",
    enabled: true,
    trigger: huggingFace.onRequest(),
    run: async (request, io, ctx) => {
    const body = await request.json();
    await io.logger.info(`Body`, body);
    },
    });
    ,