Authentication

Secure your API requests with proper authentication methods.

Security Warning: Never expose your API keys in client-side code or commit them to public repositories. Always store sensitive credentials in environment variables.

Authentication Methods

LaikaTest supports two authentication methods:

  • API Tokens: For external integrations and programmatic access
  • JWT Tokens: For dashboard and session-based authentication

API Token Authentication

Generating API Tokens

  1. Go to Dashboard → Settings → API Keys
  2. Click Create New API Key
  3. Give your key a descriptive name
  4. Select the project to associate with the key
  5. Copy the generated token (displayed only once)

Important: API tokens are shown only once. Store them securely immediately.

Environment Variables

Store your API key in environment variables for security:

Bash
# .envLAIKATEST_API_KEY=your_api_token_here

Base URL

Bash
https://api.laikatest.com

API Endpoints (cURL Examples)

1. Fetch Prompt by Name

Bash
curl "https://api.laikatest.com/api/v1/prompts/by-name/my-prompt?versionNumber=10" \  -H "Authorization: Bearer YOUR_API_TOKEN"

2. Evaluate Experiment

Bash
curl -X POST "https://api.laikatest.com/api/v3/experiments/evaluate" \  -H "Authorization: Bearer YOUR_API_TOKEN" \  -H "Content-Type: application/json" \  -d '{    "experimentTitle": "homepage-test",    "context": {      "userId": "user123",      "plan": "pro"    }  }'

3. Submit Scores

Bash
curl -X POST "https://api.laikatest.com/api/v1/scores" \  -H "Authorization: Bearer YOUR_API_TOKEN" \  -H "Content-Type: application/json" \  -d '{    "expId": "exp-789",    "bucketId": "bucket-101",    "promptVersionId": "123",    "scores": [      {"name": "rating", "type": "int", "value": 5},      {"name": "helpful", "type": "bool", "value": true}    ],    "sessionId": "session-456",    "userId": "user-123"  }'

Error Responses

JSON
{  "success": false,  "error": "Authentication error message"}

Common Error Codes

  • 401 Unauthorized: Invalid or missing API token
  • 403 Forbidden: Token does not have required permissions
  • 404 Not Found: Resource not accessible for this token

Access Control Matrix

Dashboard-Only (JWT Required)
  • • Project creation and modifications
  • • Prompt creation and deletion
  • • Organization and team management
  • • Billing and account settings
Programmatic Access (API Token)
  • • Fetch prompts
  • • Evaluate experiments
  • • Submit experiment scores