Authors
Martin-Pierre Roset
AI integration doesn’t have to be complicated. Kestra lets you connect to Hugging Face models quickly with just a few HTTP requests. Need to analyze the sentiment of customer reviews? Or perhaps classify large datasets? With Hugging Face’s extensive API library, you have access to hundreds of models capable of handling these tasks.
In this post, we’ll connect to Hugging Face’s API through Kestra’s HTTP tasks. HuggingFace will provide AI capability via an API and Kestra will handle authentication, timeout, retries and ensuring the response is correctly captured.
You can leverage Hugging Face models within Kestra for a variety of purposes:
Let’s look at a practical example of using Kestra to translate text from English to Spanish. With Hugging Face’s NLP models, you can configure an HTTP task to make a simple API call. Here’s how it’s done in Kestra:
id: hugging_face_translationnamespace: company.teamtasks: - id: translate_text type: io.kestra.plugin.core.http.Request uri: https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-en-es method: POST contentType: application/json headers: Authorization: "Bearer your token" formData: inputs: "Hello from Paris"In this workflow, Kestra makes a POST request to the Hugging Face model. This task sends text to the translation API, which then returns the translated message. It’s a lightweight integration, avoiding any extra steps for setup or maintenance. You can embed this task within a larger workflow, using the output as needed.
Because Kestra is event-driven, you can trigger Hugging Face models whenever a specific event occurs. For example, let’s look at how Kestra can help streamline customer support by classifying requests in real-time. Each time a customer inquiry comes in, Kestra can automatically call a Hugging Face model to categorize the inquiry based on topics like “refund,” “legal,” or “FAQ.” With Kestra’s HTTP capabilities, you can make these calls and get instant feedback within a single, orchestrated workflow.
Here’s how to set up a real-time classification workflow with Kestra and Hugging Face:
id: hugging_facenamespace: company.teamtasks: - id: hugging_face_categorize type: io.kestra.plugin.core.http.Request uri: https://api-inference.huggingface.co/models/facebook/bart-large-mnli method: POST contentType: application/json headers: Authorization: "Bearer <YOUR_TOKEN>" formData: inputs: "{{ trigger.value | jq('.request') | first }}!" parameters: candidate_labels: '["refund", "legal", "faq"]'
- id: insert_into_mongodb type: io.kestra.plugin.mongodb.InsertOne connection: uri: "mongodb://mongoadmin:secret@localhost:27017/?authSource=admin" database: "kestra" collection: "customer_request" document: | { "request_id": "{{ trigger.value | jq('.request_id') | first }}", "request_value": "{{ trigger.value | jq('.request') | first }}", "category": "{{ json(outputs.categorize.body).labels }}",, "category_scores": "{{ json(outputs.categorize.body).scores }}", }
triggers: - id: realtime type: io.kestra.plugin.kafka.RealtimeTrigger topic: customer_request properties: bootstrap.servers: localhost:9092 serdeProperties: valueDeserializer: JSON groupId: kestraConsumerEach time a new inquiry is processed, Kestra pulls the data and sends it to the Hugging Face model for classification. The response can then be ingested into a downstream database or trigger automated responses. With this setup, you receive immediate categorization, helping your team address customer needs promptly and efficiently.
Beyond fraud detection and translation, Kestra’s flexibility allows you to integrate AI models into a wide variety of applications. Whether you’re building automated customer support or something more niche, Kestra’s orchestration capabilities make it easy to add AI to your workflows.
Kestra platform is designed to simplify AI integration, offering features like:
With Kestra, you can keep your workflows simple while still tapping into the advanced capabilities that Hugging Face models provide. For developers, this means more time creating impactful solutions and less time worrying about setup or maintenance.
Kestra’s real power is in how it integrates with the tools you’re already using—and how it can enhance them with AI capabilities. With features that allow you to trigger workflows in real time, automate approvals, and connect across diverse tools, Kestra makes it simple to build dynamic workflows that work for you.
For developers, Kestra’s “everything-as-code” approach means that building and scaling complex, AI-enabled workflows is accessible. Kestra combines the power of plugins with flexible automation tools, making it easy to set up continuous integration, version control, and task orchestration without getting stuck in endless configuration loops.
With support for Docker, Kubernetes, and various cloud providers, Kestra fits into modern infrastructure .
The extensive plugin library and adaptable structure mean Kestra isn’t limited to data orchestration. You can bring in observability tools, set up notification triggers, or even configure machine learning models to monitor key performance metrics. It’s built for more than just task automation, you can simplify and improve how you leverage AI and data throughout your entire tech stack.
If you have any questions, reach out via Slack or open a GitHub issue. If you like the project, give us a GitHub star and join the community.
Stay up to date with the latest features and changes to Kestra