Create one or more test cases for a prompt. Test cases can be used to validate prompt performance and ensure consistent output across different scenarios.
constAPI_KEY= process.env.TELA_API_KEY;// Single test caseconst testCase ={ title:"Customer Support Query Test", promptId:"prompt_uuid", messages:[{ role:"system", content:"You are a helpful customer support assistant."},{ role:"user", content:"My order hasn't arrived yet."}], variables:{"customer_name":"John Doe","order_id":"ORD-12345"}, variablesRichContent:{}, expectedOutput:"I'll help you track down your order, John. Let me look up order ORD-12345 for you.", metadata:{ source:"craft"}};const response =awaitfetch('https://api.tela.ai/test-case',{ method:'POST', headers:{'Authorization':`Bearer ${API_KEY}`,'Content-Type':'application/json'}, body:JSON.stringify(testCase)});const data =await response.json();console.log(data);
constAPI_KEY= process.env.TELA_API_KEY;// Multiple test casesconst testCases =[{ title:"Customer Support Query - Order Status", promptId:"prompt_uuid", messages:[{ role:"system", content:"You are a helpful customer support assistant."},{ role:"user", content:"My order hasn't arrived yet."}], variables:{"customer_name":"John Doe","order_id":"ORD-12345"}, variablesRichContent:{}, expectedOutput:"I'll help you track down your order, John. Let me look up order ORD-12345 for you.", metadata:{ source:"craft"}},{ title:"Customer Support Query - Return Policy", promptId:"prompt_uuid", messages:[{ role:"system", content:"You are a helpful customer support assistant."},{ role:"user", content:"What's your return policy?"}], variables:{"customer_name":"Jane Smith"}, variablesRichContent:{}, expectedOutput:"Our return policy allows returns within 30 days of purchase with a receipt.", metadata:{ source:"craft"}}];const response =awaitfetch('https://api.tela.ai/test-case',{ method:'POST', headers:{'Authorization':`Bearer ${API_KEY}`,'Content-Type':'application/json'}, body:JSON.stringify(testCases)});const data =await response.json();console.log(data);