Quickstart Guide

Get up and running with Sophra quickly by following these steps.

Prerequisites

  • Node.js 16 or higher
  • A Sophra API key

Installation

npm install @sophra/core

Basic Setup

  1. Initialize the Sophra client:
import { SophraClient } from '@sophra/core';

const client = new SophraClient({
  apiKey: process.env.SOPHRA_API_KEY
});
  1. Configure your first document index:
await client.documents.createIndex({
  name: 'my-first-index',
  settings: {
    language: 'en',
    vectorization: true
  }
});

Core Features

Document Processing

// Index a document
const document = await client.documents.create({
  index: 'my-first-index',
  content: 'This is a sample document for testing.',
  metadata: {
    title: 'Sample Document',
    tags: ['test', 'example']
  }
});

// Search for documents
const results = await client.search.query({
  index: 'my-first-index',
  query: 'sample document',
  limit: 10
});

Experimentation

// Create an A/B test
const experiment = await client.experiments.create({
  name: 'search-ranking-test',
  variants: ['default', 'semantic'],
  distribution: [0.5, 0.5]
});

// Track experiment results
await client.experiments.track({
  experimentId: experiment.id,
  variantId: 'semantic',
  metrics: {
    clickthrough: true,
    conversionTime: 1500
  }
});

Next Steps

Need help? Join our GitHub Discussions or email [email protected]