Source: https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/
Canonical: https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/
Language: en

# Llama 3.1 Nemotron Safety Guard 8B v3

[Markdown](https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/index.md) · [JSON](https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/facts.json)

## [Llama 3.1 Nemotron Safety Guard 8B v3](https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/)

Nemotron Safety Guard v3 checks user messages and model responses against a specified risk taxonomy. Returns JSON with separate safety assessments and violation categories.

- [**Ailoot · OpenAI Chat** `POST /v1/chat/completions` `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/#method-0)
- [**Ailoot · OpenAI Chat** `POST /v1/chat/completions` `nemotron-safety-guard`](https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/#method-1)
- [**Ailoot · OpenAI Chat** `POST /v1/chat/completions` `nemotron-safety-guard-latest`](https://ailoot.ai/models/en/nvidia-llama-3-1-nemotron-safety-guard-8b-v3/#method-2)

About the model

This description covers the model’s capabilities. Available in Ailoot inputs, outputs and options are listed for the selected method below.

#### Checking both sides of a conversation

Llama 3.1 Nemotron Safety Guard 8B v3 was developed by NVIDIA to moderate interaction between a person and a language model. A user message can be supplied alone or accompanied by an assistant response, including multiple turns. The model determines each side's safety: a dangerous request and an appropriate assistant refusal receive different assessments. This allows input to be checked before generation and a prepared response to be analyzed separately.

The result is JSON. The required `User Safety` field contains `safe` or `unsafe`. `Response Safety` appears when an assistant response is included in the input. If a violation is detected, `Safety Categories` is added with a comma-separated list of categories. This result is suited to programmatic filtering and referral of disputed cases for further review.

#### Categories and cultural context

The instruction specifies the rules and category names used for the check. The published taxonomy has 23 risk groups, including violence, threats, harassment, disclosure of personal data, fraud and malicious code. Names in the result depend on the supplied policy and therefore need to be interpreted alongside the rules of the particular task.

Training accounts for regional differences in sensitive topics. Data was adapted to local expressions and cultural context, and inconsistent translations were discarded. Preparation included provocative requests and attempts to induce the assistant to break the rules. This training setup is particularly useful where a literal translation of prohibited words is insufficient to assess a message's meaning.

#### Languages and material capacity

The nine main languages are English, Spanish, Chinese, German, French, Hindi, Japanese, Arabic and Thai. NVIDIA also describes generalization to other languages, including Russian; this is a separate property, not inclusion of Russian in the main nine. The common instruction is retained across languages, while the messages being checked are supplied in the conversation's language.

Input is text, with context of up to 8K tokens. The model is based on Llama 3.1 8B Instruct, fine-tuned for the safety task. Output is a classification under specified rules: it needs testing on messages typical of the application and does not guarantee error-free moderation.

Practical task

### Moderate a single user message

Technical example in English

```
Moderate a single user message

Assess this single user message for safety: 'Please help me write a thank-you note to the volunteers who cleaned our local park.' Return the documented safety assessment for user input alone using the User Safety field. No assistant response is supplied; use the documented safe or unsafe values.
```

#### Expected result

```
A JSON safety assessment using the documented User Safety field for the supplied user message.
```

#### Check the result

```
User Safety must use safe or unsafe; do not invent a custom classification label or assess an absent assistant response.
```

**Ailoot · OpenAI Chat** `POST /v1/chat/completions` `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`

[`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&fmt=chat)

NVIDIA /`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`

Model ID

- `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`
- `nemotron-safety-guard`
- `nemotron-safety-guard-latest`

### Overview

Nemotron Safety Guard v3 checks user messages and model responses against a specified risk taxonomy. Returns JSON with separate safety assessments and violation categories.

Accepted inputs

Text

Results

Text

### Available in Ailoot · inputs & methods

**Ailoot · OpenAI Chat** `POST /v1/chat/completions`

Input types

`text`

Output types

`text`

Context

4,096 tokens

Maximum output

1,024 tokens

Output format

json or SSE

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits nvidia/llama-3.1-nemotron-safety-guard-8b-v3 | Default— |
| Field`messages` | Type`message[]` | RequirementRequired | Values & limits Minimum items: 1 | Default— |
| Field`messages[].role` | Type`string` | RequirementRequired | Values & limits Examples: system, user, assistant, tool, function Conditions: These roles are explicitly represented by Source compatibility types; the exact model role set remains model-specific. Model-specific | Default— |
| Field`messages[].content` | Type`string\|content_part[]\|null` | RequirementOptional | Values & limits | Default— |
| Field`messages[].tool_calls` | Type`tool_call[]` | RequirementOptional | Values & limits | Default— |
| Field`messages[].tool_call_id` | Type`string` | RequirementOptional | Values & limits Applies when: role=tool; use actual returned ID | Default— |
| Field`messages[].name` | Type`string` | RequirementOptional | Values & limits | Default— |
| Field`messages[].reasoning_content` | Type`string` | RequirementOptional | Values & limits Applies when: Round-trip actual returned reasoning where this model uses it | Default— |
| Field`messages[].reasoning_details` | Type`object\|array` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`max_tokens` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Model-specific | Default— |
| Field`max_completion_tokens` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Model-specific | Default— |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits | Defaultfalse |
| Field`stream_options.include_usage` | Type`boolean` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`temperature` | Type`number` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`top_p` | Type`number` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`stop` | Type`string\|string[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools` | Type`function_tool[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools[].type` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools[].function.name` | Type`string` | RequirementRequired | Values & limits Applies when: function tool supplied | Default— |
| Field`tools[].function.description` | Type`string` | RequirementOptional | Values & limits | Default— |
| Field`tools[].function.parameters` | Type`JSON_schema` | RequirementOptional | Values & limits | Default— |
| Field`tool_choice` | Type`string\|object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`parallel_tool_calls` | Type`boolean` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`response_format` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`reasoning_effort` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`reasoning` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`service_tier` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`instructions` | Type`string` | RequirementOptional | Values & limits Compatibility field | Default— |
| Field`functions` | Type`function[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`function_call` | Type`string\|object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`prompt_cache_options` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |

Input material combinations

**Text** · UTF8 text

`messages[].content`

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`material_types` | Contracttext |
| Parameter`required` | Contractmodel, messages |
| Parameter`optional_controls` | Contractnull |
| Parameter`content_type` | Contractapplication/json |
| Parameter`text_file_material` | Contractactual UTF-8 content inserted as text; file IDs/URLs need separate exact support |

Lifecycle: `exact retained published method`

Method shapes and IDs are exact; supplier capability is separate from admission.

### Pricing

#### Ailoot method rates

Input

$0.0002 */ 1K*

Output

$0.0002 */ 1K*

Cache read

$0.0002 */ 1K*

Cache write

$0.0002 */ 1K*

Cache write, 5 min

$0.0002 */ 1K tokens*

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot · OpenAI Chat

Text examplePython SDKNode.js SDKPython stream

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_TEXT_FILE:?Set your actual UTF-8 source-material file}"
export AILOOT_TEXT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "nvidia/llama-3.1-nemotron-safety-guard-8b-v3", "messages": []}')
f=Path(os.environ["AILOOT_TEXT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 source material")
text=f.read_text(encoding="utf-8")
if not text.strip():raise SystemExit("Source material must contain text")
p["messages"]=[{"role":"user","content":"Summarize this material and quote supporting source passages.\n\n"+text}]
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/chat/completions \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import json
from pathlib import Path
print(json.dumps(json.loads(Path("result.json").read_text()),ensure_ascii=False,indent=2))
PY_RESULT
```

```python
from openai import OpenAI
import os

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client = OpenAI(base_url="https://api.ailoot.ai/v1", api_key=os.environ["AILOOT_API_KEY"], max_retries=0)
resp = client.chat.completions.create(
    model="nvidia/llama-3.1-nemotron-safety-guard-8b-v3",
    messages=[{"role": "user", "content": "Explain the difference between an observation and a hypothesis in three sentences."}],
)
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

save_result(resp.to_dict(mode="json"))
```

```js
import OpenAI from "openai";

if (!process.env.AILOOT_API_KEY?.trim()) throw new Error("Set AILOOT_API_KEY before making a request");
const client = new OpenAI({ baseURL: "https://api.ailoot.ai/v1", apiKey: process.env.AILOOT_API_KEY, maxRetries: 0 });
const resp = await client.chat.completions.create({
  model: "nvidia/llama-3.1-nemotron-safety-guard-8b-v3",
  messages: [{ role: "user", content: "Explain the difference between an observation and a hypothesis in three sentences." }],
});
import { writeFileSync } from "node:fs";

function saveResult(data, stem = "result") {
  writeFileSync(stem + ".json", JSON.stringify(data, null, 2));
  console.log(JSON.stringify(data, null, 2));
  const saveBlob = (encoded, suffix, label) => {
    const raw = Buffer.from(encoded, "base64");
    const ext = raw.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])) ? "png" : raw[0]===255 && raw[1]===216 ? "jpg" : raw.subarray(0,4).toString()==="RIFF" && raw.subarray(8,12).toString()==="WEBP" ? "webp" : suffix;
    const file = `${stem}-${label}.${ext}`;
    writeFileSync(file, raw); console.log("Saved", file);
  };
  for (const [i, block] of (data.content || []).entries()) console.log("Content", i, JSON.stringify(block));
  for (const choice of data.choices || []) console.log("Choice", choice.index, JSON.stringify(choice.message || choice.delta || {}));
  for (const [i, item] of (data.output || []).entries()) {
    console.log("Output", i, JSON.stringify(item));
    if (item.type === "image_generation_call" && item.result) saveBlob(item.result, item.output_format || "bin", `output-${i}`);
  }
  for (const [ci, candidate] of (data.candidates || []).entries()) {
    for (const [pi, part] of (candidate.content?.parts || []).entries()) {
      console.log("Candidate/part", ci, pi, JSON.stringify(part));
      const blob = part.inlineData || part.inline_data;
      if (blob?.data) {
        const mime = blob.mimeType || blob.mime_type;
        const suffix = ({"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"})[mime] || "bin";
        saveBlob(blob.data, suffix, `candidate-${ci}-part-${pi}`);
      }
    }
  }
}

saveResult(resp);
```

```python
from openai import OpenAI
import os
from pathlib import Path

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

with client.chat.completions.stream(model='nvidia/llama-3.1-nemotron-safety-guard-8b-v3',messages=[{"role":"user","content":"Explain observations and hypotheses in three sentences."}]) as stream:
    with Path("stream-events.jsonl").open("w",encoding="utf-8") as log:
        for event in stream:
            payload=event.to_dict(mode="json")
            log.write(json.dumps(payload,ensure_ascii=False)+"\n"); log.flush()
            print(json.dumps(payload,ensure_ascii=False))
    final=stream.get_final_completion()
    save_result(final.to_dict(mode="json"),"stream-result")
```

### Receive and save results

#### Ailoot · OpenAI Chat

json or SSE

##### Keep all completed results

Keep every complete returned response, file and content part.

Keep every choice and its content/tool calls/reasoning. In SSE assemble deltas by choice/tool index, retain the final finish reason and usage.

##### If the original response needs checking

Keep request/response IDs and headers. No generic text job retrieval URL is supplied.

Response fields

| Field | Type |
| --- | --- |
| Field`choices[].index` | Typeinteger |
| Field`choices[].message.content` | Typestring\|null |
| Field`choices[].message.tool_calls` | Typetool\_call\[\] |
| Field`choices[].message.reasoning_content` | Typestring |
| Field`choices[].message.reasoning_details` | Typeobject\|array |
| Field`choices[].finish_reason` | Typestring\|null |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |

### Aliases

#### Model aliases

**Ailoot** [`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&fmt=chat), [`nemotron-safety-guard`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard&fmt=chat), [`nemotron-safety-guard-latest`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard-latest&fmt=chat)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&fmt=chat), [`nemotron-safety-guard`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard&fmt=chat), [`nemotron-safety-guard-latest`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard-latest&fmt=chat)

**Ailoot · OpenAI Chat** `POST /v1/chat/completions` `nemotron-safety-guard`

[`nemotron-safety-guard`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard&fmt=chat)

NVIDIA /`nemotron-safety-guard`

Model ID

- `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`
- `nemotron-safety-guard`
- `nemotron-safety-guard-latest`

### Overview

Nemotron Safety Guard v3 checks user messages and model responses against a specified risk taxonomy. Returns JSON with separate safety assessments and violation categories.

Accepted inputs

Text

Results

Text

### Available in Ailoot · inputs & methods

**Ailoot · OpenAI Chat** `POST /v1/chat/completions`

Input types

`text`

Output types

`text`

Context

4,096 tokens

Maximum output

1,024 tokens

Output format

json or SSE

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits nemotron-safety-guard | Default— |
| Field`messages` | Type`message[]` | RequirementRequired | Values & limits Minimum items: 1 | Default— |
| Field`messages[].role` | Type`string` | RequirementRequired | Values & limits Examples: system, user, assistant, tool, function Conditions: These roles are explicitly represented by Source compatibility types; the exact model role set remains model-specific. Model-specific | Default— |
| Field`messages[].content` | Type`string\|content_part[]\|null` | RequirementOptional | Values & limits | Default— |
| Field`messages[].tool_calls` | Type`tool_call[]` | RequirementOptional | Values & limits | Default— |
| Field`messages[].tool_call_id` | Type`string` | RequirementOptional | Values & limits Applies when: role=tool; use actual returned ID | Default— |
| Field`messages[].name` | Type`string` | RequirementOptional | Values & limits | Default— |
| Field`messages[].reasoning_content` | Type`string` | RequirementOptional | Values & limits Applies when: Round-trip actual returned reasoning where this model uses it | Default— |
| Field`messages[].reasoning_details` | Type`object\|array` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`max_tokens` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Model-specific | Default— |
| Field`max_completion_tokens` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Model-specific | Default— |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits | Defaultfalse |
| Field`stream_options.include_usage` | Type`boolean` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`temperature` | Type`number` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`top_p` | Type`number` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`stop` | Type`string\|string[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools` | Type`function_tool[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools[].type` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools[].function.name` | Type`string` | RequirementRequired | Values & limits Applies when: function tool supplied | Default— |
| Field`tools[].function.description` | Type`string` | RequirementOptional | Values & limits | Default— |
| Field`tools[].function.parameters` | Type`JSON_schema` | RequirementOptional | Values & limits | Default— |
| Field`tool_choice` | Type`string\|object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`parallel_tool_calls` | Type`boolean` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`response_format` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`reasoning_effort` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`reasoning` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`service_tier` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`instructions` | Type`string` | RequirementOptional | Values & limits Compatibility field | Default— |
| Field`functions` | Type`function[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`function_call` | Type`string\|object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`prompt_cache_options` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |

Input material combinations

**Text** · UTF8 text

`messages[].content`

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`material_types` | Contracttext |
| Parameter`required` | Contractmodel, messages |
| Parameter`optional_controls` | Contractnull |
| Parameter`content_type` | Contractapplication/json |
| Parameter`text_file_material` | Contractactual UTF-8 content inserted as text; file IDs/URLs need separate exact support |

Lifecycle: `exact retained published method`

Method shapes and IDs are exact; supplier capability is separate from admission.

### Pricing

#### Ailoot method rates

Input

$0.0002 */ 1K*

Output

$0.0002 */ 1K*

Cache read

$0.0002 */ 1K*

Cache write

$0.0002 */ 1K*

Cache write, 5 min

$0.0002 */ 1K tokens*

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot · OpenAI Chat

Text examplePython SDKNode.js SDKPython stream

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_TEXT_FILE:?Set your actual UTF-8 source-material file}"
export AILOOT_TEXT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "nemotron-safety-guard", "messages": []}')
f=Path(os.environ["AILOOT_TEXT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 source material")
text=f.read_text(encoding="utf-8")
if not text.strip():raise SystemExit("Source material must contain text")
p["messages"]=[{"role":"user","content":"Summarize this material and quote supporting source passages.\n\n"+text}]
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/chat/completions \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import json
from pathlib import Path
print(json.dumps(json.loads(Path("result.json").read_text()),ensure_ascii=False,indent=2))
PY_RESULT
```

```python
from openai import OpenAI
import os

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client = OpenAI(base_url="https://api.ailoot.ai/v1", api_key=os.environ["AILOOT_API_KEY"], max_retries=0)
resp = client.chat.completions.create(
    model="nemotron-safety-guard",
    messages=[{"role": "user", "content": "Explain the difference between an observation and a hypothesis in three sentences."}],
)
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

save_result(resp.to_dict(mode="json"))
```

```js
import OpenAI from "openai";

if (!process.env.AILOOT_API_KEY?.trim()) throw new Error("Set AILOOT_API_KEY before making a request");
const client = new OpenAI({ baseURL: "https://api.ailoot.ai/v1", apiKey: process.env.AILOOT_API_KEY, maxRetries: 0 });
const resp = await client.chat.completions.create({
  model: "nemotron-safety-guard",
  messages: [{ role: "user", content: "Explain the difference between an observation and a hypothesis in three sentences." }],
});
import { writeFileSync } from "node:fs";

function saveResult(data, stem = "result") {
  writeFileSync(stem + ".json", JSON.stringify(data, null, 2));
  console.log(JSON.stringify(data, null, 2));
  const saveBlob = (encoded, suffix, label) => {
    const raw = Buffer.from(encoded, "base64");
    const ext = raw.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])) ? "png" : raw[0]===255 && raw[1]===216 ? "jpg" : raw.subarray(0,4).toString()==="RIFF" && raw.subarray(8,12).toString()==="WEBP" ? "webp" : suffix;
    const file = `${stem}-${label}.${ext}`;
    writeFileSync(file, raw); console.log("Saved", file);
  };
  for (const [i, block] of (data.content || []).entries()) console.log("Content", i, JSON.stringify(block));
  for (const choice of data.choices || []) console.log("Choice", choice.index, JSON.stringify(choice.message || choice.delta || {}));
  for (const [i, item] of (data.output || []).entries()) {
    console.log("Output", i, JSON.stringify(item));
    if (item.type === "image_generation_call" && item.result) saveBlob(item.result, item.output_format || "bin", `output-${i}`);
  }
  for (const [ci, candidate] of (data.candidates || []).entries()) {
    for (const [pi, part] of (candidate.content?.parts || []).entries()) {
      console.log("Candidate/part", ci, pi, JSON.stringify(part));
      const blob = part.inlineData || part.inline_data;
      if (blob?.data) {
        const mime = blob.mimeType || blob.mime_type;
        const suffix = ({"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"})[mime] || "bin";
        saveBlob(blob.data, suffix, `candidate-${ci}-part-${pi}`);
      }
    }
  }
}

saveResult(resp);
```

```python
from openai import OpenAI
import os
from pathlib import Path

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

with client.chat.completions.stream(model='nemotron-safety-guard',messages=[{"role":"user","content":"Explain observations and hypotheses in three sentences."}]) as stream:
    with Path("stream-events.jsonl").open("w",encoding="utf-8") as log:
        for event in stream:
            payload=event.to_dict(mode="json")
            log.write(json.dumps(payload,ensure_ascii=False)+"\n"); log.flush()
            print(json.dumps(payload,ensure_ascii=False))
    final=stream.get_final_completion()
    save_result(final.to_dict(mode="json"),"stream-result")
```

### Receive and save results

#### Ailoot · OpenAI Chat

json or SSE

##### Keep all completed results

Keep every complete returned response, file and content part.

Keep every choice and its content/tool calls/reasoning. In SSE assemble deltas by choice/tool index, retain the final finish reason and usage.

##### If the original response needs checking

Keep request/response IDs and headers. No generic text job retrieval URL is supplied.

Response fields

| Field | Type |
| --- | --- |
| Field`choices[].index` | Typeinteger |
| Field`choices[].message.content` | Typestring\|null |
| Field`choices[].message.tool_calls` | Typetool\_call\[\] |
| Field`choices[].message.reasoning_content` | Typestring |
| Field`choices[].message.reasoning_details` | Typeobject\|array |
| Field`choices[].finish_reason` | Typestring\|null |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |

### Aliases

#### Model aliases

**Ailoot** [`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&fmt=chat), [`nemotron-safety-guard`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard&fmt=chat), [`nemotron-safety-guard-latest`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard-latest&fmt=chat)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&fmt=chat), [`nemotron-safety-guard`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard&fmt=chat), [`nemotron-safety-guard-latest`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard-latest&fmt=chat)

**Ailoot · OpenAI Chat** `POST /v1/chat/completions` `nemotron-safety-guard-latest`

[`nemotron-safety-guard-latest`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard-latest&fmt=chat)

NVIDIA /`nemotron-safety-guard-latest`

Model ID

- `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`
- `nemotron-safety-guard`
- `nemotron-safety-guard-latest`

### Overview

Nemotron Safety Guard v3 checks user messages and model responses against a specified risk taxonomy. Returns JSON with separate safety assessments and violation categories.

Accepted inputs

Text

Results

Text

### Available in Ailoot · inputs & methods

**Ailoot · OpenAI Chat** `POST /v1/chat/completions`

Input types

`text`

Output types

`text`

Context

4,096 tokens

Maximum output

1,024 tokens

Output format

json or SSE

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits nemotron-safety-guard-latest | Default— |
| Field`messages` | Type`message[]` | RequirementRequired | Values & limits Minimum items: 1 | Default— |
| Field`messages[].role` | Type`string` | RequirementRequired | Values & limits Examples: system, user, assistant, tool, function Conditions: These roles are explicitly represented by Source compatibility types; the exact model role set remains model-specific. Model-specific | Default— |
| Field`messages[].content` | Type`string\|content_part[]\|null` | RequirementOptional | Values & limits | Default— |
| Field`messages[].tool_calls` | Type`tool_call[]` | RequirementOptional | Values & limits | Default— |
| Field`messages[].tool_call_id` | Type`string` | RequirementOptional | Values & limits Applies when: role=tool; use actual returned ID | Default— |
| Field`messages[].name` | Type`string` | RequirementOptional | Values & limits | Default— |
| Field`messages[].reasoning_content` | Type`string` | RequirementOptional | Values & limits Applies when: Round-trip actual returned reasoning where this model uses it | Default— |
| Field`messages[].reasoning_details` | Type`object\|array` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`max_tokens` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Model-specific | Default— |
| Field`max_completion_tokens` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Model-specific | Default— |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits | Defaultfalse |
| Field`stream_options.include_usage` | Type`boolean` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`temperature` | Type`number` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`top_p` | Type`number` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`stop` | Type`string\|string[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools` | Type`function_tool[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools[].type` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`tools[].function.name` | Type`string` | RequirementRequired | Values & limits Applies when: function tool supplied | Default— |
| Field`tools[].function.description` | Type`string` | RequirementOptional | Values & limits | Default— |
| Field`tools[].function.parameters` | Type`JSON_schema` | RequirementOptional | Values & limits | Default— |
| Field`tool_choice` | Type`string\|object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`parallel_tool_calls` | Type`boolean` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`response_format` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`reasoning_effort` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`reasoning` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`service_tier` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`instructions` | Type`string` | RequirementOptional | Values & limits Compatibility field | Default— |
| Field`functions` | Type`function[]` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`function_call` | Type`string\|object` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`prompt_cache_options` | Type`object` | RequirementOptional | Values & limits Model-specific | Default— |

Input material combinations

**Text** · UTF8 text

`messages[].content`

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`material_types` | Contracttext |
| Parameter`required` | Contractmodel, messages |
| Parameter`optional_controls` | Contractnull |
| Parameter`content_type` | Contractapplication/json |
| Parameter`text_file_material` | Contractactual UTF-8 content inserted as text; file IDs/URLs need separate exact support |

Lifecycle: `exact retained published method`

Method shapes and IDs are exact; supplier capability is separate from admission.

### Pricing

#### Ailoot method rates

Input

$0.0002 */ 1K*

Output

$0.0002 */ 1K*

Cache read

$0.0002 */ 1K*

Cache write

$0.0002 */ 1K*

Cache write, 5 min

$0.0002 */ 1K tokens*

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot · OpenAI Chat

Text examplePython SDKNode.js SDKPython stream

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_TEXT_FILE:?Set your actual UTF-8 source-material file}"
export AILOOT_TEXT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "nemotron-safety-guard-latest", "messages": []}')
f=Path(os.environ["AILOOT_TEXT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 source material")
text=f.read_text(encoding="utf-8")
if not text.strip():raise SystemExit("Source material must contain text")
p["messages"]=[{"role":"user","content":"Summarize this material and quote supporting source passages.\n\n"+text}]
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/chat/completions \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import json
from pathlib import Path
print(json.dumps(json.loads(Path("result.json").read_text()),ensure_ascii=False,indent=2))
PY_RESULT
```

```python
from openai import OpenAI
import os

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client = OpenAI(base_url="https://api.ailoot.ai/v1", api_key=os.environ["AILOOT_API_KEY"], max_retries=0)
resp = client.chat.completions.create(
    model="nemotron-safety-guard-latest",
    messages=[{"role": "user", "content": "Explain the difference between an observation and a hypothesis in three sentences."}],
)
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

save_result(resp.to_dict(mode="json"))
```

```js
import OpenAI from "openai";

if (!process.env.AILOOT_API_KEY?.trim()) throw new Error("Set AILOOT_API_KEY before making a request");
const client = new OpenAI({ baseURL: "https://api.ailoot.ai/v1", apiKey: process.env.AILOOT_API_KEY, maxRetries: 0 });
const resp = await client.chat.completions.create({
  model: "nemotron-safety-guard-latest",
  messages: [{ role: "user", content: "Explain the difference between an observation and a hypothesis in three sentences." }],
});
import { writeFileSync } from "node:fs";

function saveResult(data, stem = "result") {
  writeFileSync(stem + ".json", JSON.stringify(data, null, 2));
  console.log(JSON.stringify(data, null, 2));
  const saveBlob = (encoded, suffix, label) => {
    const raw = Buffer.from(encoded, "base64");
    const ext = raw.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])) ? "png" : raw[0]===255 && raw[1]===216 ? "jpg" : raw.subarray(0,4).toString()==="RIFF" && raw.subarray(8,12).toString()==="WEBP" ? "webp" : suffix;
    const file = `${stem}-${label}.${ext}`;
    writeFileSync(file, raw); console.log("Saved", file);
  };
  for (const [i, block] of (data.content || []).entries()) console.log("Content", i, JSON.stringify(block));
  for (const choice of data.choices || []) console.log("Choice", choice.index, JSON.stringify(choice.message || choice.delta || {}));
  for (const [i, item] of (data.output || []).entries()) {
    console.log("Output", i, JSON.stringify(item));
    if (item.type === "image_generation_call" && item.result) saveBlob(item.result, item.output_format || "bin", `output-${i}`);
  }
  for (const [ci, candidate] of (data.candidates || []).entries()) {
    for (const [pi, part] of (candidate.content?.parts || []).entries()) {
      console.log("Candidate/part", ci, pi, JSON.stringify(part));
      const blob = part.inlineData || part.inline_data;
      if (blob?.data) {
        const mime = blob.mimeType || blob.mime_type;
        const suffix = ({"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"})[mime] || "bin";
        saveBlob(blob.data, suffix, `candidate-${ci}-part-${pi}`);
      }
    }
  }
}

saveResult(resp);
```

```python
from openai import OpenAI
import os
from pathlib import Path

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

with client.chat.completions.stream(model='nemotron-safety-guard-latest',messages=[{"role":"user","content":"Explain observations and hypotheses in three sentences."}]) as stream:
    with Path("stream-events.jsonl").open("w",encoding="utf-8") as log:
        for event in stream:
            payload=event.to_dict(mode="json")
            log.write(json.dumps(payload,ensure_ascii=False)+"\n"); log.flush()
            print(json.dumps(payload,ensure_ascii=False))
    final=stream.get_final_completion()
    save_result(final.to_dict(mode="json"),"stream-result")
```

### Receive and save results

#### Ailoot · OpenAI Chat

json or SSE

##### Keep all completed results

Keep every complete returned response, file and content part.

Keep every choice and its content/tool calls/reasoning. In SSE assemble deltas by choice/tool index, retain the final finish reason and usage.

##### If the original response needs checking

Keep request/response IDs and headers. No generic text job retrieval URL is supplied.

Response fields

| Field | Type |
| --- | --- |
| Field`choices[].index` | Typeinteger |
| Field`choices[].message.content` | Typestring\|null |
| Field`choices[].message.tool_calls` | Typetool\_call\[\] |
| Field`choices[].message.reasoning_content` | Typestring |
| Field`choices[].message.reasoning_details` | Typeobject\|array |
| Field`choices[].finish_reason` | Typestring\|null |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |

### Aliases

#### Model aliases

**Ailoot** [`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&fmt=chat), [`nemotron-safety-guard`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard&fmt=chat), [`nemotron-safety-guard-latest`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard-latest&fmt=chat)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`nvidia/llama-3.1-nemotron-safety-guard-8b-v3`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&fmt=chat), [`nemotron-safety-guard`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard&fmt=chat), [`nemotron-safety-guard-latest`](https://ailoot.ai/models/en/#m=nvidia%2Fllama-3.1-nemotron-safety-guard-8b-v3&route=Core&caller=nemotron-safety-guard-latest&fmt=chat)

FAQ · nvidia/llama-3.1-nemotron-safety-guard-8b-v3

What inputs and results are available?

`POST /v1/chat/completions` · `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`: `text` → `text` `POST /v1/chat/completions` · `nemotron-safety-guard`: `text` → `text` `POST /v1/chat/completions` · `nemotron-safety-guard-latest`: `text` → `text`

Which fields does the request use?

`POST /v1/chat/completions` · `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`: `model`, `messages`, `stream` `POST /v1/chat/completions` · `nemotron-safety-guard`: `model`, `messages`, `stream` `POST /v1/chat/completions` · `nemotron-safety-guard-latest`: `model`, `messages`, `stream`

What limits apply?

`POST /v1/chat/completions` · `nvidia/llama-3.1-nemotron-safety-guard-8b-v3`: `ctx`: `4096`; `max_out`: `1024`; `messages.min_items`: `1` `POST /v1/chat/completions` · `nemotron-safety-guard`: `ctx`: `4096`; `max_out`: `1024`; `messages.min_items`: `1` `POST /v1/chat/completions` · `nemotron-safety-guard-latest`: `ctx`: `4096`; `max_out`: `1024`; `messages.min_items`: `1`

Connect Ailoot to Claude Code, OpenCode, Hermes or your own app.

## The company and its project portfolio

The company and its project portfolio: millions of customers; monthly sales in the billions.

## Buy tokens at a discount.

Subscription discounts for regular use. Promo codes offer up to 50% off token purchases.

Subscription

Choose a discounted plan for your regular requests.

Promo code: up to 50% off

Enter your code at checkout. The price updates to reflect the current promotion.

Spending in your history

The model, tokens and amount are recorded for each request.

[Choose a subscription](https://ailoot.ai/docs/en/billing/subscriptions/) · [View model prices](https://ailoot.ai/models/en/)

## Connect the API to a product you sell.

Use Ailoot in SaaS, apps and bots under its official service offer and licence agreement. Request a reseller licence for resale.

Commercial application

Add text, image, video and audio generation to paid features in your service.

Reseller licence

Send a description of your project and how you provide access. Request written terms for use and resale.

Documents on the website

The service offer, licence agreement and data processing policy are available before you connect.

[Request a reseller licence](mailto:support@ailoot.ai) · [Service offer and licence agreement](https://ailoot.ai/legal/offer?lang=en)

## Ailoot · The company and its project portfolio





Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.





The company and its project portfolio: millions of customers; monthly sales in the billions.





Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
