Skip to content

Interacting with Hugging Face Models Made Easy with Bruno

Hugging Face has democratized access to state-of-the-art ML models. When you need to interact with these models via an API, a robust client is essential.

Enter Bruno, a modern, open-source API client that simplifies this interaction. In this post, we’ll walk through how Bruno makes hitting Hugging Face Inference Endpoints easy.

Let’s dive in!


The Dynamic Duo: Hugging Face and Bruno

These two make a great team:

  • Hugging Face: A leading platform for AI models, datasets, and a vibrant community. Its **Inference API** provides HTTP access to many models for easy integration.
  • Bruno: An offline-first, lightweight, and developer-friendly API client. Its "Collection-as-Code" feature allows collections to be version-controlled with Git.

Together, Hugging Face provides the powerful models, and Bruno offers an efficient way to interact with them via their APIs, streamlining your ML workflow.


Setting the Stage: What You'll Need

To follow along with this guide, you'll need a couple of things:

  1. A Hugging Face Account & API Token: Required for authentication on some Inference Endpoints.
    • Sign up for a free account on Hugging Face.
    • Once logged in, go to your Profile settings (click your avatar) → Access Tokens.
    • Create a new token with at least "Read" permissions. Copy this token – we'll use it shortly.
  2. Bruno Installed:
    • Download and install Bruno from the official website: www.usebruno.com. It's available for Windows, macOS, and Linux.

Step-by-Step: Interacting with a Hugging Face Model via API

For this tutorial, we'll use a popular sentiment analysis model: distilbert-base-uncased-finetuned-sst-2-english. This model takes text as input and tells us whether it's positive or negative.

1. Create a New Bruno Collection

First, let's organize our requests in Bruno:

  • Open Bruno. You'll see a clean interface.
  • Click "Create Collection".
  • Choose a location to save your collection.
  • Let's call it Hugging Face API Interactions

Screenshot 2025-06-05 at 6.50.37 PM

2. Configure an Environment for Your API Token

It's best practice never to hardcode API keys directly into your requests. Bruno's environments are perfect for this.

  • In your new collection, click the "Environments" (top-right corner).
  • Click "New Environment". Let's name it Hugging Face Dev.
  • In the environment editor, add a new variable:
    • Variable Name:
      HUGGING_FACE_API_TOKEN
    • Value: Paste the Hugging Face API token you copied earlier into the value field.

Screenshot 2025-06-07 at 1.21.49 PM

3. Add a New Request for Sentiment Analysis

Now, let's create the request to call our sentiment analysis model:

  • Right-click on your Hugging Face API Interactions collection in the sidebar.
  • Select "New Request".
  • Give it a name, like Sentiment Analysis - DistilBERT.
  • Select POST as the method.
  • For the URL, we'll use the Hugging Face Inference API format:
    https://api-inference.huggingface.co/models/distilbert/distilbert-base-uncased-finetuned-sst-2-englishhttps://api-inference.huggingface.co/models/distilbert-base-uncased-finetuned-sst-2-english

4. Configure Headers

We need two headers for this request: one for authentication and one to specify the content type.

  • Go to the "Headers" tab.
  • Add the following headers:
    • Header 1 (Authorization):
      Name: Authorization
      Value: Bearer 
    • Header 2 (Content-Type):
      Name: Content-Type
      Value: application/json

Screenshot 2025-06-07 at 1.23.10 PM

5. Define the Request Body

The Hugging Face Inference API expects a JSON payload.

  • Go to the "Body" tab.
  • Select the JSON radio button.
  • Enter the following JSON payload:
    {
      "inputs": "Hugging Face and Bruno make an amazing team for machine learning workflows!"
    }

6. Send the Request and Observe the Response

You're all set!

  • Make sure your Hugging Face Dev environment is selected from the dropdown (usually in the top right or bottom left corner of the request editor).
  • Click the "Send" button (the play icon).

Bruno will send the request to Hugging Face, and you'll see the model's response appear in the response pane:

[
  [
    {
      "label": "POSITIVE",
      "score": 0.999862790107727
    },
    {
      "label": "NEGATIVE",
      "score": 0.00013718708942178637
    }
  ]
]

Success! The model correctly identified our input sentence as "POSITIVE" with a very high confidence score.

 

Screenshot 2025-06-07 at 1.23.44 PM


🔗 Try the Demo Yourself

We’ve published the full working collection on GitHub. You can either clone this, or simply click the Fetch in Bruno button below!

 

Wrap Up

Hugging Face has transformed how we access and use state-of-the-art AI. By pairing it with Bruno, you gain an efficient, organized, and Git-friendly way to interact with those models via their APIs.

Whether you're a data scientist testing a new model, a developer integrating AI into an application, or an ML engineer debugging a deployed service, this powerful combination will undoubtedly boost your productivity.

Ready to try it yourself?

Happy API calling! 🚀