Prompt Management
Deploy and iterate prompts through the AI Gateway without code changes
CoreValue's AI Gateway integrates directly with our prompt management system without the need for custom packages or code changes.
This guide shows you how to integrate the AI Gateway with prompt management, not the actual prompt management itself. For creating and managing prompts, see Prompt Management.
Why Use Prompt Integration?
Instead of hardcoding prompts in your application, reference them by ID:
// ❌ Prompt hardcoded in your app
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{
role: "system",
content: "You are a helpful customer support agent for TechCorp. Be friendly and solution-oriented."
},
{
role: "user",
content: `Customer ${customerName} is asking about ${issueType}`
}
]
});// ✅ Prompt managed in CoreValue dashboard
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
prompt_id: "customer_support",
inputs: {
customer_name: customerName,
issue_type: issueType
}
});
// The prompt template lives in CoreValue, not your codeGateway vs SDK Integration
Without the AI Gateway, using managed prompts requires multiple steps:
// 1. Install package
npm install @cova/gateway
// 2. Initialize prompt manager
const promptManager = new CovaPromptManager({
apiKey: process.env.COVA_API_KEY
});
// 3. Fetch and compile prompt (separate API call)
const { body, errors } = await promptManager.getPromptBody({
prompt_id: "abc123",
inputs: { customer_name: "John", ... }
});
// 4. Handle errors manually
if (errors.length > 0) {
console.warn("Validation errors:", errors);
}
// 5. Finally make the LLM call
const response = await openai.chat.completions.create(body);// Just reference the prompt - gateway handles everything
const response = await client.chat.completions.create({
prompt_id: "abc123",
inputs: { customer_name: "John", ... }
});Why the gateway is better:
- No extra packages - Works with your existing OpenAI SDK
- Single API call - Gateway fetches and compiles automatically
- Lower latency - Everything happens server-side in one request
- Automatic error handling - Invalid inputs return clear error messages
- Cleaner code - No prompt management logic in your application
Integration Steps
Build and test prompts with variables in the dashboard
Replace messages with prompt_id and inputs in your gateway calls
API Parameters
Use these parameters in your chat completions request to integrate with saved prompts:
stringrequiredThe ID of your saved prompt from the CoreValue dashboard. Can also be set via the Cova-Prompt-Id request header — when both are present, body.prompt_id overrides the header.
stringWhich environment version to use: development, staging, or production
objectrequiredVariables to fill in your prompt template (e.g., {"customer_name": "John", "issue_type": "billing"})
stringrequiredAny supported model - works with the unified gateway format
Cova-Prompt-Id Header
You can also pass the prompt ID as a request header instead of (or in addition to) the body field:
Cova-Prompt-Id: customer_support_v2Prompt expansion is performed server-side via the Core API (M2 milestone 0.6). When body.prompt_id and the Cova-Prompt-Id header are both present, the body field takes precedence and overrides the header.
Example Usage
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
prompt_id: "customer_support_v2",
environment: "production",
inputs: {
customer_name: "Sarah Johnson",
issue_type: "billing",
customer_message: "I was charged twice this month"
}
});