Back to articles
Hugging Face Has a Free Inference API — Here's How to Use 200K+ AI Models

Hugging Face Has a Free Inference API — Here's How to Use 200K+ AI Models

via Dev.to JavaScriptAlex Spinov

Hugging Face offers a free Inference API that gives you access to 200,000+ models — text generation, image generation, classification, translation, embeddings, and more. No GPU needed. Getting Your API Token Sign up at huggingface.co → Settings → Access Tokens → Create new token. Installation npm install @huggingface/inference Text Generation import { HfInference } from " @huggingface/inference " ; const hf = new HfInference ( " your-token " ); const result = await hf . textGeneration ({ model : " mistralai/Mistral-7B-Instruct-v0.3 " , inputs : " Explain web scraping in simple terms: " , parameters : { max_new_tokens : 200 , temperature : 0.7 } }); console . log ( result . generated_text ); Chat Completion const response = await hf . chatCompletion ({ model : " meta-llama/Llama-3.2-3B-Instruct " , messages : [ { role : " system " , content : " You are a helpful coding assistant. " }, { role : " user " , content : " Write a Python web scraper for news headlines " } ], max_tokens : 500 }

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
2 views

Related Articles