Meta-Llama-3.1-8B-Instruct — Free API

Created by Meta ⭐ Score: 36
hugging-face/meta-llama-3-1-8b-instruct
🛠️ Function Calling JSON Mode chat

What is Meta-Llama-3.1-8B-Instruct?

Meta Llama 3.1 8B is available free through Hugging Face's Serverless Inference API, providing access to the full 128K-context model without setting up your own infrastructure. The HF API is not OpenAI SDK-compatible (uses Hugging Face's own format), so it requires HF-specific client code or the huggingface_hub Python library. Rate limits are approximately 1,000 requests per day — sufficient for prototyping, evaluation, and low-volume applications. Registration required; free for public models.

Model ID
meta-llama-3-1-8b-instruct
Base URL
https://router.huggingface.co/v1

Meta-Llama-3.1-8B-Instruct API Code Example

Paste your API key and run. See the config generator for Claude Code, Cursor, and more tools.

from openai import OpenAI

client = OpenAI(
    base_url="https://router.huggingface.co/v1",
    api_key="YOUR_API_KEY"
)

response = client.chat.completions.create(
    model="meta-llama-3-1-8b-instruct",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "https://router.huggingface.co/v1",
  apiKey: "YOUR_API_KEY",
});

const completion = await openai.chat.completions.create({
  model: "meta-llama-3-1-8b-instruct",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(completion.choices[0].message.content);
curl https://router.huggingface.co/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "meta-llama-3-1-8b-instruct",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Other Free Models from Hugging Face

More About Hugging Face

How to get an API key, rate limits, platform limitations, and tool configuration — everything you need to set up Hugging Face as a free LLM API backend.

View Hugging Face full guide →