Use managed prompts with Gateway
Retrieve and render prompt instructions before a model request.
Use a released prompt and a server key with prompt:read and gateway:execute. The prompt must define the variables passed by your application.
await nirmos.gateway.chat.create({
route: "production-chat",
prompt: { id: "support-reply", version: "active", variables: { customerName: "Asha" } },
messages: [{ role: "user", content: "Explain the refund policy." }],
});The SDK retrieves and renders before sending chat. Prompt messages precede request messages by default; position: "after" reverses the groups. A prompt never removes the requirement for a model or route. Request options supplied to chat do not govern the prompt lookup.
Model names beginning with configured/ are placeholders. Replace them with an accessible provider-qualified identifier from model discovery. The snippets reuse the server client from the quickstart.
Inspect content before execution
const prompt = await nirmos.managedPrompts.retrieveActive("support-reply", { cache: "reload" });
const rendered = await nirmos.managedPrompts.render(prompt, { customerName: "Asha" });
const completion = await nirmos.gateway.chat.create({
model: "configured/chat-model",
messages: [...rendered.messages, { role: "user", content: "What is the refund policy?" }],
});
console.log(rendered.promptVersion, completion.outputText);Retrieving and rendering separately gives the application a point to inspect selected content. Use numeric versions for reproducible selection, or active with a deliberate cache policy. A request-level timeout on chat does not govern its preceding prompt lookup.