Prompt Management
Prompt Management lets you store reusable system prompts and apply them to chat requests by sending a prompt ID in a request header. It is designed for teams that want consistent behavior across apps without repeating long system instructions in every request.
One stored prompt becomes your single source of truth-update it once, apply everywhere, and disable it instantly if needed.
Quick Start
Include the X-Prompt-Id header in your chat completion request:
curl https://api.llmapi.ai/v1/chat/completions \
-H "Authorization: Bearer your_api_key" \
-H "X-Prompt-Id: your_prompt_id" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello"}
]
}'
When validated, your stored prompt is injected as the first system message, followed by your original request messages.
How It Works
When you send a request with X-Prompt-Id:
- Lookup - LLM API retrieves the prompt by ID from cache or database
- Validate - LLM API confirms the prompt exists, belongs to your project, and is enabled
- Inject - The stored prompt text is prepended as the first system message
- Route - The full message list continues through normal model and provider routing
- Respond - The model processes the injected prompt plus your original messages
INFO
Existing client-provided system messages are preserved and appear after the injected prompt.
Errors and Validation
| Condition |
Status |
Code |
| Prompt ID does not exist |
400 |
prompt_not_found |
| Prompt belongs to another project |
403 |
prompt_project_mismatch |
| Prompt is disabled |
400 |
prompt_disabled |
WARNING
Prompt data is project-scoped. Cross-project prompt usage is blocked even if someone knows a
prompt ID.
Best Practices
- One prompt per task family - Create separate prompts for support, coding, extraction, etc. rather than storing multiple unrelated instructions in one prompt.
- Use clear, version-like titles - Name prompts descriptively (e.g., "Support Agent v2", "Code Reviewer v1") to make history and intent clear.
- Roll out with enable/disable toggles - Disable a prompt instantly if needed instead of deleting it. This lets you revert safely without code changes.
- Keep prompt text concise - Shorter prompts are faster to inject and easier to update. Test for regressions after any text changes.
Limitations and Scope
- Endpoint support - Prompt injection is currently available for chat completions.
- Injection mode - Prompts are always injected as the first system message.
- Cache lookup - Lookups use Redis read-through cache with database fallback for high performance.
- Cache invalidation - Update or delete operations automatically invalidate the prompt cache.