Hugging Face Transformers Integration

Updated on Aug 14, 2026

Use this integration when your app is implemented in Python.

Setup

  1. Install SDK
bash
pip install progress-observability
  1. Instrument your app
python
Observability.instrument(
    app_name=os.getenv("OBSERVABILITY_APP_NAME"),
    api_key=os.getenv("OBSERVABILITY_API_KEY")
)
  1. Complete example
python
import os
from dotenv import load_dotenv
from transformers import pipeline
from progress.observability import Observability, agent

load_dotenv()

Observability.instrument(
    app_name=os.getenv("OBSERVABILITY_APP_NAME"),
    api_key=os.getenv("OBSERVABILITY_API_KEY"),
)


@agent(name="transformers_local_agent")
def main():
    model_id = os.getenv("TRANSFORMERS_MODEL", "Qwen/Qwen2.5-1.5B-Instruct")
    generator = pipeline("text-generation", model=model_id)

    messages = [{"role": "user", "content": "What is the capital of France?"}]

    outputs = generator(messages, max_new_tokens=200, do_sample=False)

    reply = outputs[0]["generated_text"][-1]["content"]


if __name__ == "__main__":
    try:
        main()
    finally:
        Observability.shutdown()
In this article
Setup
Not finding the help you need?
Contact Support