Llama Guard 3 is a Llama-3.1-8B pretrained model, fine-tuned for content safety classification. Similar to previous versions, it can be used to classify content in both LLM inputs (prompt classification) and in LLM responses (response classification). It acts as an LLM – it generates text in its output that indicates whether a given prompt or response is safe or unsafe, and if unsafe, it also lists the content categories violated.
Llama-Guard-3-8b (meta/llama-guard-3-8b) is a moderation model from Meta, released 2025-01-22. Context window: — tokens; max output —. Pricing via AIgateway: input $0.040/M tokens, output $0.080/M tokens. Call it via https://api.aigateway.sh/v1/moderations — set model="meta/llama-guard-3-8b". Best for: Input/output moderation, Abuse detection.
curl https://api.aigateway.sh/v1/moderations \
-H "Authorization: Bearer $AIGATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"meta/llama-guard-3-8b"}'{
"model": "meta/llama-guard-3-8b",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
],
"temperature": 0.7,
"top_p": 0.95,
"max_tokens": 1024,
"stream": false
}{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1776947082,
"model": "meta/llama-guard-3-8b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 12,
"total_tokens": 36
}
}# pip install aigateway-py openai
# aigateway-py adds sub-accounts, evals, replays, jobs, webhook verify.
# openai SDK covers chat — drop-in per our SDK's own guidance.
from openai import OpenAI
client = OpenAI(
base_url="https://api.aigateway.sh/v1",
api_key="sk-aig-...",
)
r = client.chat.completions.create(
model="meta/llama-guard-3-8b",
messages=[{"role": "user", "content": "Hello!"}],
)
print(r.choices[0].message.content)