Call Llama 3.1 8B Free on Cloudflare Workers AI
Cloudflare Workers AI serves Llama 3.1 8B on its permanent no-card Free plan with 10,000 daily Neurons. Cloudflare Workers AI replaced its deprecated @cf/meta/llama-3.1-8b-instruct slug with @cf/meta/llama-3.1-8b-instruct-fast — use the -fast model ID inside your OpenAI SDK or Worker binding to stay within the 10,000 free daily Neurons allowance.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/v1",
api_key=os.environ["CLOUDFLARE_API_TOKEN"],
)
r = client.chat.completions.create(
model="@cf/meta/llama-3.1-8b-instruct-fast",
messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{"model":"@cf/meta/llama-3.1-8b-instruct-fast","messages":[{"role":"user","content":"Hello"}]}'# Pull and run locally (~4.9 GB download, ~6.7 GB VRAM at 8K)
ollama run llama3.1:8b
# Confirm 100% GPU offload while running
ollama psRun Llama 3.1 8B Locally
Llama 3.1 8B Instruct remains one of the most widely supported 8B open-weight baselines for general chat, summarization and structured tool calling. Its 32-layer Grouped-Query Attention (8 KV heads) architecture supports a 128K context window while keeping Q4_K_M memory at roughly 6.7 GB — small enough to fit completely on an 8 GB RTX 4060 or 16 GB Apple Silicon Mac.
Launch it locally with ollama run llama3.1:8b (4-bit default) or load a Q4_K_M / Q6_K GGUF in LM Studio or llama.cpp. If you plan to use long 32K+ prompts in Ollama, remember Ollama defaults to a smaller num_ctx unless you raise it in a Modelfile or API payload.
Memory Needed per Quantization
Estimated at 8K context (32 layers, 8 KV heads, 128 head dimension, 0.125 MB FP16 KV cache per token). At Q4_K_M (6.7 GB), the entire model fits on an 8 GB RTX 4060 with roughly 1.3 GB left for display overhead.
| Quantization | Weights | Total at 8K | Fits on |
|---|---|---|---|
| FP16 | 16.0 GB | 18.4 GB | Mac Studio 128GB, Mac Studio 64GB, RTX 4090, RTX 5090 |
| Q4_K_M | 4.8 GB | 6.7 GB | Mac mini 24GB, Mac Studio 128GB, Mac Studio 64GB, RTX 4060, RTX 4060 Ti 16GB, RTX 4070, RTX 4090, RTX 5090 |
| Q5_K_M | 5.7 GB | 7.6 GB | Mac mini 24GB, Mac Studio 128GB, Mac Studio 64GB, RTX 4060, RTX 4060 Ti 16GB, RTX 4070, RTX 4090, RTX 5090 |
| Q8_0 | 8.5 GB | 10.5 GB | Mac mini 24GB, Mac Studio 128GB, Mac Studio 64GB, RTX 4060 Ti 16GB, RTX 4070, RTX 4090, RTX 5090 |
Llama 3.1 8B vs Qwen2.5 7B on 8 GB GPUs
Both models target the same 8 GB GPU tier, but they optimize for different strengths. Choose Llama 3.1 8B if you want a matching free cloud fallback on Cloudflare Workers AI; choose Qwen2.5 7B if you prioritize Apache 2.0 licensing, coding accuracy or lower KV cache memory at 16K–32K context.
| Dimension | Llama 3.1 8B | Qwen2.5 7B |
|---|---|---|
| Q4_K_M at 8K | 6.7 GB | 5.9 GB |
| KV Cache per Token | 0.125 MB | 0.055 MB (2.3× smaller) |
| Verified Free API | Cloudflare Workers AI | Local only verified |
| License | Llama 3.1 Community | Apache 2.0 |
Llama 3.1 Community License
Permits research and commercial use; products above 700M monthly active users require a separate license from Meta, and attribution is required. Read the official license at github.com/meta-llama/….