Creating prompts
Create text or chat prompts with typed variables and metadata.
Use nirmos.prompts.create to create a logical prompt and its initial version.
Text prompt
const prompt = await nirmos.prompts.create({
name: "Product summary",
slug: "product-summary",
description: "Produces a short customer-facing product summary.",
content: {
type: "text",
role: "system",
text: "Summarize {{productName}} for a {{audience}} audience in {{maxWords}} words.",
},
variables: [
{
name: "productName",
type: "string",
required: true,
description: "Public product name",
},
{
name: "audience",
type: "enum",
required: true,
values: ["technical", "executive", "general"],
},
{
name: "maxWords",
type: "number",
required: false,
default: 80,
min: 20,
max: 200,
},
],
tags: ["marketing", "production"],
folder: "content/product",
metadata: {
owner: "growth-platform",
risk: "low",
},
commitMessage: "Create initial product summary prompt",
activate: true,
});If slug is omitted, Nirmos can derive one from the name. Set it explicitly when application code will reference the slug.
Chat prompt
const prompt = await nirmos.prompts.create({
name: "Support triage",
slug: "support-triage",
content: {
type: "chat",
messages: [
{
role: "system",
content: "Classify support tickets for {{company}}.",
},
{
role: "developer",
content: "Allowed categories: {{categories}}",
},
],
},
variables: [
{ name: "company", type: "string", required: true },
{
name: "categories",
type: "array",
itemType: "string",
required: true,
},
],
activate: true,
});Array and object values render as JSON. Strings render without added quotes.
Variable names
Use names that start with a letter and contain letters, numbers, _, ., or -:
{{customerName}}
{{order.id}}
{{policy-version}}Declare every production placeholder as a variable. The SDK reports missing required values and unresolved placeholders before sending a model request.
Request options
All mutations accept request options as the final argument:
await nirmos.prompts.create(params, {
timeoutMs: 20_000,
idempotencyKey: crypto.randomUUID(),
});Use an idempotency key when your API environment supports mutation idempotency and your application may retry after an uncertain network failure.