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-clientStep 2: Get Your API Key
- Log in to your LaikaTest dashboard
- Navigate to Settings → API Keys
- Click "Create New API Key"
- Give it a name (e.g., "Development")
- Select your project
- 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:
- Create a new project in the dashboard
- Inside the project, create a prompt template
- Add your prompt content (supports variables like {{name}})
- 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:
- Create at least two versions of your prompt
- Create a new experiment
- Add variants linking to different prompt versions
- Configure traffic split (e.g., 50/50)
- 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