Prompt registry
Last updated: 2026-11-27T14:39:27-03:00 (UTC-3)
Keep your product’s prompts in one place, with versions, explicit publishing and history. A prompt has messages with variables ({{input}}), an owner (the team) and immutable revisions; only the published revision is used in eval experiments (any stored revision with prompt_tracking) and in the preview. Flag: prompt_registry.
The registry stores text that you configure. It does not capture prompts from inference traffic; with prompt revision on traffic a request records which prompt and revision it was built from (identifiers, never the text). Optional enforced system prompts explicitly bind a static published system-only revision to a Chat alias; registry creation alone never injects content.
| Flag | What it enables |
|---|---|
prompt_registry |
Inventory and reading; requires ui and PostgreSQL |
prompt_management |
Save, publish, revert and delete |
prompt_render |
Administrative preview of the published revision, without calling a provider |
prompt_json_schema |
Default off; typed json_schema_v1 creation, publication, reads and local rendering; requires prompt_registry |
prompt_api |
Default off; bearer-key read of the owning team’s current publication; requires prompt_registry |
prompt_api_render |
Default off; bearer-key local render; requires prompt_api |
prompt_scoped_read |
Reading by members of the owning team |
prompt_scoped_write |
Default-off explicit team-delegated draft/destructive actions; never implicitly publishes |
prompt_scoped_publish |
Default-off additional publication boundary, requiring scoped write |
prompt_delegation_management |
Default-off admin policy staging, version/base CAS, adoption and revert |
prompt_entitlements |
Also requires the prompt_scoped_read right in the team’s plan |
prompt_tracking |
Default off (tenant action, plan right prompt_tracking); the prompt revision on traffic: render tokens, the prompt headers, traffic per revision, the query fields and the prompt variables of evaluators; requires prompt_registry |
prompt_events |
Default off (operator control); the prompt events on alert channels and alert rules; requires prompt_registry |
prompt_labels |
Default off (tenant action, plan right prompt_labels); labels and Deploy to: labels such as production pointing at one revision each, read and rendered by label, recorded on traffic; requires prompt_registry and prompt_management |
prompt_improve |
Default off (tenant action, plan right prompt_improve); Improve: a suggestion for a draft through the chat alias the team chose, accepted into a new draft; requires prompt_registry and prompt_management |
How to declare one
Section titled “How to declare one”prompts: - id: support-response team: existing-team-id # the ID of the owning team name: Support response description: Reviewed support text schema_profile: flat_strings_v1 messages: - role: system content: Answer clearly. - role: user content: "Help with {{input}}" variables: input: required: true min_length: 1 max_length: 8192| Key | Default | What it does |
|---|---|---|
prompts[].id |
required | Unique identifier, used in the API and the console |
prompts[].team |
required | ID of the owning team |
prompts[].name |
required | Display name, up to 128 characters of text |
prompts[].description |
empty | Up to 2048 characters, shown in the registry |
prompts[].disabled |
false |
Keeps the prompt and its history but refuses renders and reads of its publication |
prompts[].schema_profile |
required | flat_strings_v1 (string variables, below) or json_schema_v1 (typed variables) |
prompts[].messages[].role |
required | system, user or assistant |
prompts[].messages[].content |
required | The message text; {{name}} inserts a variable |
prompts[].variables.<name>.required |
false |
The render fails when the variable is missing |
prompts[].variables.<name>.min_length |
0 |
Fewest Unicode characters the value may have |
prompts[].variables.<name>.max_length |
required | Most Unicode characters the value may have, up to 8,192 |
prompts[].variables.<name>.enum |
none | The only values the variable accepts |
prompts[].variable_roles.<name> |
none | query (the user’s question) or context (the retrieved text), for the evaluators that read {{prompt.query}} and {{prompt.context}}; names a declared variable (also of json_schema_v1); omitted when empty, so a prompt without it keeps its content hash |
Prompts are also created and edited in the console (Prompt registry) and in the API (/api/v1/admin/prompts). The YAML is validated even when the flags are off.
Flat string variables
Section titled “Flat string variables”{{name}}inserts the value once.\{{in the text produces a literal{{.- An inserted value is never reinterpreted:
{{other}}inside a value stays as text. - Variables that are declared but not used, or used but not declared, are refused.
- In
flat_strings_v1, values are strings.required,min_length,max_length(up to 8,192 Unicode characters) andenumare validated. A missing optional variable becomes an empty string.
| Limit | Value |
|---|---|
| Messages per prompt | 1 to 32 (system, user, assistant, text only) |
| Variables | up to 64 |
| Template text | 64 KiB |
| Rendered text | 128 KiB decoded, with encoded message JSON also capped at256KiB |
| Prompts | up to 1,000 IDs, counting deleted ones |
| Revisions per prompt | up to 100 |
flat_strings_v1 is a simple profile, not full JSON Schema.
Typed JSON variables
Section titled “Typed JSON variables”Choose schema_profile: json_schema_v1 explicitly and enable features.prompt_json_schema: true (default false, requiring prompt_registry). The console keeps the existing flat-string preset as its first choice. The new profile accepts structured values with a closed, bounded subset of JSON Schema2020-12. It validates locally; there is no schema fetching, provider call or executable template language.
features: ui: true prompt_registry: true prompt_management: true prompt_render: true prompt_json_schema: trueprompts: - id: reviewed-order team: existing-team-id name: Reviewed order schema_profile: json_schema_v1 messages: - role: user content: "Customer {{customer}}, orders {{orders}}, approved {{approved}}" input_schema: type: object additionalProperties: false properties: customer: {type: string, minLength: 1, maxLength: 128} orders: type: array maxItems: 10 items: {type: integer, minimum: 0, maximum: 1000000} approved: {type: boolean} required: [customer, orders]Use the owning active team’s real ID. For a typed definition, omit variables (or supply an empty object); input_schema is required. Root type: object, explicit properties and additionalProperties: false are required. Every top-level declared property must occur as a placeholder, and every placeholder needs a declaration. There is no nested placeholder traversal.
The schema editor accepts JSON, while YAML uses a natural mapping. Preview accepts the original JSON object, for example {"customer":"Ana","orders":[1,2],"approved":true}. Strings are inserted as raw text; all other values use deterministic compact JSON. Missing optional values insert empty text, and declared nullable values insert literal null. An inserted {{other}} is never rendered again. The preview and bearer APIs always use the published revision’s profile, even when a newer draft has a different profile.
Supported schema keywords and defaults
Section titled “Supported schema keywords and defaults”| Keyword | Contract |
|---|---|
$schema |
Optional at root only, exactly https://json-schema.org/draft/2020-12/schema |
type |
Required: string, integer, number, boolean, null, object or array; nested nodes may use one non-null type plus null |
properties |
Explicit closed object fields; root names match [A-Za-z_][A-Za-z0-9_]{0,63} |
additionalProperties |
Required false for objects; extra fields are refused |
required |
Optional; absent means no required fields; only declared names, without duplicates |
items |
Required single schema for arrays; no tuples |
minItems, maxItems |
Optional array constraints, from0 through64; omitted constraints retain the hard64-item ceiling |
minLength, maxLength |
Optional string constraints, from0 through8192 Unicode points; omitted constraints retain the hard8192 ceiling |
minimum, maximum |
Optional inclusive numeric bounds inside the safe numeric domain below |
enum |
Optional1–100 individually bounded values; a runtime value must satisfy both enum membership and all other declared constraints |
Only those keywords are supported, and each must apply to its declared type. There are no references ($ref, $defs, IDs or anchors), combinators, default injection, patterns, formats, content keywords, coercion, YAML aliases/merges or schema network/file loading. Unknown and unsupported keywords are refused rather than ignored. Schema numbers and incoming JSON numeric lexemes are checked before conversion.
| Hard limit | Value |
|---|---|
| Schema JSON | 64KiB |
| Semantic schema depth / schema nodes | 5 /512; counts schema nodes rather than JSON metadata members |
| Total declared properties / root properties | 128 /64 |
| Input value depth / total nodes | 5 /4096 |
| Items per input array | 64; schema enum metadata independently permits100 |
| String value length | 8192 Unicode points |
| Render request body | 256KiB |
| Template / decoded rendered text / encoded messages | 64KiB /128KiB /256KiB, unchanged |
Numbers must be finite, inside ±9007199254740991, and preserve their mathematical decimal value through an ordinary binary64 JSON round trip. 0.1 is accepted; an overprecise decimal that rounds to another decimal is refused. A raw number has at most64 characters and exponent magnitude308. Use strings for larger identifiers or arbitrary-precision financial values. The editor preserves the raw schema/preview JSON when sending it; it never silently rounds an invalid value into an accepted one. Duplicate JSON members, invalid Unicode, wrong case and undeclared null values are refused. Schema constraints can narrow the hard bounds, never enlarge them.
Publication, flags, plans and upgrades
Section titled “Publication, flags, plans and upgrades”The existing owner, scopes, CAS/version, fingerprint, publication and audit rules apply unchanged. With feature plans enabled, typed scoped/bearer access additionally requires the team’s and applicable organization’s prompt_json_schema right. The flag does not grant permission. Turning it off preserves stored definitions/history and global administrative inspection for recovery; typed creation/save/publication/render and scoped/bearer typed content are refused. Delete/revert recovery remains available. Flat-string publications continue to work, including when their latest draft is typed.
No database migration is added. Upgrade all replicas to a supporting binary before enabling or publishing typed prompts. Existing flat fingerprints and wire shapes are unchanged. Older binaries/clients do not understand typed definitions: before downgrading, retire typed publications and restore compatible definitions/configuration. No automatic lossy conversion is performed. Evals share the same published-profile dispatcher; existing string-valued eval inputs must actually satisfy the schema, with no implicit text-to-object conversion.
Versions and publishing
Section titled “Versions and publishing”- A revision is the immutable content (1 to 100). Saving creates a new revision, as a draft.
- Publishing chooses the revision in use. The previous publication stays in effect until you publish another one.
- The version is the edit control: every write carries the
versionand the YAML base fingerprint that were read, and a concurrent change gets409. - Did the YAML change? A publication based on the old definition stops being valid until you review and publish again; nothing is republished on its own.
- Reverting a prompt from the YAML creates a draft from the current YAML and withdraws the publication. Deleting a console prompt keeps its owner and history.
Preview
Section titled “Preview”The preview renders the published revision with the values you type, without calling a provider. The values and the result are not stored in the database, logs, audit or the browser: leaving the screen discards everything.
Who can do what
Section titled “Who can do what”| Action | Who |
|---|---|
| Read, save, publish, revert, delete | Global admin |
Preview (prompts:render) |
Global admin |
| Read their own team’s prompts | user, team_viewer and team_admin, with prompt_scoped_read |
| Author an owned draft | Existing user/team_admin with explicit prompts:write delegation and all current ceilings |
| Publish an existing owned revision | Explicit prompts:publish delegation and publication switch/plan/license; separate from authoring |
| Scoped revert/delete | Explicit prompts:delete; publication withdrawal also requires publish authority |
| See prompt content | Global viewer and operator cannot |
- Team readers see only prompts of active teams they belong to; any mismatch between the YAML and the stored state hides the prompt from them, for safety. The history they see shows neither the administrative actor nor the request ID.
- Administrative writes and previews require a session, same origin and CSRF. The separate read/render API below uses a scoped gateway key, not a console session. A matching permission name does not grant either credential access to the other interface.
- The audit records the action, actor, request ID and version, never the text, the variables or the result.
- Prompts have a comment thread, like eval items.
See delegated prompt management for the complete policy fields, defaults, UI/API, live revocation and operator-pin protection. This profile requires identical boot model/system-prompt YAML across replicas sharing control; pause delegated mutations during model-base rollout. The shared version fence protects managed model changes, not heterogeneous boot catalogs. Global admin and local/bearer rendering keep their existing contracts.
Limits
Section titled “Limits”- Templates are not a vault: do not put credentials in them.
- Bearer-key access is limited to the active key team and the currently published revision through the API below. No draft/history selector, sync with an external registry, per-prompt ACL or A/B testing.
- Up to four simultaneous previews per process.
Published prompt API and Python client
Section titled “Published prompt API and Python client”Use a server-side gateway key to fetch or render a publication. This does not call a provider, inject prompts into inference automatically or grant access to console administration. Create/edit/publish the template through the existing YAML plus console/API management workflow first. In the console, Settings & sources manages the catalog flags and Virtual keys → Custom routes selects prompts:read and/or prompts:render. API access includes complete bearer-key curl examples. Do not copy an administrator console token into an application.
features: ui: true prompt_registry: true prompt_management: true prompt_api: true # default false: GET /v1/prompts/{id} prompt_api_render: true # default false: POST /v1/prompts/{id}/renderA key’s team must be active and own the prompt; the request cannot select another team. The registry must be enabled, the template enabled and published, and its current YAML fingerprint must still match the selected publication. With feature-plan entitlements enabled, team and organization ceilings must grant prompt_registry, prompt_api and, for rendering, prompt_api_render. A flag never grants the key scope. The existing prompt_scoped_read membership right concerns console readers; it does not replace bearer-key authorization.
| Request | Required key scope | Result |
|---|---|---|
GET /v1/prompts/{id} |
prompts:read |
Current template messages, variable definitions, schema profile, immutable revision and content hash |
GET /v1/prompts/{id}?revision=3 |
prompts:read |
Same result, only if revision3 is currently published |
GET /v1/prompts/{id}?label=production |
prompts:read |
With prompt_labels: the revision that label points at, published or not; the answer adds label |
POST /v1/prompts/{id}/render |
prompts:render |
Rendered messages with exact revision and content hash |
The optional revision is a current-publication assertion, not a historical version selector (a label is the way to pin another revision). A mismatched assertion returns409 after ownership checks. The API never substitutes a draft, an older revision or another prompt. The response carries id, revision, content_hash, and messages; GET additionally returns schema_profile and either variables for flat_strings_v1 (an empty object for a constant prompt), or input_schema for json_schema_v1; typed responses omit variables. Administrative actor, team inventory and revision history are omitted.
BASE_URL='http://localhost:8080': "${GATEWAY_API_KEY:?Set a gateway key with prompts:render for the owning team}"curl --fail-with-body -sS -X POST "$BASE_URL/v1/prompts/support-response/render" \ -H "Authorization: Bearer $GATEWAY_API_KEY" \ -H 'Content-Type: application/json' \ --data-raw '{"revision":3,"variables":{"input":"Where is my order?"}}'Replace the example ID, revision and variable names with your reviewed publication. Missing/foreign/unpublished/disabled prompts and inactive owners return404, invalid credentials401, missing scope or denied plan403, current-publication conflict409, malformed input400, excessive request size413 and invalid variables/output422. Storage/capacity failure returns503; a configured request deadline remains a gateway timeout. Duplicate or unknown JSON fields and malformed/repeated revision query values are refused. Nonstring flat variables are400; typed schema/value violations are422. All outcomes use private, no-store; telemetry contains metadata/IDs, never template text, variables or rendered content.
Installing the Python client
Section titled “Installing the Python client”The versioned source package is clients/python, named m7gtw-prompts, version 0.1.0.dev0, Python3.11 or later. It has no runtime dependencies. The earlier import name, ai_gateway_prompts, still works in this release with a DeprecationWarning and is removed in the next one; the TypeScript package has no alias, so change the import to m7gtw-prompts. Setuptools80.9.0 is a pinned build tool in a separate build environment; it is not part of the gateway or the installed client runtime. Build a local wheel and install it into your application’s environment:
python3 -m venv /tmp/gateway-prompts-build/tmp/gateway-prompts-build/bin/python -m pip install setuptools==80.9.0/tmp/gateway-prompts-build/bin/python -m pip wheel --no-deps --no-build-isolation \ clients/python --wheel-dir dist/sdk# In your application's virtual environment:python -m pip install --no-index --no-deps \ dist/sdk/m7gtw_prompts-0.1.0.dev0-py3-none-any.whlThis package is distributed as a local wheel; no PyPI publication is implied. Application credentials belong in the application’s secret mechanism and are passed explicitly:
import osfrom m7gtw_prompts import PromptClient
prompts = PromptClient( base_url="https://gateway.example.com", api_key=os.environ["GATEWAY_API_KEY"],)published = prompts.get("support-response")rendered = prompts.render( "support-response", {"input": "Where is my order?"}, revision=published.revision,)messages = rendered.as_messages() # Fresh dictionaries for your application.# Explicitly pass messages to your chosen inference client if needed.The base URL is the gateway root, not /v1. Constructor controls: timeout=10.0 seconds, max_response_bytes=1048576 bytes and allow_insecure_http=False. HTTPS is required except for loopback development; other HTTP origins require that explicit opt-in. Timeout must be finite, greater than zero and at most300 seconds; the response ceiling accepts1 through16777216 bytes. The1MiB default is a conservative wire ceiling. The gateway separately enforces128KiB decoded rendered text and256KiB encoded message JSON; HTML escaping can reach the encoded ceiling before the text ceiling. Both controls are validated by the client. Each call can supply request_id and traceparent for the same end-to-end journey. The client refuses redirects and URL user info/query/fragment, ignores ambient proxy/credential settings, and performs no automatic retry or caching. It validates the response’s prompt ID, revision/hash and typed messages; PromptError, PromptProtocolError and PromptTransportError carry safe diagnostics rather than response content or credentials. Do not put provider keys in this client, and do not persist gateway keys in a browser.
The exercised runtime is Python3.14.7 on macOS/ARM64; the package declares Python3.11 or later, without claiming every minor version or OS was certified. The synchronous client supports flat_strings_v1 through get/render, and json_schema_v1 through get/the explicit render_json method. Typed GET returns a separate immutable record with input_schema; render keeps its string-only contract. No async client, provider execution, historical/draft selection or client-side template interpreter is advertised. Tests with a real gateway and PostgreSQL certify this local client boundary; deterministic loopback failures cover redirects, malformed responses and privacy without consuming provider credits.
Typed Python rendering
Section titled “Typed Python rendering”published = prompts.get("reviewed-order")rendered = prompts.render_json( "reviewed-order", {"customer": "Ana", "orders": [1, 2], "approved": True}, revision=published.revision,)The client bounds JSON trees and interoperable numbers before transport; the gateway validates the actual published schema. The client does not fetch schemas remotely, coerce data, interpret templates or perform inference. Use render for the unchanged string profile and render_json explicitly for structured values; old client versions fail closed on the unknown typed profile.
TypeScript and Go clients
Section titled “TypeScript and Go clients”The same published-prompt contract has two more dependency-free, server-side clients (T168), with the Python client’s checks: HTTPS except loopback or an explicit opt-in, no redirects, no ambient proxy or credential discovery, no retry or cache, bounded responses, strict response validation (exact fields, no duplicate keys, prompt ID, revision and hash, safe text) and errors that carry only the status, a known gateway code and a safe request ID, never the response body, the key or a private URL. Both are local source packages; nothing is published to a registry.
TypeScript (clients/typescript, package m7gtw-prompts 0.1.0-dev.0, "private": true, ES module, Node 22.18 or later, global fetch; no runtime dependencies). Build it with TypeScript 5.9.3 (npm install && npm run build in the directory, or the console’s pinned compiler ../../web/node_modules/.bin/tsc -p tsconfig.json) and install the result from a local tarball (npm pack, then npm install ./m7gtw-prompts-0.1.0-dev.0.tgz in your application):
import { PromptClient, PromptError } from "m7gtw-prompts";
const prompts = new PromptClient("https://gateway.example.com", process.env.GATEWAY_API_KEY!);const published = await prompts.get("support-response");const rendered = await prompts.render("support-response", { input: "Where is my order?" }, { revision: published.revision });const messages = rendered.asMessages(); // fresh objects for your inference client// Typed publications: prompts.renderJson("reviewed-order", { customer: "Ana", orders: [1, 2] })Options: timeoutMs (default 10000, at most 300000), maxResponseBytes (default 1048576, 1–16777216) and allowInsecureHttp (default false); per call revision, requestId and traceparent. Results are frozen objects with id, revision, contentHash and messages; get adds schemaProfile and either variables (flat_strings_v1) or inputSchema (json_schema_v1). Errors: PromptError (status, code, requestId), PromptProtocolError and PromptTransportError, none with a cause.
Go (clients/go, module github.com/m7gtw/gateway/clients/go, package prompts, Go 1.26 or later, standard library only). Use it from this repository with a replace directive pointing at the directory:
client, err := prompts.New("https://gateway.example.com", os.Getenv("GATEWAY_API_KEY"))published, err := client.Get(ctx, "support-response", prompts.RequestOptions{})rendered, err := client.Render(ctx, "support-response", map[string]string{"input": "Where is my order?"}, prompts.RequestOptions{Revision: published.Revision})messages := rendered.AsMessages()// Typed publications: client.RenderJSON(ctx, "reviewed-order", map[string]any{"customer": "Ana"}, prompts.RequestOptions{})Options: prompts.WithTimeout (default 10 s, at most 300 s), prompts.WithMaxResponseBytes (default 1 MiB, 1–16777216) and prompts.WithInsecureHTTP(); RequestOptions carries Revision, RequestID and Traceparent. Get returns a *Published with SchemaProfile and Variables or InputSchema; Render and RenderJSON return a *Rendered. Errors: *prompts.Error (Status, Code, RequestID), prompts.ErrProtocol and prompts.ErrTransport, never wrapping the cause. The client value prints without its key.
Tests. Loopback tests of each client run in every gate (node --test clients/typescript/test/*.test.mjs, go test ./... in clients/go). The real-gateway certification (scripts/verify-prompt-sdk.sh, full and release gates) starts the built gateway with an owned PostgreSQL and runs the Python checks, then the same published, typed, denial (401, 403, 404, 409, 422), escaped-boundary and request/trace correlation checks through the TypeScript and Go clients against that gateway; no provider is called.
Prompt revision on traffic
Section titled “Prompt revision on traffic”Know which prompt revision produced each answer, and compare revisions on live traffic: volume, errors, latency, tokens, cost and the pass rate of every evaluator, side by side. Turn it on, then make your inference requests name the revision they were built from.
features: ui: true prompt_registry: true prompt_management: true prompt_api: true prompt_api_render: true prompt_tracking: true # default falseprompt_tracking: render_token_ttl: 1h # default 1h, from 1m to 24h declared_headers: true # default trueThe flag is read on every request (no restart); the prompt_tracking block is read at startup. It needs PostgreSQL schema migration 275. With feature plans on, the team’s plan must include prompt_tracking.
Name the revision on the request
Section titled “Name the revision on the request”The recommended path is the render token: render the published revision through the published prompt API, send its messages to the model, and send back the header the render answered.
curl -sS -D headers.txt -X POST "$BASE_URL/v1/prompts/support-response/render" \ -H "Authorization: Bearer $GATEWAY_API_KEY" -H 'Content-Type: application/json' \ --data-raw '{"variables":{"input":"Where is my order?"}}' > rendered.jsonTOKEN=$(grep -i '^x-gateway-prompt-render:' headers.txt | cut -d' ' -f2 | tr -d '\r')curl -sS "$BASE_URL/v1/chat/completions" \ -H "Authorization: Bearer $GATEWAY_API_KEY" -H 'Content-Type: application/json' \ -H "X-Gateway-Prompt-Render: $TOKEN" \ --data-raw "{\"model\":\"chat-default\",\"messages\":$(jq -c .messages rendered.json)}"| Header | On | What it does |
|---|---|---|
X-Gateway-Prompt-Render |
render answer, inference request | The render token: signed by the gateway for the key’s team, the prompt and the revision it rendered, valid for render_token_ttl. The request records the revision as rendered (observed by the gateway). The render body’s fields do not change, so existing clients keep working |
X-Gateway-Prompt-Render-Expires |
render answer | When the token stops being accepted |
X-Gateway-Prompt-Id, X-Gateway-Prompt-Revision |
inference request | The client’s own claim, recorded as declared, for prompts the client renders itself; the revision (1–100) is optional. Read while declared_headers is true |
A request without either keeps the required system prompt the gateway applied, recorded as system. When a request names a prompt and a system prompt was also applied, the named one takes the fields and the span keeps the system prompt as system_prompt_id and system_prompt_revision.
The revision is attribution: it never makes the gateway refuse the model call. When it cannot use what the request sent, the request is answered as usual, records no prompt revision from it (a declaration sent beside an unusable token is still recorded as declared), and the answer carries X-Gateway-Prompt-Tracking with the reason (also logged as prompt_tracking_ignored):
X-Gateway-Prompt-Tracking |
Why |
|---|---|
expired |
The token is past render_token_ttl: render the prompt again |
invalid_signature, malformed |
The token is not one this gateway signed (forged, cut, or signed with a session key the gateway no longer has) |
other_team |
The token was issued to another team’s key |
not_entitled |
The team’s plan does not include prompt_tracking |
entitlement_unavailable |
The plan could not be read |
Only a request that is malformed or contradicts itself is refused, with 400 invalid_prompt_declaration before the model is called: an X-Gateway-Prompt-Id that is not a prompt ID or is repeated, an X-Gateway-Prompt-Revision outside 1–100, or a declaration that names another prompt or revision than the token it comes with (two tokens: 400 invalid_prompt_render). With the flag off the headers are ignored and the render answers no token. A declaration is never authorization: it is kept only on the rows of the key’s own team, so it never reaches another team’s prompt page.
The token is signed with a key derived from the console session key (admin.session_key_env, and its keyring with session_key_rotation), so every replica with the same session key accepts the tokens of the others and a restart keeps them valid. Without a session key no token is issued (the render answers X-Gateway-Prompt-Tracking: no_session_key); declared headers still work.
With prompt_tracking on, saving a definition identical to the current draft creates no revision (the answer keeps the version): revisions stay the versions that differ, so the traffic of one text is not split across revisions. Any change, re-asserting an older text included, is a new revision.
What is recorded
Section titled “What is recorded”The request log row gets prompt_id, prompt_revision and prompt_source (rendered, declared, system); the request span gets the same as the attributes prompt_id, prompt_revision and prompt_source, on both span engines, and the analytics store copy of the request log carries the three columns. Never the text, the variables or the answer. Rows written before or with the flag off carry none.
The prompt page
Section titled “The prompt page”Prompt registry → a prompt → Traffic by revision, for a reader who may read the prompt and has analytics:read:
- one card per revision for the last 24 hours, 7 or 30 days: requests, errors and error rate, p50 and p95 latency, input and output tokens per request, the known cost with the unpriced requests apart (with
usage_valuation), how many requests were rendered, declared or used it as the system prompt, and the pass rate (or mean score) of every evaluator over that revision’s requests (withevaluation_resultsandevals:read); - View requests opens the trace explorer over that revision’s request spans (
prompt.id:<id> prompt.revision:<n> span.kind:request); View all linked requests over every revision; - Run experiment opens Evals with a new experiment of that revision (
prompt_revision, published or not), the prompt’s team dataset first; - Compare revisions puts two revisions side by side: requests, p95 latency, tokens per request, the pass rate of each evaluator with the change, and the template diff;
- Experiments with this prompt lists the team’s runs of it.
The list shows requests in 7 days for each prompt. A request span with a prompt revision shows a Prompt chip in the trace view that opens the prompt at that revision, saying whether it was rendered, declared or the system prompt.
Everything reads the prompt’s own team, in the organization the team is in now; another organization’s traffic is never counted, even when it declared the same prompt ID.
Query and analytics
Section titled “Query and analytics”- Query fields
prompt.id,prompt.revisionandprompt.sourcein the request log and the spans scopes of the query language:prompt.id:support-response prompt.revision:2. - Analytics dimensions
prompt_id,prompt_revisionandprompt_sourceinGET /analytics/query(also as dimensions of the judged request over evaluation results). With results stored in the analytics store, these dimensions are read from its copy of the request log, as every usage dimension of evaluation results is.
Evaluators read the prompt’s variables
Section titled “Evaluators read the prompt’s variables”An evaluator’s prompt may read {{prompt.query}}, {{prompt.context}}, {{prompt.variables.<name>}}, {{prompt.id}}, {{prompt.revision}} and {{prompt.source}}. The variables are read back from the request’s captured content through the revision’s template, so mark the roles once in the prompt with variable_roles and any hallucination or grounding check reads the right text. See evaluator variables.
Upgrade
Section titled “Upgrade”Migration 275 adds three nullable columns to gateway_usage_events (no table rewrite) and the table gateway_prompt_yaml_seen. Upgrade every replica before turning the flag on: a replica of before ignores the headers and records nothing. An older binary refuses a prompt saved with variable_roles; remove the roles before downgrading. {{prompt.…}} in an evaluator is now a path over the prompt revision, refused when saved with the flag off: an evaluator of before that held such text literally reads an empty value and must be edited.
Once the flag is on, the gateway builds two partial indexes on the request log for the traffic reads (gateway_usage_events_prompt_idx and gateway_usage_events_prompt_time_idx, only over requests that recorded a prompt), CONCURRENTLY so writes go on, one replica at a time; the build runs apart from the prompt events, and a failed one is logged as prompt_index_failed and tried again after a wait that doubles from one minute up to an hour. At 2 million requests they take one prompt’s figures from about 120 ms to about 2 ms (measured). The analytics store needs no index for these reads. Each read still stops at 5 seconds (422 query_too_costly on the page; the list then shows no count).
Prompt events
Section titled “Prompt events”Get a message when a prompt changes, whoever changed it and however.
features: prompt_events: true # default false alert_channels: truealerting: channels: - id: prompt-changes name: Prompt changes kind: slack url_env: PROMPT_SLACK_WEBHOOK_URL events: [prompt_created, prompt_version_published, prompt_deleted]| Event | When |
|---|---|
prompt_created |
A console prompt was created (an ID with no prompt, or only a deleted one), through the console, the admin API or a team-delegated write; or a prompt ID appeared in the YAML file |
prompt_version_published |
A revision was published that was not already the publication (publishing a YAML prompt included) |
prompt_deleted |
A console prompt was deleted |
prompt_label_deployed |
With prompt_labels: Deploy to moved a label to a revision (the detail adds label; previous_revision is empty for a new label) |
Each event is written in the same transaction as the change, so a change that fails reports nothing and one that commits reports once. Every write of the registry goes through it: the console, the admin API (path: api) and team-delegated writes, and a prompt added to the YAML file (path: yaml, reported once across replicas and restarts). The published prompt clients (Python, TypeScript, Go) only read and render; a client or script that creates prompts calls the admin API and is reported like any other call. The first run with the flag on takes the inventory of the YAML prompts without reporting them, so turning it on does not announce every prompt you already had.
Not reported: reverting a prompt to its YAML definition (it withdraws the publication: the revert is in the audit log), a publication withdrawn because the YAML definition changed, a prompt removed from the YAML file, and a YAML prompt ID that was removed and added again (an ID is reported the first time it is seen).
The detail holds prompt_id, team, organization, revision, previous_revision, name, path, actor and request_id (and label for a label move); never the text. Channels that subscribe receive every prompt event: give them to the operators. For a team or an organization, an alert rule of the prompts signal matches only its own prompts and delivers to the channels open to it. Each event is also a prompt_event log line (stdout and OTLP) with the identity fields.
Labels and Deploy to
Section titled “Labels and Deploy to”With prompt_labels, a prompt carries labels: names such as production, staging or canary-eu, each pointing at one stored revision of the prompt, published or not. An application reads or renders the prompt by label, so moving a label changes what it gets without a new deployment, and each environment can run its own revision.
- Labels (the prompt page’s Labels panel,
GET /api/v1/admin/prompts/{id}/labels): each label with its revision, when and by whom it was last moved; the revision history shows the labels as pills. - Deploy to (
PUT /api/v1/admin/prompts/{id}/labels/{label}): moves a label to a revision ({"revision": 3}) or to the revision another label points at ({"from_label": "staging"}, promoting staging to production), or creates it.expected_revision(0 for a new label) orexpected_versionrefuses a move made meanwhile; deploying a label where it already is changes nothing. A disabled revision, or one made on another YAML base, is refused. Remove (DELETE) drops a label: requests rendering by it then get 404. A label name is 1–32 lowercase letters, digits,-or_, starting with a letter; a prompt has at most 20. - Deleting or reverting the prompt removes its labels; a prompt live through labels counts as published there, so a team member needs the publish right to delete it.
- Who: reading the labels needs the prompt read right. Moving one is a publication: a global administrator, or a team member with
prompt_scoped_writewhose current delegation lets the team publish the prompt (prompts:publish). Under plan entitlements, the team’s plan must includeprompt_labels. Labels belong to the prompt’s team: another team or organization neither reads, moves nor renders them. - Audit and events: every move (
prompt_label.deploy, with the previous revision) and removal (prompt_label.remove) is in the audit log; a move is also theprompt_label_deployedevent, for alert channels and the prompts signal of alert rules. - Using a label:
GET /v1/prompts/{id}?label=productionandPOST /v1/prompts/{id}/renderwith"label": "production"(the Python, TypeScript and Go clients takelabel=/{label}/Label). The answer names the label. With prompt tracking, the render token carries it too: the request built from it recordsprompt_labelbeside the revision, on the request log row and the request span (query fieldprompt.label, analytics dimensionprompt_label).
curl -sS -X PUT "$GATEWAY/api/v1/admin/prompts/support/labels/production" \ -H "Cookie: $SESSION" -H "X-CSRF-Token: $CSRF" -H 'Content-Type: application/json' \ --data-raw '{"from_label":"staging","expected_revision":2}'curl -sS -X POST "$GATEWAY/v1/prompts/support/render" -H "Authorization: Bearer $KEY" \ -H 'Content-Type: application/json' \ --data-raw '{"label":"production","variables":{"question":"Where is my order?"}}'Improve
Section titled “Improve”With prompt_improve, the prompt page gains an Improve panel: a suggestion for the current draft’s messages, generated by a model, that you review before anything is saved.
- Choose the team’s alias. There is no default: the prompt’s team uses the chat alias it chose for Improve, and a team without one has no suggestions. A global administrator or an administrator of the team picks an enabled chat alias (Improve alias of the team, or
PUT /api/v1/admin/prompt-improve/{team}); the choice is written to the audit log (prompt_improve.set,prompt_improve.delete). - Ask for a suggestion. Optionally say what to improve, then Suggest an improvement of draft N. The gateway sends the draft’s messages and declared variables to the team’s alias, as a call of that team: its policy, budget and model rules apply, and the call is recorded like any helper call (origin
helper, kindprompt_improve, the console request as its parent) and priced from the price book. - Review the diff. The suggestion is shown as a line diff against the draft, with the model’s reason. It is used only when it keeps the same number of messages with the same roles, uses every declared variable and adds none; otherwise the panel says why and shows nothing.
- Accept as new draft saves it through the ordinary save, as a new draft revision. It is never published by itself: publication stays the separate Publish action. Discard drops it.
Improving needs prompts:manage and the right to save the prompt (a global administrator, or a team member with prompt_scoped_write and a delegation that lets the team write). Under plan entitlements, the team’s plan must include prompt_improve. The prompt’s text goes to the provider behind the alias the team chose, as any request of the team would.
Admin API routes
Section titled “Admin API routes”Every route below needs a console session or an admin Bearer token, the role’s permission and, for writes, the X-CSRF-Token header; the full contract is in the API reference.
| Route | What it does |
|---|---|
POST /api/v1/admin/prompts/{id}/publish |
Publishes an existing revision as the current one; content history never changes |
POST /api/v1/admin/prompts/{id}/render |
Previews the published revision with variables, without calling a provider |
GET /api/v1/admin/prompts/{id}/versions |
Lists a prompt’s revisions |
GET /api/v1/admin/prompts/{id}/versions/{revision} |
Reads the body of one earlier revision |
DELETE /api/v1/admin/prompts/{id} |
Restores the YAML prompt as a new unpublished revision, or keeps a tombstone of a console-only prompt |
GET /api/v1/admin/prompts/{id}/metrics |
The traffic by revision over from/to (at most 90 days); prompt_tracking, usage_analytics, a reader of the prompt with analytics:read |
GET /api/v1/admin/prompt-tracking |
The effective prompt_tracking block with each value’s source, the headers and the events; config:read |
POST /api/v1/admin/prompts/{id}/versions/{revision}/render |
Renders any revision the session may read, published or not, for the Playground’s prompt variants; playground_prompt_variants, prompts:read; nothing stored |
GET /api/v1/admin/prompts/{id}/requests/{request_id}/variables |
A request’s revision and the variables read back from its captured content (reopen a request); playground_prompt_variants, prompt_tracking, content_sent:read of the request’s team; audited |
POST /api/v1/admin/prompts/{id}/versions/{revision}/improve |
A suggestion for the revision’s messages through the team’s Improve alias (Improve); prompt_improve, prompts:manage; nothing saved |
GET /api/v1/admin/prompt-improve |
The Improve alias of each team the session reads, and the teams it may choose for; prompts:read |
PUT /api/v1/admin/prompt-improve/{team} |
Chooses a team’s Improve alias (an enabled chat alias); a global administrator or an administrator of the team; audited |
DELETE /api/v1/admin/prompt-improve/{team} |
Removes a team’s choice, and with it Improve for that team; audited |
GET /api/v1/admin/prompts/{id}/labels |
The prompt’s labels and whether the session may move them; prompt_labels, prompts:read |
PUT /api/v1/admin/prompts/{id}/labels/{label} |
Deploy to: move or create a label (revision or from_label, optional expected_revision); the right to publish the prompt; audited, prompt_label_deployed |
DELETE /api/v1/admin/prompts/{id}/labels/{label} |
Remove a label; the right to publish the prompt; audited |
See also
Section titled “See also”- Evals: experiments with a published revision, or any stored revision with
prompt_tracking. - Playground.
- Plans.
Prompt schema and private content
Section titled “Prompt schema and private content”The default prompt profile is flat_strings_v1; optional json_schema_v1 requires its default-off flag. shared parameter definitions supply the same required choice to validation and the existing editor. A new-draft preset is separate from a backend default. Templates, messages and variable definitions remain private typed content, outside global configuration and the safe parameter catalog. Metadata names use their existing UTF-8 byte bounds; variable value lengths use Unicode code points. Publication, rendering, team scope and plan checks remain separate from schema membership.