Templates let you define reusable prompts with {{variable}} slots.
1 // Create a template with your API key 2 const client = new MeshAPI({ 3 baseUrl: "https://api.yourdomain.com", 4 token: "rsk_...", 5 }); 6 7 const template = await client.templates.create({ 8 name: "support-agent", 9 system: "You are a helpful customer support agent for {{company}}. Be concise and friendly.", 10 model: "openai/gpt-4o-mini", 11 variables: ["company"], 12 }); 13 14 console.log("Created template:", template.id); 15 16 // Use the template in a chat completion (data-plane key) 17 const response = await client.chat.completions.create({ 18 messages: [{ role: "user", content: "How do I reset my password?" }], 19 template: "support-agent", // template name or UUID 20 variables: { company: "Acme Corp" }, 21 }); 22 23 console.log(response.choices[0]?.message.content);
1 // List all templates 2 const templates = await client.templates.list(); 3 4 // Get a specific template 5 const t = await client.templates.get("uuid-here"); 6 7 // Update a template 8 const updated = await client.templates.update("uuid-here", { 9 system: "You are a concise assistant for {{company}}.", 10 model: "openai/gpt-4o", 11 }); 12 13 // Delete a template 14 await client.templates.delete("uuid-here");