Skip to content
Hugging Face logo

Hugging Face

Models, datasets, and inference for open machine learning.

CodingResearch

How it works / How to use

Models, datasets, and inference for open machine learning. Browse the Hub to find models, try them in browser widgets powered by Inference Providers, and integrate the same models via SDK or API. Hub seats (Free, PRO, Team, Enterprise) are separate from pay-as-you-go inference credits.

  1. Open huggingface.co and sign in (free account) to use widgets, upload repos, and generate access tokens.
  2. Find a model: filter by task, library, or Inference Providers availability on the Models page.
  3. Try the inference widget on the model page, or copy code snippets from View Code Snippets.
  4. For production use, create a token with Inference Providers permission and call via InferenceClient or the OpenAI-compatible chat endpoint.

Browse and try models on the Hub

Filter models by task and Inference Providers, open a model page, read the Model Card, then test in the widget on the right before writing code.

What to provide

  • The task you need (text generation, image, speech, embeddings, etc.)
  • Any constraints: language, model size, license, or provider preference
  • A sample input to test in the widget

Details that improve the result

  • Widgets appear when at least one Inference Provider hosts the model
  • Use the Inference Playground to compare chat models side by side
  • Check pipeline_tag and license on the Model Card before relying on a model

Example prompt

Find a conversational text-generation model for summarization. Filter by Inference Providers, open a top model, read its Model Card for language support, then enter: “Summarize in three bullets: [paste text]” in the widget and click Generate.

If the first output is not good

  • Try a different provider from the widget dropdown if latency is high
  • Open View Code Snippets to copy the Python or JavaScript call
  • Compare two models in the Inference Playground with the same prompt

Common mistakes

  • Assuming every model has a working widget—some need provider support first
  • Skipping the Model Card and missing license or bias limitations
  • Confusing free Hub access with unlimited inference credits

Chat completion via Inference Providers

Use InferenceClient or the OpenAI-compatible endpoint at router.huggingface.co/v1 with Bearer auth. Pass model id and messages; append :fastest to let the router pick a provider.

What to provide

  • A Hugging Face token with Inference Providers permission
  • The model id (optionally with :fastest, :cheapest, or :provider suffix)
  • Your messages array and any parameters (max_tokens, temperature, stream)

Details that improve the result

  • Chat completion supports tools, grammars, constraints, and streaming
  • Vision-language models accept image content in messages
  • Inference Providers credits are pay-as-you-go on top of Hub plans

Example prompt

Python with InferenceClient:
client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3-0324",
  messages=[{"role": "user", "content": "Explain LoRA fine-tuning in five sentences."}],
  max_tokens=300
)

If the first output is not good

  • Switch to model:fastest or model:groq to change provider routing
  • Enable stream=True for incremental UI updates
  • Add a system message to set role and output format

Common mistakes

  • Using a token without Inference Providers permission
  • Hard-coding a provider suffix when auto-routing would work
  • Expecting the OpenAI-compatible endpoint to cover non-chat tasks like text-to-image

Explore and use datasets

Search Datasets on the Hub, read the Dataset Card, preview rows in Data Studio, then load with the datasets library or download files directly.

What to provide

  • The domain or task (NLP, vision, audio, etc.)
  • Language, size, and license requirements
  • How you will consume data (streaming, download, Data Studio)

Details that improve the result

  • datasets library loads with one line: load_dataset("org/name")
  • Streaming works for datasets too large to fit in memory
  • Private datasets require organization access and appropriate tokens

Example prompt

Find a small English sentiment dataset with an open license. Open Data Studio to preview columns, then in Python: from datasets import load_dataset; ds = load_dataset("org/name", split="train[:100]")

If the first output is not good

  • Filter by language and size on the Datasets page
  • Use streaming=True for large files
  • Check the Dataset Card for known biases or collection method

Common mistakes

  • Downloading a multi-GB dataset when streaming would suffice
  • Ignoring license terms for commercial use
  • Assuming all columns are clean without inspecting Data Studio

Run and explore Spaces demos

Search Spaces, open a demo, interact in the browser. For your own Space, create a repo and deploy with Gradio or Streamlit SDKs.

What to provide

  • The demo type you need (Gradio, Streamlit, static, or Docker)
  • Sample inputs to test the Space
  • Hardware needs (CPU vs ZeroGPU for GPU demos)

Details that improve the result

  • ZeroGPU provides NVIDIA GPUs on demand for eligible Spaces
  • Static Spaces are simple HTML/CSS/JS pages
  • Embed a Space on your site with the embed snippet

Example prompt

Search Spaces for a text-to-image Gradio demo. Enter “A watercolor forest at dawn, no text” and run. Note latency and output quality before integrating the underlying model via API.

If the first output is not good

  • Duplicate a Space to fork and modify the demo
  • Upgrade a Space to GPU hardware if generation is slow
  • Check the linked model repo from the Space README

Common mistakes

  • Treating a Space demo as production-ready without checking the model license
  • Expecting instant GPU on every Space—ZeroGPU is dynamic
  • Confusing a static Space with a live inference backend

Upload and share a model

Create a model repo on the Hub, upload files via git or huggingface_hub, add a README Model Card, set pipeline_tag, and enable an inference widget if a provider hosts it.

What to provide

  • Model files or a training checkpoint
  • A Model Card describing architecture, training data, limitations, and license
  • Pipeline tag and library metadata (Transformers, diffusers, etc.)

Details that improve the result

  • Model Cards document limitations, bias, and intended use
  • Gated models require user acceptance before download
  • Use git-xet or huggingface-cli for large checkpoints

Example prompt

Create repo username/my-classifier. Upload config and weights, write a Model Card with task, training data summary, evaluation metrics, and license. Tag pipeline_tag: text-classification.

If the first output is not good

  • Add evaluation results and TensorBoard traces to the repo
  • Enable gating if the model needs use-policy acceptance
  • Request provider support if you want a browser widget

Common mistakes

  • Uploading without a Model Card or license
  • Publishing weights without documenting known failure modes
  • Assuming upload automatically enables inference—providers choose models independently

Programmatic inference with SDKs

Install huggingface_hub or @huggingface/inference. Use InferenceClient with provider="auto" for routing, or call task-specific methods. Copy snippets from the model widget when unsure.

What to provide

  • HF_TOKEN with appropriate permissions
  • Model id and task type (chat, text-to-image, embeddings, etc.)
  • Input payload and provider preference (auto or named)

Details that improve the result

  • JavaScript and Python SDKs share the same Inference Providers backend
  • Non-chat tasks (image, speech, embeddings) use InferenceClient task methods, not the OpenAI chat endpoint
  • Dedicated Inference Endpoints are a separate product for always-on deployment

Example prompt

from huggingface_hub import InferenceClient
client = InferenceClient(api_key=HF_TOKEN, provider="auto")
image = client.text_to_image("A serene mountain landscape at sunset", model="black-forest-labs/FLUX.1-schnell")

If the first output is not good

  • Switch provider="fal" or another named provider for consistency
  • Use dedicated Inference Endpoints when you need private, always-on hosting
  • Compare widget output with SDK output to confirm parity

Common mistakes

  • Using the OpenAI-compatible chat endpoint for image generation
  • Omitting api_key and hitting anonymous rate limits
  • Confusing Inference Providers pay-as-you-go with Inference Endpoints pricing

How to prompt

On Hugging Face, prompting happens in model widgets, the Inference Playground, or your API calls. Match the prompt style to the task and model: chat messages for LLMs, descriptive text for image models, and structured inputs for task-specific pipelines.

Task: chat summarization.
Model: deepseek-ai/DeepSeek-V3-0324
Messages: [{"role": "system", "content": "Return three bullets only."}, {"role": "user", "content": "Summarize: [text]"}]
Constraints: max_tokens=200

Read the Model Card first

Model Cards list intended tasks, languages, limitations, and bias notes. Prompt within those bounds for reliable results.

Example

Before prompting a translation model, confirm its supported language pairs in the Model Card, then: “Translate to French: [English text]”.

Use chat roles for LLMs

Chat completion models expect role-structured messages. A system message sets format; user messages carry the task.

Example

messages=[{"role": "system", "content": "Answer in JSON: {summary, open_questions}"}, {"role": "user", "content": "Analyze this paragraph: …"}]

Test in the widget before coding

The model-page widget uses the same Inference Providers endpoint as production. Validate prompts interactively, then copy View Code Snippets.

Example

Enter your prompt in the widget, click Generate, adjust until output fits, then copy the generated Python snippet.

Pick provider routing deliberately

Append :fastest for speed, :cheapest for cost, or :groq/:fal/etc. for a specific provider. Omit suffix to use default fastest routing.

Example

model="moonshotai/Kimi-K2-Instruct-0905:groq" for a fixed provider; model="deepseek-ai/DeepSeek-R1-0528:fastest" for auto speed.

Match prompt style to pipeline tag

Text-to-image models want visual descriptions; embedding models want raw text; ASR models want audio input. Check pipeline_tag on the model page.

Example

For text-to-image: “A serene mountain landscape at sunset, wide angle, no text, no watermark.”

Best output tips

Start on the model page

Open a model repo, read the Model Card, and use the inference widget on the right. Widgets appear when at least one Inference Provider hosts the model.

Use the Inference Playground for chat models

Compare chat completion models with the same prompt, adjust temperature and max_tokens, and pick a model before wiring it into your app.

Authenticate API calls properly

Generate a fine-grained Hugging Face token with Inference Providers permission. Pass it as Bearer hf_**** in headers or via HF_TOKEN in SDKs.

Choose the right API surface

Chat tasks: OpenAI-compatible router.huggingface.co/v1 or InferenceClient.chat.completions. Other tasks (image, speech, embeddings): InferenceClient task methods.

Route providers intentionally

Append :fastest, :cheapest, :preferred, or a named provider (e.g. :groq) to the model id. Default routing picks the fastest available provider.

Separate Hub seats from inference spend

Free, PRO, Team, and Enterprise cover Hub features and collaboration. Inference Providers and Endpoints bill separately as pay-as-you-go or dedicated hosting.

Load datasets efficiently

Use the datasets library with load_dataset. Enable streaming for large files. Preview rows in Data Studio before downloading.

Document models you publish

Upload a Model Card with task, training summary, evaluation, limitations, and license. Gated models require user acceptance before access.

Explore Spaces for quick demos

Gradio and Streamlit Spaces run in the browser. ZeroGPU adds on-demand NVIDIA GPUs for eligible demos.

Use structured chat messages

Set a system message for output format and constraints. Keep user messages focused on the task and source material.

Enable streaming for long replies

Set stream=True in chat completion calls to receive incremental tokens—useful for responsive UIs and early cancellation.

Check licenses before production

Model and dataset licenses vary (open, research-only, commercial restrictions). Confirm terms in the card before shipping.

Copy snippets from the widget

View Code Snippets on the model page generates Python or JavaScript that matches the widget endpoint—reduces integration errors.

Request provider support when needed

If a model has no widget, click Ask for provider support on the model page. Providers choose which models to host.

Know when to use Endpoints

Inference Endpoints provide dedicated, always-on deployment with autoscaling. Inference Providers are serverless and pay-per-call.

  • Filter models by Inference Providers before assuming a browser widget exists.
  • Create a fine-grained token with Inference Providers permission for API calls.
  • Read Model Cards and Dataset Cards for license, bias, and task fit.
  • Try the widget or Inference Playground before integrating code.
  • Hub plans (Free, PRO, Team, Enterprise) are separate from inference credit bills.
  • Use streaming for chat when building interactive UIs.
  • For large datasets, prefer streaming over full download.
  • Copy code snippets from the model widget to avoid endpoint mismatches.
  • Dedicated Inference Endpoints are for always-on private deployment—not the same as Providers pay-as-you-go.

Try this AI

Try Hugging Face

Product Details

Pricing, features, limits and latest updates

Hugging Face

Models, datasets, and inference for open machine learning.

Free / Paid · Free

Pricing Plans

Free

Free

PRO

$9/ Monthly

Team

$20/ Monthly

Enterprise

$50/ Monthly

Enterprise Plus

Custom

Key Features

Chat

HuggingChat and the Inference Playground let you try models in a chat UI; API and widget availability depends on the model and provider.

API

Inference Providers and Endpoints are pay-as-you-go on top of Free, PRO, Team, and Enterprise.

Open Source

Hosts community models, datasets, and Spaces; Hub seats are separate from GPU bills.

Limits

  • Free Hub API requests: 1000 per 5 min. Free-tier Hub API rate limit per five-minute window (Hugging Face rate limits docs).
  • Inference Providers credits: 0.1 USD/month. Free-tier monthly Inference Providers credits; pay-as-you-go after (Hugging Face pricing docs).

Ideas / Prompt experiences

Share a prompt that worked for you. Username and email are shown with your submission. External links are not allowed.

Example prompt

Try a model on the Hub

Prompt

Open the model card for [model-id] on Hugging Face Hub. Read the Model Card limitations, then run one short prompt in the hosted widget. Compare the widget output to the card's intended use case.

Short explanation

Hugging Face workflows differ by surface: Hub widgets, Inference Providers API, and Spaces are separate paths.

Example prompt

Inference Providers API call

Prompt

Using Inference Providers, send one chat completion to [provider/model] with: System: You are a concise assistant. User: Explain LoRA fine-tuning in three sentences for a backend engineer.

Short explanation

API usage is billed separately from Hub PRO seats; check Inference Providers credits and rate limits in official docs.

Share your experience

Required fields are marked. Variation, result, and explanation are optional.

Cursor logo

Cursor

Explore

AI coding agent for building software in your editor, terminal, and IDE.

CodingFree / Paid

AutoGPT logo

AutoGPT

Explore

Platform for building and running AI agents with visual Agent Builder, AutoPilot chat, scheduling, and 200+ integration blocks; self-host open source or use hosted Pro/Max plans.

CodingFree / Paid

v0 logo

v0

Explore

Build full-stack web apps from prompts with AI-generated code, preview, and deploy.

CodingFree / Paid