POST
/
test-case
curl --request POST \
  --url https://api.tela.com/test-case \
  --header 'Content-Type: application/json' \
  --data '{
  "title": "<string>",
  "variablesRichContent": {},
  "promptId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "expectedOutput": "<string>",
  "promptApplicationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "messages": [
    {
      "role": "user",
      "content": "<string>"
    }
  ],
  "variables": {},
  "files": [
    {
      "index": 123,
      "name": "<string>",
      "mimeType": "<string>",
      "vaultUrl": "<string>",
      "variableName": "<string>",
      "url": "<string>"
    }
  ],
  "metadata": {
    "source": "workstation"
  }
}'

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.

Create a Test Case

const API_KEY = process.env.TELA_API_KEY;

// Single test case
const 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 = await fetch('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);

Create Multiple Test Cases

const API_KEY = process.env.TELA_API_KEY;

// Multiple test cases
const 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 = await fetch('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);

Request Body

The request body can be either a single test case object or an array of test case objects.

Test Case Object

FieldTypeRequiredDescription
promptIdstringYesUUID of the prompt to create test cases for
titlestringNoTitle of the test case
messagesarrayYesArray of message objects with role and content
variablesobjectNoKey-value pairs of variables used in the test case
variablesRichContentobjectYesKey-value pairs of rich content variables
filesarrayNoArray of file objects to attach to the test case
expectedOutputstringNoExpected output for evaluation purposes
promptApplicationIdstringNoUUID of the prompt application if applicable
metadataobjectNoMetadata about the test case including source

Message Object

FieldTypeRequiredDescription
rolestringYesRole of the message sender (user, system, assistant, function, developer)
contentstringYesContent of the message

File Object

FieldTypeRequiredDescription
indexnumberYesIndex of the file in the array
namestringYesName of the file
mimeTypestringYesMIME type of the file
vaultUrlstringYesURL to the file in the vault
variableNamestringYesVariable name associated with the file
urlstringYesPublic URL to the file

Response

The response will contain the created test case(s) with all fields including the generated IDs and timestamps.

Body

application/json
variablesRichContent
object
required

Key-value pairs of rich content variables

promptId
string
required

UUID of the prompt to create test cases for

messages
object[]
required

Array of message objects with role and content

title
string

Title of the test case

expectedOutput
string | null

Expected output for evaluation purposes

promptApplicationId
string | null

UUID of the prompt application if applicable

variables
object | null

Key-value pairs of variables used in the test case

files
object[] | null

Array of file objects to attach to the test case

metadata
object

Metadata about the test case

Response

200

Test case(s) created successfully