Using Llama Guard 2 8B on Replicate API

Implementation guide · Llama Guard · AI at Meta

ServerlessOpen Weights

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. 1
    Create an account at Replicate API and generate an API key.
  2. 2
    Use the Replicate API SDK or REST API to call llama-guard-2-8b — see the documentation for request format.
  3. 3
    You'll be billed $0.05/1M input, $0.25/1M output tokens. See full pricing.

Code Examples

Install
pip install replicate
API key
REPLICATE_API_TOKEN
Model ID
llama-guard-2-8b

Replicate 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

TypePrice (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 .

Model Specs

Released2024-04-18
Parameters8B
Context8k
ArchitectureDecoder Only
Knowledge cutoff2023-03

Provider

Replicate API

Replicate

San Francisco, California, United States