Prompt
I'm building a multi-model app and need prompts tracked by environment
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
A good pattern is to keep prompt versions per environment and resolve them at runtime from a single source of truth.
Recommended setup
Store prompts in a table/collection like:
prompt_key— stable identifier, e.g.summarize_ticketenvironment—dev,staging,prodversion— integer or semvertemplate— the actual prompt textactive— booleanmodel— optional, if prompts differ by modelcreated_at,updated_at
Example:
| prompt_key | environment | version | model | active | template |
|---|---|---|---|---|---|
| summarize_ticket | dev | 3 | gpt-4.1 | true | ... |
| summarize_ticket | prod | 2 | gpt-4.1 | true | ... |
Runtime resolution
At request time:
- Read current app env (
dev/staging/prod) - Load the active prompt for:
prompt_key- current
environment - optionally
model
- Fall back in a controlled order if not found:
- exact env + model
- exact env
- default/global prompt
Why this helps
- Safe testing: dev can iterate without touching prod
- Version control: roll back a prompt quickly
- Model-specific tuning: different prompt for different LLMs
- Auditability: you know what prompt was used for each output
Good implementation options
- Database-backed prompt registry for dynamic updates
- Git-backed prompt files for review/PR workflow
- Hybrid: prompts in Git, synced into DB for runtime use
Example prompt structure
{
"prompt_key": "summarize_ticket",
"environment": "prod",
"version": 4,
"model": "gpt-4.1",
"template": "You are a support assistant. Summarize the ticket in 3 bullet points..."
}
Best practices
- Include a prompt hash in logs for traceability
- Store the resolved prompt version with each model invocation
- Use feature flags if you need gradual rollout
- Separate system, developer, and user prompt layers
- Validate templates before activating them
If you want, I can give you:
- a Postgres schema,
- a Python/TypeScript resolver, or
- a full env-based prompt management design.