APIYard
Back to APIs
AI & MLBearer TokenFree tier

Hugging Face

Access thousands of community-trained models for NLP, computer vision, audio, and more through the Inference API.

Base URL

https://api-inference.huggingface.co
transformersNLPvisionaudioopen-source

Endpoints

POST/models/{model_id}

Run inference on any Hugging Face model.

const response = await fetch("https://api-inference.huggingface.co/models/gpt2", {
  method: "POST",
  headers: {
  "Content-Type": "application/json",
  "Authorization": "Bearer YOUR_ACCESS_TOKEN"
  },
  body: JSON.stringify({
  "inputs": "The meaning of life is"
})
});

const data = await response.json();
console.log(data);

Response Preview

[
  {
    "generated_text": "The meaning of life is to find your gift. The purpose of life is to give it away."
  }
]