Using Llama Guard 2 8B on Replicate API
Implementation guide · Llama Guard · AI at Meta
Replicate API exposes Llama Guard 2 8B through model ID llama-guard-2-8b. Use the setup steps, sourced pricing, capabilities, and official provider links below to validate this route before deployment.
Last refreshed 2026-09-18. Next refresh: weekly.
Quick Start
- 1
- 2Use the Replicate API SDK or REST API to call
llama-guard-2-8b— see the documentation for request format. - 3
Code Examples
pip install replicateREPLICATE_API_TOKENllama-guard-2-8bReplicate uses "owner/model-name" format (e.g. "meta/meta-llama-3-8b-instruct") for the latest version, or "owner/model-name:version-sha" to pin to a specific version. The REST endpoint splits owner and model-name into the path: /v1/models/{owner}/{model-name}/predictions.
import replicate
# reads REPLICATE_API_TOKEN from env
# llama-guard-2-8b format: "owner/model-name" (latest version) or "owner/model-name:version-hash"
output = replicate.run(
"llama-guard-2-8b",
input={"prompt": "Hello"}
)
# Output is a list or generator depending on the model
print("".join(output))Pricing on Replicate API
| Type | Price (per 1M) |
|---|---|
| Input tokens | $0.05 |
| Output tokens | $0.25 |
Capabilities
No model capability flags are currently sourced.
About Llama Guard 2 8B
Llama Guard 2 is an 8B-parameter LLM built on the Llama 3 architecture, specifically designed for content moderation tasks. Released by Meta on April 18, 2024, it excels in classifying both inputs and outputs of LLMs across 11 safety categories. The model generates text outputs indicating whether content is safe or unsafe, providing detailed feedback on violations. It aims to enhance user experience by minimizing false positives while maintaining high accuracy in content moderation, supporting developers in creating safer AI applications .