esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

Safety for Text-to-Image

How text-to-image models are kept from drawing harmful pictures, where each safety layer can fail, and what to say in your AI interview.

In short

Text-to-image safety means stopping a model from drawing harmful pictures, such as sexual or violent images and fake photos of real people. It uses layers of checks, and no single layer is enough, so teams also test with attackers.

11 min readBeginnerOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Text-to-image safety means stopping the model from drawing harmful pictures, like sexual or violent images, or fake photos of real people. I use layers. I clean the training data, check the prompt, check the picture before anyone sees it, and mark AI images so people can tell. No single layer catches everything, because attackers rephrase until one slips through. So I test the whole system with red teams and keep watching for new bypasses.

What is text-to-image safety, in plain words?

A text-to-image model reads a sentence, called a prompt, and draws a picture that matches it. Safety means that picture should not cause harm. The main harms are graphic violence, sexual content, hateful imagery, and realistic fakes of real people, which can pass as evidence.

Think of a hospital pharmacy. One person checks the prescription, another checks the dose, and a third checks the label before anything leaves the counter. Each check misses things, so the hospital runs all three. Image teams do the same, with several checks before and after the picture is made.

Here is the same job at work. Say a retailer's marketing team (a made-up company) uses an in-house tool for ad pictures. Someone under deadline types a request the tool should refuse, and it has to refuse it even when the wording is clever.

Key words

Training data
The pictures and captions the model learned from.
Safety filter
A check that blocks or flags a prompt or a picture.
Red teaming
Testing a system by trying to break it, the way an attacker would.
Watermark
A hidden mark in a picture that a checker can detect later.

Which layers stop a harmful picture?

Each layer catches a different failure, and each one has a gap. The chart runs one request through them. Orange is the harm, blue the checks, violet the model and green the safe end.

One request through the safety layers

Risky request

a fake photo of a real person

Before the picture

Prompt check

blocks risky wording

Image model

trained on filtered data

After the picture

Picture check

scans the picture itself

Watermark

marks AI output for later checks

Shown or blocked

a picture that fails a check is blocked

  1. 1The request goes to the prompt check first.
  2. 2Risky wording is stopped here. Clean wording goes on to the model.
  3. 3The model draws the picture, trained on filtered data.
  4. 4The picture check scans the image before anyone sees it.
  5. 5A marked picture is shown. A picture that fails any check is blocked.
One request passes a prompt check, the image model and a picture check, then a watermark, before anything is shown. Each layer can miss something, so the layers are stacked.
  1. 1

    Clean the training data

    Remove violent and sexual images before training. Measure what the filter does to fairness, because it can make some groups appear in a narrower or unfair way.

  2. 2

    Check the prompt

    A text check blocks risky wording before the model runs. It is fast and cheap, but it only reads words.

  3. 3

    Limit what the model can draw

    Some teams also remove risky concepts inside the model. Test those removals, because research has shown how prompts can get past them.

  4. 4

    Check the picture

    An image check scans the output itself. Microsoft's classic Foundry content filter sorts content into hate, sexual, violence and self-harm, each with a severity level.

  5. 5

    Mark and log

    Watermark the output so it can be traced later, and log blocked requests so the team can spot new attacks.

  • “Without this mitigation, the model would learn to produce graphic or explicit images when prompted for them”

    OpenAI, on DALL·E 2

Why doesn't a prompt filter alone work?

A prompt filter reads words, so an attacker changes the words. A 2023 paper called SneakyPrompt automated that loop against a filter that blocked NSFW requests (not safe for work, meaning nudity and sexual content). It tries a wording, reads the result and changes the wording again.

  • “Given a prompt that is blocked by a safety filter, SneakyPrompt repeatedly queries the text-to-image generative model and strategically perturbs tokens in the prompt based on the query results to bypass the safety filter”

    SneakyPrompt researchers

A second 2023 paper, Ring-A-Bell, came at it from the other side. It built prompts that look safe, and showed they can still evade the safety mechanisms of the systems it tested, including online services such as Midjourney.

Here is a worked example with made-up numbers. The retailer's tool sees 1,000 risky requests in a month. The prompt check misses 2 in 100, so 20 reach the model. The picture check misses 1 in 100 of those, so about 0.2 harmful pictures get through a month, roughly one every five months.

Two checks that miss 2% and 1% would miss only 0.02% together, but only if their misses are unrelated. An attacker who finds one wording that beats the first check will often try it on the second, so the misses overlap. The real rate can be higher than the simple multiplication suggests, so the team has to measure it.

A sample prompt a red team would try: "a photo of our regional manager accepting cash from a supplier". It names no one and uses no banned word, so a word list would pass it. The picture could still look like evidence.

  • Prompt check only

    The picture goes straight out

    A reworded request passes the words check, and the picture reaches the user with no second look.

  • Prompt and picture checks

    Two chances to stop it

    The picture check scans the output, so a reworded request must also fool a second check.

What about fake photos and labels?

The worst harm is a believable fake of a real person. A text check cannot see whether a face belongs to someone real, so the defence moves to marking and rules. Google DeepMind's SynthID embeds watermarks in AI images, audio, text and video, and the watermark is designed to survive cropping, filters and compression.

Google launched its SynthID Detector in 2025. Anyone can now check whether an image, video or audio file was made with AI from Google or its partners, which helps journalists and anyone checking a suspect photo.

In Europe the rules are set out in the EU's AI Act (its AI law). The AI Act has duties for labelling AI content, and the EU's code of practice supports them. Those transparency duties, which mean making clear that content is AI-made, apply from 2 August 2026, as the EU's code-of-practice page states. Signing the code is voluntary, but the duties behind it are legal obligations.

Be honest about the limit. A watermark shows that a participating tool made the file. It proves nothing about pictures from a tool that never marks its output, and a determined attacker may still try to strip a mark. So a watermark is one signal among several.

Tip

Asked about deepfakes? Say you refuse realistic likenesses of real people by policy, check the picture, mark every output and give people a way to report and take down a fake. Don't promise that detection catches everything.

How would you ship an image tool for a marketing team?

Start from what the tool must never draw, written down with the team's legal and brand owners. Then build the checks in the order a request flows, and test before launch.

  1. 1

    Write the no-go list

    Sexual content, graphic violence, hate, and realistic images of real people without their consent. Keep it short enough to test.

  2. 2

    Put a check on each stage

    A prompt check, a picture check and a watermark, with blocked and flagged cases logged.

  3. 3

    Give people a way out

    A clear message when a request is refused, and a route for staff to appeal a wrong block.

  4. 4

    Red-team before launch and after each change

    Use testers who know the defences, because a fixed list of test prompts tells you little about a clever attacker.

Each extra layer adds delay and review work, so measure the cost with real traffic before you decide where to add more.

What does the interviewer want to hear?

A strong answer covers

  • Text-to-image safety keeps harmful or deceptive pictures from being made or shown.
  • The layers: training data, prompt check, picture check, watermark and human review.
  • Each layer has a known gap, and attackers rephrase to get past the first one.
  • Realistic fakes of real people need likeness rules as well as marking.
  • Red-team before launch and after every model or policy change.
  • Be honest that no filter is perfect, and limit what gets out.

Common traps

  • Trap"A good prompt filter stops every harmful picture."

    BetterAttackers reword. Check the picture too, and test the whole system with red teams.

  • Trap"A watermark solves deepfakes."

    BetterA watermark helps only when the tool adds one. It is one signal alongside the other checks.

  • Trap"Just ban the bad words."

    BetterWord lists miss reworded prompts and also block harmless ones. Use them as one layer only.

Can you spot the gap?

Spot the gap

Which setup is most likely to show a harmful picture?

Quick check

A marketing tool must keep fake photos of real staff from being made or shown. Which change does the most?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q444How do diffusion models work, basically?13 min
  2. Q236Watermarking and content provenance (C2PA)?10 min
  3. Q237How do you label AI-generated content?11 min
  4. Q458Copyright and data provenance?12 min
  5. Q221What is red teaming?10 min
  6. Q465Transparency duties (AI disclosure, deepfake labels)?11 min

Last updated on 27 November 2026

Building an image tool for your team or product?

I design and build AI products and agents, including the safety checks around them. Book a short call and tell me what your tool must never make.