Prompts

Your team’s prompts deserve their own database, not a code repo.

Versioned templates with Jinja2 variables, A/B testing, AI recommendations, and per-key selection. Ship prompt changes without redeploying — and roll back in one click when they regress.

prompt-library · acme-inc

Active templates

support-agent.jinja2v3 · active
code-reviewer.jinja2v7 · active
sql-explainer.jinja2v2 · A/B 60/40
onboarding-bot.jinja2v1 · draft
Total versions tracked47
Avg activation latency< 50 ms
Jinja2versionedaudit-logged
Versioning
Every save

Snapshot + diff + author + timestamp

Per-key selection
extra_body

nrouter_prompt_template_id on any request

A/B variants
Deterministic

Sticky by virtual key

Prompt logs
Opt-in

Honors org-level data policy

The lifecycle

support-agent.jinja2 — every version, one pointer, zero redeploys.

The active-version pointer moves; your code never changes. Roll back from the dashboard in one click when a change regresses.

v1

Initial draft

Authored in the dashboard. Never committed to a repo.

v2

Token-reduction pass

-15% input tokens. Diff reviewed, one-click activated.

v3

Clarity rewrite

active

Active now. Serving every request that references the template.

v4

Draft — A/B candidate

A/B running

Running 60/40 against v3. Promote or discard from the dashboard.

Variants

Test prompts the way you test features

Don’t guess which version is better. Measure it. Split buffered traffic deterministically, capture provider-completed cost, latency, and token outcomes per branch, and promote the winner without a code change.

A/B testing

Deterministic splits, statistical confidence

Create two or more variants with a configurable traffic split. Assignment is hash-deterministic per authenticated virtual key, so retries stay on the same branch. Provider-completed buffered metrics roll up in the analytics dashboard.

  • Lifecycle: draft → running → paused → completed
  • Per-variant cost, latency, token, and success metrics
  • Promote the winner from the dashboard without code change
  • Stop the test instantly if a variant regresses
ab_test · sql-explainer

Variant performance (last 24h)

Variant A · traffic60%
Variant A · avg cost$0.018
Variant A · p95 latency1 240 ms
Variant B · traffic40%
Variant B · avg cost$0.014
Variant B · p95 latency980 ms
runningdeterministic splitlogged
Full prompt reference: Jinja2, recommendations, audit, storage
Jinja2 templates
Strict double-brace scalar variables injected per request via nrouter_prompt_variables. Missing variables fail closed; authenticated system variables are applied last.
Version history + rollback
Every save creates a snapshot with author, timestamp, and diff. Linear version chain with an active-version pointer; activate any version instantly, no redeploy. Soft-delete preserves audit history.
AI-powered recommendations
Clarity rewrites with predicted quality lift, token-reduction passes with a -% estimate, passive-voice and ambiguous-role detection. Generated, never auto-applied. One-click apply creates a new version.
Per-request selection
Pass nrouter_prompt_template_id + nrouter_prompt_variables in extra_body on any chat completion — works with the unmodified OpenAI SDK in every language. Stripped from the upstream payload before forwarding.
Audit trail
Every save, activation, A/B start, and rollback captured with actor, IP, and full diff. Append-only, filterable, CSV + JSON export for SIEM ingestion — pinned for SOC 2 evidence collection.
Tenant-isolated storage
Templates, versions, and variable payloads live in org-scoped rows (nrouter.prompt_templates, nrouter.prompt_versions) with Row-Level Security. Cross-org reads are impossible at the database layer.
FAQ

Common prompt questions

How do variables work in a prompt template?

Templates use strict double-brace scalar variables, with values injected at request time via nrouter_prompt_variables in extra_body. Missing variables fail closed, and org_name, model, timestamp, and user_id come from authenticated request context and apply last.

Can I version prompts and roll back?

Yes. Every save creates a new version with author, timestamp, and diff. Any version can be activated instantly from the dashboard. No redeploy. If a prompt change regresses output quality, roll back to the previous version in one click.

How does A/B testing compare prompts?

Create two or more model or immutable prompt-version variants and set a traffic split (e.g. 60/40). nRouter keeps each authenticated virtual key on a deterministic variant and logs provider-completed buffered latency, cost, and token outcomes.

Is prompt data logged anywhere outside my org?

No. Prompt templates, versions, and variable payloads are stored in your org-scoped Supabase rows with Row-Level Security. Nothing crosses organization boundaries. You control logging granularity per-org via the data policy setting.

Ship without redeploying

Move every prompt out of the codebase — today

Free to start. Versioning, variants, recommendations, and the audit trail are unlocked on every plan from day one.