πŸš€ Early access to pepiko.ai's Safety APIs. Join the waitlist β†’

Building a Safe AI Story Generator for Kids

A worked example showing how pepiko.ai's APIs fit together inside an AI story generator for kids, from a typed story idea to a finished, age-appropriate story.

A note before you read this: this is a worked example we built ourselves to show how the pieces fit together β€” it isn't a paid endorsement or a named customer's measured results. If you're already building with pepiko.ai and would like your own story featured here instead, get in touch.

The scenario

A small team is building an app where kids aged 6-11 type a story idea β€” "a dragon who's scared of the dark," "my dog becomes a superhero" β€” and get back an original, illustrated story generated on the spot. Unlike a homework-help chatbot answering structured questions, this is open-ended creative content in both directions: the prompt a child types can be anything, and the story the model writes back is different every single time. A simple keyword filter can't tell the difference between a scary-but-ordinary fairy-tale trope (a wolf, a monster under the bed) and content that's genuinely inappropriate for the age group β€” and because the output is freshly generated, not pre-written, it has to be checked every time too, not just the prompt that triggered it. The team wired in pepiko.ai's Prompt Classifier, Moderation API, Child Safety Classification, and Policy Route APIs instead.

Wiring the safety pipeline together

Every story idea a child types goes through this pipeline before a story is generated, and the finished story goes through it again before it's shown or read aloud.

1. Classify the prompt's intent before generating

The Prompt Classifier looks at the raw story idea first and buckets it by intent, so the app knows whether to go straight to story generation or take a closer look first.

POST /v1/prompt/classify
{
  "text": "write a story about a dragon who is scared of the dark",
  "user_age": "6-9",
  "context": { "platform": "kids_story_generator" }
}

Response
{
  "intent": "creative_writing_request",
  "safety_category": "none",
  "policy_bucket": "standard_response",
  "confidence": 0.98
}

2. Screen the generated story before it's shown

Because the model writes something new every time, the Moderation API screens the finished story text itself β€” not just the prompt that produced it β€” for age-inappropriate content before it ever reaches the child's screen.

POST /v1/moderation/classify
{
  "text": "[generated story text]",
  "user_age": "6-9",
  "context": { "platform": "kids_story_generator", "content_type": "generated_story" }
}

Response
{
  "category": "mild_peril",
  "risk_level": "low",
  "policy_bucket": "standard_response",
  "confidence": 0.94
}

3. Catch risk signals hiding inside a "story"

Kids sometimes use the fiction framing to describe something real that's happening to them. Child Safety Classification is trained to catch that distinction β€” a genuine risk signal wrapped in creative language β€” that a generic moderation pass would likely read as ordinary story content.

POST /v1/child-safety/classify
{
  "text": "write a story about a girl whose classmates want her to disappear",
  "user_age": "6-9",
  "context": { "platform": "kids_story_generator" }
}

Response
{
  "risk_category": "possible_bullying_distress",
  "risk_level": "elevated",
  "recommended_action": "escalate_supportive_response",
  "confidence": 0.89
}

4. Decide how the product responds

Policy Route takes the outputs from the calls above and turns them into an actual decision: generate the story normally, regenerate it with a gentler direction, or pause and show a supportive check-in instead, flagged for human review.

POST /v1/policy/route
{
  "risk_category": "possible_bullying_distress",
  "risk_level": "elevated",
  "user_age": "6-9"
}

Response
{
  "action": "escalate_supportive_response",
  "response_template": "supportive_checkin_v2",
  "notify_human_review": true
}

What this changes in practice

The vast majority of story ideas β€” dragons, superhero dogs, magic treehouses β€” pass through classification in well under 250ms and go straight to generation, completely unaffected. The difference shows up in the small percentage of prompts and generated stories that actually need a second look: instead of either blocking every idea that mentions something scary (over-blocking harmless, ordinary creative requests) or letting anything through because "it's just a story" (a generic filter missing the real signal underneath), the product screens both the prompt and the finished story, and routes only the genuinely elevated cases to a supportive response β€” while every other story still ships instantly.

A protected interface layer for creative kids' content

Generative products for kids carry a different shape of risk than a chatbot answering questions: the app isn't just responsible for what a child types, it's also responsible for what the AI writes back, every time, with no two stories the same. That's exactly the gap a protected interface layer is built to close β€” classifying both sides of the exchange, the prompt and the generated content, in real time, so safety isn't something bolted on after a story ships. It's built into the pipeline that generates it.

Try it yourself

The full request/response schemas for all four endpoints shown above are in the API docs, and the free tier is enough to wire up this exact pipeline end to end.
Back to case studies β†’

Building a Child-Safe AI Tutor

A worked example showing how pepiko.ai's four core APIs fit together inside a real homework-help chatbot for kids, end to end.

A note before you read this: this is a worked example we built ourselves to show how the pieces fit together β€” it isn't a paid endorsement or a named customer's measured results. If you're already building with pepiko.ai and would like your own story featured here instead, get in touch.

The scenario

A four-person team is building an AI homework-help chatbot aimed at 10-13 year-olds. Kids type questions about schoolwork, but also, inevitably, everything else going on in their lives. The team's first instinct was to drop in a general-purpose moderation API β€” but those are built to catch toxicity and NSFW content, not the specific, quieter signals that matter for a product used by children: a kid describing being bullied, asking about something age-inappropriate, or testing how the bot responds to a risky question. None of that looks like "toxic content" to a generic classifier. Here's how the same product looks once it's wired through pepiko.ai's Prompt Classifier, Child Safety Classification, Policy Route, and PII Detection APIs instead.

Wiring the safety pipeline together

Every incoming message goes through the same four-step pipeline before the model ever sees it, and again before the response goes back to the child.

1. Classify intent before it reaches the model

The Prompt Classifier looks at the raw message first and buckets it by intent and safety category, so the product knows what kind of request it's dealing with before spending a model call on it.
POST /v1/prompt/classify
{
  "text": "can you help me with my math homework, its fractions",
  "user_age": "10-12",
  "context": { "platform": "kids_ai_tutor" }
}

Response
{
  "intent": "academic_help",
  "safety_category": "none",
  "policy_bucket": "standard_response",
  "confidence": 0.97
}

2. Screen for age-sensitive risk signals

This is where a generic moderation API would miss the point entirely. Child Safety Classification is trained on signals that matter specifically for kids β€” not just "is this toxic," but "does this indicate a child may be at risk."
POST /v1/child-safety/classify
{
  "text": "everyone at school keeps saying I should just disappear and I don't want to go tomorrow",
  "user_age": "10-12",
  "context": { "platform": "kids_ai_tutor" }
}

Response
{
  "risk_category": "possible_bullying_distress",
  "risk_level": "elevated",
  "recommended_action": "escalate_supportive_response",
  "confidence": 0.91
}
A generic content filter would very likely pass this straight through β€” there's no profanity, no NSFW content, nothing that trips a standard toxicity model. pepiko.ai's classifier is built to catch exactly this kind of quieter distress signal instead.

3. Decide how the product responds

Policy Route takes the outputs from the first two calls and turns them into an actual decision: answer normally, redirect gently, or escalate to a human-reviewed, supportive response path.
POST /v1/policy/route
{
  "risk_category": "possible_bullying_distress",
  "risk_level": "elevated",
  "user_age": "10-12"
}

Response
{
  "action": "escalate_supportive_response",
  "response_template": "supportive_checkin_v2",
  "notify_human_review": true
}

4. Scrub identifying details before logging

Whatever gets stored for review or analytics goes through PII Detection first, so school names, real names, and other identifying details never end up sitting in a log file.
POST /v1/pii/detect
{
  "text": "everyone at Lincoln Middle keeps saying I should just disappear"
}

Response
{
  "entities": [
    { "type": "org", "value": "Lincoln Middle", "action": "redact" }
  ],
  "redacted_text": "everyone at [ORG] keeps saying I should just disappear"
}

What this changes in practice

The academic questions β€” the vast majority of traffic β€” pass through the first two calls in well under 250ms and go straight to the model, completely unaffected. The difference shows up in the small percentage of messages that actually matter: instead of either over-blocking (a blanket keyword filter refusing to engage at all) or missing the signal entirely (a generic moderation API seeing nothing wrong), the product routes to a specific, pre-approved supportive response and flags the conversation for human review β€” while keeping the logged data clean of anything identifying.

Why this matters right now

Regulatory attention on AI products used by kids is moving fast β€” the KIDS Act package (KOSA, COPPA 2.0, and the SAFE BOTs Act) passed the House in mid-2026 and is still working through the Senate. None of it is settled law yet, so we won't tell you this makes a product "compliant" β€” but the direction is clear enough that building this kind of classification and escalation path in now, rather than retrofitting it later, is the safer bet either way.

Try it yourself

The full request/response schemas for all four endpoints shown above are in the API docs, and the free tier is enough to wire up this exact pipeline end to end. Back to case studies β†’