Prompts SDK
Manage prompts programmatically with full type safety.
List Prompts
const result = await client . prompt . listPrompts ({
limit: 20 ,
offset: 0 ,
isLatest: true ,
});
for await ( const page of result ) {
const { data , total , hasNext } = page . result ;
data . forEach ( p => console . log ( p . name , 'v' + p . version ));
}
You can filter by name, version, isLatest, or createdBy:
const result = await client . prompt . listPrompts ({
name: 'support' ,
isLatest: true ,
createdBy: 'user@example.com' ,
});
Create Prompt
MutagenT supports three prompt formats. Use humanPrompt for template-based prompts, systemPrompt + humanPrompt for structured prompts, or rawPrompt for plain text.
Structured (System + Human)
Human Prompt Only
Raw Prompt
const prompt = await client . prompt . createPrompt ({
name: 'Support Assistant' ,
systemPrompt: 'You are a helpful support agent for {company}.' ,
humanPrompt: 'The customer asks: {question}' ,
description: 'Customer support prompt' ,
inputSchema: {
type: 'object' ,
properties: {
company: { type: 'string' },
question: { type: 'string' },
},
},
tags: [ 'production' , 'support' ],
});
console . log ( 'Created:' , prompt . id , 'v' + prompt . version );
Template variables use single braces: {variable}. Define matching keys in inputSchema for validation.
Get Prompt by ID
const prompt = await client . prompt . getPrompt ({ id: 123 });
console . log ( prompt . name , 'v' + prompt . version );
console . log ( 'System:' , prompt . systemPrompt );
console . log ( 'Human:' , prompt . humanPrompt );
console . log ( 'Latest:' , prompt . isLatest );
Update Prompt
const updated = await client . prompt . updatePrompt ({
id: 123 ,
body: {
description: 'Updated description' ,
humanPrompt: 'Revised prompt for {company}.' ,
isLatest: true ,
tags: [ 'production' , 'v2' ],
},
});
The body object accepts all optional fields:
Field Type Description descriptionstringUpdated description isLatestbooleanMark as latest version systemPromptstringUpdated system prompt humanPromptstringUpdated human prompt template rawPromptstringUpdated raw prompt outputSchemaobjectUpdated output schema metadataobjectUpdated metadata tagsstring[]Updated tags
Delete Prompt
const result = await client . prompt . deletePrompt ({ id: 123 });
Create New Version
Create a new version of an existing prompt with optional changes to its content:
const newVersion = await client . prompt . createPromptVersion ({
id: 123 ,
body: {
newVersion: '2.0.0' ,
changes: {
humanPrompt: 'Improved prompt for {company}: {question}' ,
isLatest: true ,
},
},
});
console . log ( 'New version:' , newVersion . version );
List Prompt’s Datasets
const datasets = await client . promptDatasets . listDatasetsForPrompt ({
id: 123 ,
});
datasets . forEach ( d => console . log ( d . name , d . promptGroupId ));
Prompt Lifecycle
Type Definitions
interface Prompt {
id : number ;
name : string ;
description : string | null ;
version : string ;
isLatest : boolean ;
systemPrompt : string | null ;
humanPrompt : string | null ;
rawPrompt : string | null ;
inputSchema : any ;
outputSchema : any ;
metadata : any ;
createdAt : string | null ;
updatedAt : string | null ;
createdBy : string | null ;
tags : string [] | null ;
}
Method Reference
Method Description Returns listPrompts(request?)List all prompts (paginated) PageIterator<ListPromptsResponse>createPrompt(body)Create a new prompt PromptgetPrompt({ id })Get prompt by ID PromptupdatePrompt({ id, body })Update prompt fields PromptdeletePrompt({ id })Delete prompt PromptSuccessResponsecreatePromptVersion({ id, body })Create new version Prompt