GPT-OSS Safeguard 20B

GPT-OSS Safeguard 20B

category
chat
runs via
api, javascript and python sdk, belt cli, mcp
updated
2026-10-13
price
$0.075/M input ($0.0375/M cached), $0.30/M output

Most teams building with LLMs skip safety checks entirely. Not because they don't care, but because the economics don't work. Running every user input and every model output through your primary LLM for a safety evaluation doubles your inference bill. So the safety layer gets deprioritized, moved to a backlog ticket, or replaced with a handful of regex patterns that catch the obvious stuff and miss everything else.

GPT-OSS Safeguard 20B changes that calculation. It's cheap enough that the question flips. Instead of "can we afford to add safety checks?" the question becomes "can we afford not to?"

I think this is one of the more important model releases in recent memory, not because it pushes the frontier of what language models can do, but because it makes a critical piece of production architecture economically viable for everyone.

what safeguard actually is

Let me be clear about what this model does and what it doesn't do. Safeguard 20B is not a general-purpose chat model. You're not going to use it to write code, draft emails, or answer customer questions. It's a 21-billion-parameter Mixture-of-Experts model with only 3.6 billion active parameters per forward pass, fine-tuned from OpenAI's open-weight gpt-oss-20b base model specifically for safety classification and content moderation. OpenAI developed it in collaboration with Discord, SafetyKit, and Robust Open Online Safety Tools (ROOST), and released it under the Apache 2.0 license. Its job is to look at a piece of text, reason through a developer-provided safety policy, and tell you whether the content contains harmful material, policy violations, prompt injection attempts, or other problems you don't want flowing through your system. The model produces a transparent chain of thought showing how it reached each decision.

There's also a larger sibling - gpt-oss-safeguard-120b - for cases where you need more reasoning depth and can tolerate higher latency. But the 20B version hits a sweet spot for most production use. The MoE architecture with only 3.6B active parameters means it's fast - response latency is low because only a fraction of the total parameters are involved in any given inference. But the model is large enough to understand context, nuance, and the kind of indirect phrasing that trips up simpler classifiers. A keyword filter catches "how to make a bomb." A reasoning-capable safety model can catch someone asking the same question through a creative writing framing or a role-play scenario.

This sits in a category that I think deserves more attention from the developer community. We've spent years debating how to make primary models safer - training with RLHF, constitutional AI, system prompts, guardrails baked into the model weights. All of that matters. But it's a fundamentally different approach from having a dedicated, independent model whose entire purpose is safety evaluation. Both approaches have value, and they're better together than either is alone.

the architecture that makes sense

The pattern I keep coming back to is straightforward. User input arrives. Before it touches your expensive primary model, Safeguard 20B screens it. If the input passes, it flows to Claude or GPT-4o or whatever you're using for the actual work. The primary model generates its response. Before that response reaches the user, Safeguard 20B screens the output too.

User input, then Safeguard screens, then your primary model processes, then Safeguard checks the output, then the user sees the result. Five steps instead of three, but the two additional steps cost almost nothing and catch problems at both ends of the pipeline.

On inference shell, this kind of chaining is natural. You're already calling models through a unified API, so adding a Safeguard call before and after your primary model call is a few extra lines in your orchestration logic. The latency cost is real but small - a 20B model responds quickly, and the calls can run in a fraction of the time your primary model takes to generate its response.

The economics are hard to argue with. Adding Safeguard screening adds a negligible percentage to your effective input cost. That's the cost of a meaningful safety layer. Compare that to running the safety check through your primary model, which would roughly double your cost. Or compare it to not running safety checks at all and dealing with the consequences when something gets through.

where this actually helps

The most obvious use case is content moderation for user-facing applications. Chatbots, customer support agents, creative tools - anything where users submit free-text input and receive model-generated responses. Both sides of that exchange benefit from safety screening. On the input side, you catch harmful requests before they consume expensive inference. On the output side, you catch cases where your primary model generates something problematic despite its own safety training.

But the use case I find more interesting is in agent systems. Agents are increasingly autonomous. They make decisions, call tools, generate content, and take actions with minimal human oversight. The surface area for things going wrong is vastly larger than in a simple chatbot. An agent might receive a benign-seeming instruction that, when combined with its tool access, leads to harmful outcomes. Or it might generate an intermediate artifact - a code snippet, a database query, a message draft - that's problematic even if the final output looks fine.

Running Safeguard checks at multiple points in an agent pipeline - on the initial user input, on the agent's planned actions before execution, on tool outputs before the agent processes them, on the final response before delivery - creates a mesh of safety checks that catches problems at different stages. Each check costs fractions of a cent. The cumulative protection is substantially better than any single check point.

Prompt injection is another area where a dedicated safety model adds value. The attack surface for prompt injection is growing as more applications expose LLMs to untrusted input. A user pastes a document that contains hidden instructions. An email body includes text designed to hijack the model's behavior. A web page scraped by an agent contains adversarial content. These attacks target the primary model's instruction-following behavior. A separate safety model evaluating the input independently isn't susceptible to the same injection because it's not following the same instruction context. It's looking at the content from the outside and asking a different question entirely.

what it won't catch

I want to be honest about the limitations because overselling a safety tool is worse than not having one. A 20B parameter model, no matter how well-trained, will miss things.

Sophisticated adversarial attacks designed to evade detection will sometimes succeed. Safety is fundamentally an adversarial domain. Attackers adapt to defenses. A model trained on known attack patterns can be circumvented by novel patterns. This isn't a failing specific to Safeguard 20B - it's true of every safety system ever built. The question is whether it raises the bar meaningfully, and a 20B model trained on safety data raises it significantly compared to no dedicated safety layer.

Culturally specific content is another challenge. What counts as harmful varies across cultures, languages, and contexts. A model's training data reflects specific cultural assumptions about harm, and those assumptions won't perfectly align with every deployment context. If your application serves a global audience, you'll need to evaluate Safeguard's performance on content that reflects different cultural norms and potentially supplement it with your own policy-specific classifiers.

Subtle policy violations that require deep domain knowledge will likely get through. If your content policy says users can't discuss competitor products in a specific way, a general safety model won't know that. Safeguard 20B handles broad categories of harm - violence, illegal activity, sexual content, harassment. Custom policy enforcement still needs custom solutions.

There's also the question of bias. Every classifier has biases in what it flags and what it misses. Safety models can be more aggressive about flagging content from certain demographic groups or on certain topics, leading to disparate treatment that's itself a form of harm. I'd recommend monitoring Safeguard's behavior across different input populations and adjusting your threshold or supplementing with additional checks where you see imbalances.

dedicated versus built-in safety

The philosophical question behind Safeguard 20B is whether safety should be a separate concern or an integrated one. The frontier model providers have invested heavily in building safety into their primary models. Claude, GPT-4, Gemini - they all have built-in refusal behaviors and content policies.

I think both approaches are necessary, and neither is sufficient alone. Built-in safety is valuable because it operates with full context. The model knows the entire conversation history and can make nuanced judgments about whether a request is harmful given the context. But built-in safety is also brittle because it can be subverted through the same interface it's protecting. Jailbreaks work precisely because the safety behavior and the instruction-following behavior share the same model and the same context.

A dedicated external safety model doesn't share that context. It evaluates content independently, which makes it resistant to the class of attacks that target the primary model's instruction-following behavior. It's also cheaper to update and iterate on. Retraining or fine-tuning a 21B MoE safety model on new attack patterns is faster and less expensive than retraining a 400B general-purpose model. And since Safeguard is released under the Apache 2.0 license with open weights, you can customize it for your specific policies.

The practical architecture is defense in depth. Your primary model's built-in safety catches most issues. Safeguard 20B catches some that slip through. Your application-level rules catch domain-specific violations. Human review catches the rest. No single layer is complete. The stack of layers, each cheap and fast enough to run on every interaction, gets you much closer to complete coverage.

what this means for the market

Safeguard 20B is part of a broader trend toward specialized models. The era of one model doing everything is giving way to an era of model pipelines where different models handle different concerns. A small fast model for routing. A specialized model for safety. A large capable model for reasoning. Another specialized model for code generation or image understanding.

This decomposition makes systems more reliable, more cost-effective, and easier to improve incrementally. When your safety layer needs updating, you swap in a new version of the safety model without touching anything else. When you want to upgrade your reasoning capability, you swap the primary model. Each component improves independently.

For developers building agent systems, this is a significant shift in how to think about architecture. The question isn't just "which model is best?" It's "which combination of models gives me the best performance, safety, and cost profile for my specific workload?" Safety is no longer a tax on your inference budget. With models like Safeguard 20B, it's negligible.

frequently asked questions

can safeguard 20b replace human content moderators?

No, and it shouldn't. Safeguard 20B is a first-pass filter that handles the high-volume, clear-cut cases automatically. It catches obvious policy violations quickly and cheaply, which means your human moderators spend their time on the ambiguous cases that actually require human judgment. The model will miss edge cases, misclassify borderline content, and lack the cultural context that experienced moderators bring. Think of it as the layer that reduces the haystack your human team has to search through, not a replacement for the team itself. The right architecture combines automated screening for volume with human review for quality.

does it work with models from other providers, or only openai models?

Despite being built by OpenAI, Safeguard 20B works as a standalone screening layer regardless of what primary model you're using. It evaluates text independently, so you can chain it with Claude, Gemini, Llama, Mistral, or any other model in your pipeline. The model doesn't need to know anything about your primary model. It just looks at text and classifies it. This provider-agnostic nature is actually one of its strengths. You can swap your primary model without changing your safety layer, and vice versa. The screening logic stays the same regardless of what's behind it.

is the 20B model enough for reliable safety classification?

For the majority of safety-relevant content, yes. Despite only activating 3.6 billion parameters per forward pass (thanks to the MoE architecture), the model handles direct policy violations, explicit harmful content, and common adversarial patterns reliably. The reasoning chain of thought helps it evaluate content against custom policies rather than relying on rigid pattern matching. Where size becomes a constraint is on highly sophisticated attacks that require deep contextual reasoning to detect - think multi-turn conversations where the harmful intent only becomes apparent when you connect information across many exchanges. For those cases, OpenAI's larger gpt-oss-safeguard-120b or a human reviewer will catch things the 20B model misses. The practical approach is to use Safeguard 20B as a fast, cheap filter for the 95% of cases it handles well, and route uncertain classifications to more thorough review.

api reference

about

gpt-oss safeguard 20b

get an api key

create one in settings → api keys. the examples read it from INFERENCE_API_KEY.

bash
1export INFERENCE_API_KEY="inf_your_key"

1. calling the api

install the client

nothing to install. any http client works; the examples use curl, and jq to read responses. every response wraps its result in a data field.

run and get result

send "wait": true to hold the connection until the task finishes. without it the call returns right away with the task still running.

bash
12# "wait": true holds the connection until the task finishes.3# the response is {"data": {"id", "status", "status_text", "output", ...}}4curl -X POST https://api.inference.sh/apps/run \5  -H "Authorization: Bearer $INFERENCE_API_KEY" \6  -H "Content-Type: application/json" \7  -d '{8    "app": "openrouter/gpt-oss-safeguard-20b",9    "input": {},10    "wait": true11  }'

stream live updates

get real-time progress updates as the task runs. ideal for showing progress bars, partial results, or long-running tasks. send "stream": true and the response is a server-sent event stream that ends when the task does.

bash
12# "stream": true answers with server-sent events until the task finishes3curl -N -X POST https://api.inference.sh/apps/run \4  -H "Authorization: Bearer $INFERENCE_API_KEY" \5  -H "Content-Type: application/json" \6  -d '{7    "app": "openrouter/gpt-oss-safeguard-20b",8    "input": {},9    "stream": true10  }'

run in the background

start the task and get its id back right away, then check on it later. for long tasks, or when you'd rather be called back, see webhooks.

bash
1# without "wait" the call returns the task right away (status 1, "received")2TASK_ID=$(curl -s -X POST https://api.inference.sh/apps/run \3  -H "Authorization: Bearer $INFERENCE_API_KEY" \4  -H "Content-Type: application/json" \5  -d '{6    "app": "openrouter/gpt-oss-safeguard-20b",7    "input": {}8  }' | jq -r '.data.id')910# later: read its state. done when status is 10 (completed), 11 (failed) or 12 (cancelled)11curl -s https://api.inference.sh/tasks/$TASK_ID \12  -H "Authorization: Bearer $INFERENCE_API_KEY" | jq '.data | {status, status_text, output}'

2. authentication

the api uses api keys for authentication. see the authentication docs for detailed setup instructions.

3. files

file inputs are automatically handled by the sdk. you can pass local paths, urls, or base64 data.

automatic upload

pass urls directly or use data uris for inline content.

bash
1# pass URLs or data URIs as input values2curl -X POST https://api.inference.sh/apps/run \3  -H "Authorization: Bearer $INFERENCE_API_KEY" \4  -H "Content-Type: application/json" \5  -d '{6    "app": "openrouter/gpt-oss-safeguard-20b",7    "input": {8      "image": "https://example.com/image.png",9      "audio": "data:audio/mp3;base64,..."10    },11    "wait": true12  }'

manual upload

you can also upload files manually and use the returned url.

bash
1# 1. create the file: the response has an upload_url and the file's uri2FILE=$(curl -s -X POST https://api.inference.sh/files \3  -H "Authorization: Bearer $INFERENCE_API_KEY" \4  -H "Content-Type: application/json" \5  -d '{"files": [{"filename": "image.png", "content_type": "image/png"}]}')67# 2. PUT the bytes to upload_url8curl -X PUT "$(echo "$FILE" | jq -r '.data[0].upload_url')" \9  -H "Content-Type: image/png" \10  --data-binary @image.png1112# 3. pass the uri as an input value13echo "$FILE" | jq -r '.data[0].uri'

4. webhooks

get notified when a task completes by providing a webhook url. when the task reaches a terminal state (completed, failed, or cancelled), a POST request is sent to your url with the task result.

bash
1curl -X POST https://api.inference.sh/apps/run \2  -H "Authorization: Bearer $INFERENCE_API_KEY" \3  -H "Content-Type: application/json" \4  -d '{5    "app": "openrouter/gpt-oss-safeguard-20b",6    "input": {},7    "webhook": "https://your-server.com/webhook"8  }'

webhook payload

your endpoint receives a JSON POST with the task result:

json
1{2  "event": "task.completed",3  "timestamp": "2024-01-15T10:30:05Z",4  "data": {5    "id": "task_abc123",6    "short_id": "abc123",7    "status": 10,8    "status_text": "completed",9    "output": { ... },10    "created_at": "2024-01-15T10:30:00Z",11    "updated_at": "2024-01-15T10:30:05Z"12  }13}
eventstringtask.completed, task.failed or task.cancelled
timestampstringiso timestamp of the delivery
data.idstringtask id
data.short_idstringshort task id
data.statusnumberterminal status (10=completed, 11=failed, 12=cancelled, 13=rejected)
data.status_textstringthe status as a word: completed, failed or cancelled
data.outputobjecttask output (when completed)
data.errorstringerror message (when failed, omitted otherwise)
data.session_idstringsession id (when the task ran in a session, omitted otherwise)
data.created_atstringiso timestamp
data.updated_atstringiso timestamp

5. schema

input

reasoning_excludeboolean

exclude reasoning tokens from response

default: false
textstring

text

default: ""
imagesarray

images

filesarray

files

attachmentsarray

attachments

contextarray

context

default: []
rolestring

chatmessagerole

default: "user"
options:"system""user""assistant""tool""injection""compaction""event"
reasoningstring

reasoning

tool_call_idstring

tool call id

system_promptstring

system prompt

default: "you are a helpful assistant that can answer questions and help with tasks."
context_sizeinteger

the context size for the model.

default: 200000
temperaturenumber

temperature

default: 0.7min:0max:1
top_pnumber

top p

default: 0.95min:0max:1
top_kinteger

top k

min_pnumber

min p

frequency_penaltynumber

frequency penalty

presence_penaltynumber

presence penalty

repetition_penaltynumber

repetition penalty

seedinteger

seed

stoparray

stop

max_tokensinteger

max tokens

default: 64000
reasoning_effortstring

reasoning effort. this model always reasons; it cannot be turned off.

default: "low"
options:"low""medium""high"
reasoning_max_tokensinteger

reasoning max tokens

toolsarray

tools

tool_choiceobject

toolchoice

response_formatobject

responseformat

output

imagesarray

images

reasoningstring

reasoning

reasoning_stateobject

reasoning state

responsestring

response

tool_callsarray

tool calls

usageobject

llmusage

ready to run GPT-OSS Safeguard 20B?

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.