A prompt glued to an endpoint. One jailbreak and it breaks.

INTRODUCING · PYTHON

Guardrailed Agentic AI API

A hardened agent API: attacks screened before the model, leaks screened after it, prompts versioned behind an evaluation gate.

livePythonFastAPILangGraphPydanticSQLite
The live service: Swagger /docs flanked by a blocked prompt-injection response and an SSE stream
The problem

Most AI features are a prompt glued to an endpoint: one jailbreak, rate limit, follow-up question or careless prompt edit and they break.

One jailbreak and it breaks
The solution

Every request is screened before the model and every answer before it leaves; blocked requests cost zero tokens; prompts ship only through an audited evaluation gate; every answer is traceable by request ID.

How it works

01
Edge
Each call gets a request ID, an optional API-key check and a per-client rate limit (429, not a surprise bill).
02
Input guardrail
Injection and system-prompt extraction are blocked before the model is ever called.
03
Plan and act
The model plans in a strict schema with retry/backoff; code runs the tools; memory persists per session.
04
Output guardrail
Answers are screened for prompt leakage before they leave; streamed content is released only after this check.
05
Observe
Traces, JSON logs and Prometheus metrics share one request ID and name the prompt version that answered.
Watch the Guardrailed Agentic AI API film

English subtitles burned in · Spanish CC on YouTube

Features

Promise one: attacks stay out.

Every request is screened for prompt injection before the model is called (OWASP LLM01). A blocked request returns a generic error and costs zero tokens.

Promise two: secrets stay in.

Answers are re-screened for system-prompt leakage and reflected injection before they leave (OWASP LLM02). A flagged answer is replaced with a safe message.

Promise three: every change is proven.

Prompts are versioned artifacts promoted only if they pass an A/B evaluation gate; the safety metric can never be overridden. Every change is sealed in a hash-chained audit log and rollback takes one call.

A hiccup? It retries.

Conversations persist per session, so follow-ups like "now double that" resolve against full history. Transient model errors are retried with backoff instead of becoming 500s.

One request ID. Every answer traceable.

One request ID ties traces, JSON logs and Prometheus counters together. Every response names the prompt version and hash that produced it.

Production-shaped by default.

Per-client rate limiting, optional API-key auth and a non-root Docker image with a health check. CI runs the full suite with zero secrets.

Architecture

Architecture of the Guardrailed Agentic AI API: FastAPI edge checks, injection guardrail, planner with tools, output guardrail, prompt registry, checkpoints and observability stores
Source: project README
Text description of the diagram

The Client hits the FastAPI edge (request-id, security headers, rate limit, API key) over POST /agent/run and /agent/stream. The edge passes the guardrail (sanitize + injection screen, OWASP LLM01): blocked input short-circuits to error_output and then the JSON/SSE response; safe input reaches the planner (structured output with retry/backoff), then execution tools (calculator, echo, web_search), then the output_guardrail leak screen (OWASP LLM02) before the JSON/SSE response. The Prompt Registry (prompts/<name>/vN.yaml + registry.json) supplies the promoted template and links to the hash-chained audit log; the planner keeps per-session checkpoints in SQLite and emits opt-in traces; the edge emits structlog JSON logs and Prometheus /metrics counters.

Measured. Not claimed.

0
Automated tests
Fully offline, deterministic planner (1 live-only test skipped)
0
Coverage
Line coverage, measured in CI
0
Injection block rate
Gate dataset · 22 synthetic cases · planner v1 · 2026-10-09
0
Prompt leak rate
Same gate dataset
Green, zero secrets
CI
ruff + mypy + pytest + Docker build
KNOWN LIMITATIONS
  • SQLite memory suits demos and light workloads; high concurrency should move to a Postgres checkpointer.
  • Shared-secret API-key auth, not OAuth2/JWT identity; no multi-tenant isolation.
  • The 22-case evaluation dataset guards against regressions on known cases; it does not prove prompt quality.

A real, running service. Not a slide.

Stack

PythonFastAPILangGraphPydanticSQLiteLangfusePrometheusDocker
NEED AGENTS YOU CAN TRUST IN PRODUCTION?

Your product. Your tools. Your rules.

Guardrails, streaming, memory and a prompt gate — the boring parts are already done; the tools shown are examples, adapted to your systems on request.