Quick Start Guide

Get started with LaikaTest in less than 5 minutes

Prerequisites: You'll need a LaikaTest account and Node.js 14+ installed.Sign up here if you don't have an account yet.

Step 1: Install the SDK

Install the LaikaTest client SDK in your project:

npm install @laikatest/js-client

Step 2: Get Your API Key

  1. Log in to your LaikaTest dashboard
  2. Navigate to Settings → API Keys
  3. Click "Create New API Key"
  4. Give it a name (e.g., "Development")
  5. Select your project
  6. Copy the generated API key

Important: Store your API key securely in environment variables. Never commit it to version control.

Step 3: Create a Project and Prompt

Before integrating, set up your first prompt in the dashboard:

  1. Create a new project in the dashboard
  2. Inside the project, create a prompt template
  3. Add your prompt content (supports variables like {{name}})
  4. Publish your first prompt version
Text
Example prompt template:Hello {{customerName}}, thank you for contacting support.How can we help you with {{issue}} today?

Step 4: Fetch and Use Prompts

Now integrate the SDK in your application:

import { LaikaTest } from '@laikatest/js-client';// Initialize the clientconst client = new LaikaTest(process.env.LAIKATEST_API_KEY);try {  // Fetch a prompt by name  const prompt = await client.getPrompt('customer-greeting');  // Compile with variables  const message = prompt.compile({    customerName: 'Alice',    issue: 'billing question'  });  console.log(message);  // Output: Hello Alice, thank you for contacting support...} catch (error) {  console.error('Failed to fetch prompt:', error);} finally {  client.destroy();}

Step 5: Run A/B Experiments (Optional)

To run experiments and test different prompt variations:

5a. Set up an experiment in the dashboard:

  1. Create at least two versions of your prompt
  2. Create a new experiment
  3. Add variants linking to different prompt versions
  4. Configure traffic split (e.g., 50/50)
  5. Start the experiment

5b. Fetch experiment prompts in your code:

TypeScript
// Get prompt from running experimentconst result = await client.getExperimentPrompt(  'greeting-experiment',  {    user_id: 'user_123',      // For consistent assignment    session_id: 'session_456'  });// Use the assigned prompt variantconst message = result.prompt.compile({  customerName: 'Alice'});

Complete Example

Here's a complete working example:

import { LaikaTest } from '@laikatest/js-client';async function sendGreeting(customerName: string, issue: string) {  const client = new LaikaTest(process.env.LAIKATEST_API_KEY, {    timeout: 5000,    cacheEnabled: true  });  try {    // Fetch prompt template    const prompt = await client.getPrompt('customer-greeting');    // Compile with customer data    const message = prompt.compile({      customerName,      issue    });    // Send to customer (via email, chat, etc.)    return message;  } catch (error) {    console.error('Error fetching prompt:', error);    // Fallback message    return `Hello ${customerName}...`;  } finally {    client.destroy();  }}// Usageconst greeting = await sendGreeting('Alice', 'billing question');console.log(greeting);

Best Practices

  • Environment Variables: Always store API keys in environment variables, never hardcode them
  • Client Reuse: Create one client instance and reuse it across requests for better performance
  • Error Handling: Always wrap SDK calls in try-catch blocks with fallback behavior
  • Caching: Keep caching enabled (default) to reduce API calls and improve response times
  • Resource Cleanup: Call client.destroy() when done to properly clean up resources

What's Next?