Get started with Sophra in minutes
npm install @sophra/core
import { SophraClient } from '@sophra/core'; const client = new SophraClient({ apiKey: process.env.SOPHRA_API_KEY });
await client.documents.createIndex({ name: 'my-first-index', settings: { language: 'en', vectorization: true } });
// 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 });
// 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 } });