Prompt templates are reusable, version-controlled prompts that let you define instructions once and apply them consistently across multiple API calls with dynamic variable substitution.
Consistency: Ensure the same instructions are used across your application without copy-pasting prompts.
Version Control: Track changes to prompts over time and roll back if needed.
Dynamic Content: Inject variables like user names, dates, or context into standardized prompts.
Team Collaboration: Share and manage prompts across team members.
A/B Testing: Test different prompt versions to optimize model performance.
- Create a template with placeholder variables (e.g.,
{{user_name}},{{task}}) - Save and version the template in your Freddy Hub
- Reference the template by ID in your API calls
- Pass variables to substitute into the placeholders
- Model receives the complete prompt with variables filled in
- Go to Freddy Hub
- Click "Create Prompt Template"
- Define your prompt with variables:
You are an expert {{role}}.
Help the user with: {{task}}
User context:
- Name: {{user_name}}
- Experience level: {{experience_level}}
Provide a {{tone}} response with {{detail_level}} detail.- Save the template - you'll receive a template ID like
prompt_abc123
Variables use double curly braces: {{variable_name}}
Supported variable types:
- Strings: Text values
- Numbers: Numeric values
- Images: File IDs or URLs
- Files: Document file IDs
- Arrays: Lists of values
curl https://api.freddy.aitronos.com/v1/model/response \
-H "Authorization: Bearer $FREDDY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1",
"prompt": {
"id": "prompt_abc123",
"variables": {
"role": "Python developer",
"task": "debugging code",
"user_name": "Alice",
"experience_level": "intermediate",
"tone": "friendly",
"detail_level": "comprehensive"
}
},
"inputs": [
{
"role": "user",
"texts": [{"text": "My code keeps throwing a TypeError"}]
}
]
}'import requests
response = requests.post(
"https://api.freddy.aitronos.com/v1/model/response",
headers={"Authorization": f"Bearer {api_key}"},
json={
"model": "gpt-4.1",
"prompt": {
"id": "prompt_abc123",
"version": "v2.1", # Use specific version
"variables": {
"customer_name": "John Doe",
"issue_type": "billing"
}
},
"inputs": [
{"role": "user", "texts": [{"text": "I was charged twice"}]}
]
}
)// Customer support example
const createSupportResponse = async (customerId, issueDescription) => {
// Fetch customer data
const customer = await getCustomer(customerId);
const response = await fetch('https://api.freddy.aitronos.com/v1/model/response', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4.1',
prompt: {
id: 'prompt_support_agent',
variables: {
customer_name: customer.name,
account_type: customer.tier,
issue_category: classifyIssue(issueDescription),
response_urgency: customer.tier === 'premium' ? 'high' : 'standard'
}
},
inputs: [
{
role: 'user',
texts: [{ text: issueDescription }]
}
]
})
});
return await response.json();
};- Experiment safely: Test new prompts without affecting production
- Rollback capability: Revert to previous versions if needed
- Track performance: Compare results across prompt iterations
- Gradual rollout: Deploy new prompts to subset of users first
v1.0 - Initial production version
v1.1 - Minor improvements
v2.0 - Major prompt restructure
latest - Always points to newest version (default){
"prompt": {
"id": "prompt_abc123",
"version": "v1.0" // Pin to specific version
}
}Omit version to always use the latest:
{
"prompt": {
"id": "prompt_abc123"
// No version = uses latest
}
}{
"prompt": {
"id": "prompt_multilang_support",
"variables": {
"language": "Spanish",
"user_query": "¿Cómo funciona esto?"
}
}
}Template content:
Respond in {{language}}.
User asks: {{user_query}}{
"prompt": {
"id": "prompt_image_analyzer",
"variables": {
"analysis_focus": "safety concerns",
"detail_level": "comprehensive",
"target_image": "file_img123"
}
},
"inputs": [
{
"role": "user",
"texts": [{"text": "Analyze this image"}],
"images": [{"fileId": "file_img123"}]
}
]
}{
"prompt": {
"id": "prompt_code_reviewer",
"variables": {
"language": "Python",
"review_focus": ["performance", "security", "best practices"],
"experience_level": "senior"
}
}
}- Use descriptive variable names:
{{customer_name}}not{{name}} - Version major changes: Increment version for significant prompt rewrites
- Test templates: Validate with sample data before production use
- Document templates: Add descriptions explaining purpose and variables
- Set defaults: Provide fallback values for optional variables
- Pin versions in production: Use specific versions for critical workflows
- Hardcode sensitive data: Never put API keys or secrets in templates
- Over-complicate: Keep templates focused and maintainable
- Ignore versioning: Always version templates for production use
- Mix concerns: One template should have one clear purpose
- Skip validation: Always test variable substitution
curl https://api.freddy.aitronos.com/v1/prompts \
-H "Authorization: Bearer $FREDDY_API_KEY"Templates are immutable once created. To update:
- Create a new version in Freddy Hub
- Test the new version
- Update your code to use the new version
- Deprecate old versions
curl https://api.freddy.aitronos.com/v1/prompts/prompt_abc123 \
-X DELETE \
-H "Authorization: Bearer $FREDDY_API_KEY"Note: Deleting a template affects all code using it. Prefer deprecation over deletion.
- Standardized workflows (customer support, code review)
- Team-shared prompts
- A/B testing different prompts
- Version-controlled instructions
- One-off requests
- Highly dynamic, unique prompts
- Rapid prototyping
- User-generated prompts
You can also combine both:
{
"model": "gpt-4.1",
"prompt": {
"id": "prompt_base_instructions",
"variables": {"expertise": "medical"}
},
"inputs": [
{
"role": "user",
"texts": [{"text": "What causes headaches?"}]
}
]
}The template provides base instructions, while inputs add the specific user query.
If a template requires variables you don't provide:
{
"error": {
"type": "invalid_request_error",
"message": "Missing required template variable: 'user_name'",
"code": "missing_template_variable",
"param": "prompt.variables.user_name"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Prompt template not found",
"code": "template_not_found",
"param": "prompt.id"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Prompt template version 'v99.0' not found",
"code": "template_version_not_found",
"param": "prompt.version"
}
}Related: