Appearance
Llama 3.1 Nemoguard 8b Content Safety ​
Overview ​
Llama 3.1 Nemoguard 8b Content Safety is a specialized content moderation model developed by NVIDIA, designed to detect and filter harmful content. Built on the Llama 3.1 architecture with 8 billion parameters, this model excels at analyzing text for safety concerns and providing detailed reasoning for its safety evaluations.
Use Cases ​
Ideal for content moderation systems, safety filtering applications, and harmful content detection. The model can evaluate text content and determine whether it contains potentially harmful, inappropriate, or unsafe material, making it essential for platforms that need to maintain content quality and user safety.
Model Card: Llama 3.1 Nemoguard 8b Content Safety
Endpoints ​
1. Create Chat Completion ​
POST /v1/chat/completions
Description ​
Analyzes content for safety concerns and provides safety evaluations with detailed reasoning.
Request Body ​
json
{
"model": "nvidia/llama-3.1-nemoguard-8b-content-safety",
"messages": [
{
"role": "system",
"content": "You are a content safety evaluator. Analyze content and respond with SAFE or UNSAFE with reasoning."
},
{
"role": "user",
"content": "Please evaluate this text for safety: Hello, how are you today?"
}
],
"temperature": 0.1,
"max_completion_tokens": 100,
"stream": false
}| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | ID of the model to use. Only nvidia/llama-3.1-nemoguard-8b-content-safety is available. |
messages | array | Yes | List of messages in the conversation. Each message must include a role and content. |
temperature | number | No | Sampling temperature (0-2). Lower values recommended for consistent safety evaluations. Default: 0.1. |
max_completion_tokens | integer | No | Maximum number of tokens to generate for the completion. |
stream | boolean | No | If true, the response will be streamed in chunks. Default: false. |
Response (When stream is false) ​
json
{
"id": "chat-abcdefg1234567",
"object": "chat.completion",
"created": 1743765837,
"model": "nvidia/llama-3.1-nemoguard-8b-content-safety",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "SAFE\n\nThis text is a simple, polite greeting that contains no harmful, inappropriate, or unsafe content. It's a standard conversational opener that poses no safety concerns."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 28,
"total_tokens": 53
}
}| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the chat completion. |
object | string | Always "chat.completion". |
created | integer | Unix timestamp of when the chat completion was created. |
model | string | The model used to generate the completion. |
choices | array | List of generated responses. Each choice includes the message and finish_reason. |
usage | object | Token usage details, including prompt_tokens, completion_tokens, and total_tokens. |
Response (When stream is true) ​
The response is streamed in chunks. Each chunk contains a part of the generated safety evaluation.
First Chunk ​
json
{
"id": "chat-abcdefg1234567",
"object": "chat.completion.chunk",
"created": 1743765837,
"model": "nvidia/llama-3.1-nemoguard-8b-content-safety",
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": "SAFE"
},
"finish_reason": null
}
]
}Subsequent Chunk ​
json
{
"id": "chat-abcdefg1234567",
"object": "chat.completion.chunk",
"created": 1743765838,
"model": "nvidia/llama-3.1-nemoguard-8b-content-safety",
"choices": [
{
"index": 0,
"delta": {
"content": "\n\nThis text is a simple, polite greeting"
},
"finish_reason": null
}
]
}Final Chunk ​
json
{
"id": "chat-abcdefg1234567",
"object": "chat.completion.chunk",
"created": 1743765839,
"model": "nvidia/llama-3.1-nemoguard-8b-content-safety",
"choices": [
{
"index": 0,
"delta": {},
"finish_reason": "stop"
}
]
}| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the chat completion. |
object | string | Always "chat.completion.chunk" for streaming responses. |
created | integer | Unix timestamp of when the chunk was created. |
model | string | The model used to generate the completion. |
choices | array | List of incremental responses. Each choice includes the delta and finish_reason. |
delta | object | Contains the incremental part of the response. |
finish_reason | string/null | Indicates why the response generation stopped. |
2. List Models ​
GET /v1/models
Description ​
Lists all available models and their metadata.
Response ​
json
{
"object": "list",
"data": [
{
"id": "nvidia/llama-3.1-nemoguard-8b-content-safety",
"object": "model",
"created": 1672531200,
"owned_by": "SwissAI"
}
]
}| Field | Type | Description |
|---|---|---|
id | string | Model identifier. |
object | string | Always "model". |
created | integer | Unix timestamp of model creation. |
owned_by | string | Organization owning the model. |
Example Code Snippets ​
Note:
The production URL for this API is available in the corresponding plan for this model in the Digital Marketplace. To retrieve the URL:
- Navigate to the Digital Marketplace.
- Go to the Documentation section.
- Select the plan associated with the
Llama 3.1 Nemoguard 8b Content Safetymodel.- Locate the production URL provided in the plan details.
- Set up the environment variable
API_URLto the production URL retrieved.
1. Using curl ​
Content Safety Evaluation ​
bash
curl -X POST $API_URL/v1/chat/completions \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nvidia/llama-3.1-nemoguard-8b-content-safety",
"messages": [
{
"role": "system",
"content": "You are a content safety evaluator. Analyze content and respond with SAFE or UNSAFE with reasoning."
},
{
"role": "user",
"content": "Please evaluate this text for safety: Hello, how are you today?"
}
],
"temperature": 0.1,
"max_completion_tokens": 100
}'List Models ​
bash
curl -X GET $API_URL/v1/models \
-H "Authorization: Bearer $YOUR_API_KEY"2. Using Python (OpenAI Client) ​
Content Safety Evaluation (Non-streaming) ​
python
import os
import openai
client = openai.OpenAI(
api_key=os.getenv("YOUR_API_KEY"),
base_url=os.getenv("API_URL") + "/v1",
)
response = client.chat.completions.create(
model="nvidia/llama-3.1-nemoguard-8b-content-safety",
messages=[
{
"role": "system",
"content": "You are a content safety evaluator. Analyze content and respond with SAFE or UNSAFE with reasoning."
},
{
"role": "user",
"content": "Please evaluate this text for safety: Hello, how are you today?"
}
],
temperature=0.1,
max_completion_tokens=100,
stream=False
)
print(response.choices[0].message.content)Content Safety Evaluation (Streaming) ​
python
import os
import openai
client = openai.OpenAI(
api_key=os.getenv("YOUR_API_KEY"),
base_url=os.getenv("API_URL") + "/v1",
)
response = client.chat.completions.create(
model="nvidia/llama-3.1-nemoguard-8b-content-safety",
messages=[
{
"role": "user",
"content": "Evaluate this content: This is a normal conversation."
}
],
temperature=0.1,
max_completion_tokens=50,
stream=True
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)List Models ​
python
import os
import openai
client = openai.OpenAI(
api_key=os.getenv("YOUR_API_KEY"),
base_url=os.getenv("API_URL") + "/v1",
)
response = client.models.list()
print(response)Best Practices ​
TIP
Temperature Settings: Guardrail models work best with low temperature settings (0.1-0.3) to ensure consistent and reliable safety evaluations.
TIP
System Prompts: Use clear system prompts that define the evaluation criteria and expected response format for optimal results.
Replace YOUR_API_KEY with your actual API key to authenticate the requests. You can follow the procedure in Inference Endpoints Overview

