Skip to main content

Quick Start

Get up and running with Trix in under 5 minutes. Install the SDK, store your first memory, and see semantic recall in action.

Prerequisites

Before you begin, make sure you have:

  • A Trix account — Sign up free (no credit card required)
  • An API key — Get your API key by running trix keys create after installing the CLI in Step 1, or generate one in the dashboard
  • Node.js 18+, Python 3.9+, or .NET 6+

The free tier includes 1,000 memories, 5,000 search queries, and 100 credits per month — plenty for development and small projects.

Step 1: Install the SDK

Install the Trix client library for your language:

npm install @trixdb/client

Or install the CLI globally:

npm install -g @trixdb/cli

Step 2: Set Your API Key

Add your API key to your environment. Never commit API keys to version control.

export TRIX_API_KEY="your_api_key_here"

Add .env to your .gitignore file to prevent accidentally exposing your API key.

Step 3: Initialize the Client

Create a Trix client instance with a session identifier. Sessions isolate memories between users.

import { Trix } from '@trixdb/client';

// Initialize with your API key
const trix = new Trix({
  apiKey: process.env.TRIX_API_KEY
});

Step 4: Store a Memory

Use remember() to store information. Trix automatically generates embeddings and indexes the content.

// Store a memory
const memory = await trix.memories.create({
  content: 'User prefers dark mode and TypeScript'
});

console.log('Stored memory:', memory.id);
// Output: Stored memory: mem_abc123xyz

Step 5: Recall Memories

Use recall() to search memories semantically. You don't need exact keyword matches — Trix understands meaning.

// Search memories using natural language
const results = await trix.memories.list({
  q: 'What are the user preferences?'
});

for (const mem of results.data) {
  console.log(`[${mem.relevance.toFixed(2)}] ${mem.content}`);
}
// Output: [0.94] User prefers dark mode and TypeScript

Notice: We asked about "user preferences" but stored "dark mode and TypeScript". Trix understands they're related.

Step 6: Reinforce Useful Memories

Use reinforce() to mark memories as helpful. This improves future recall accuracy.

// Submit feedback on a memory
if (results.data.length > 0) {
  await trix.feedback.submit({ memoryId: results.data[0].id, helpful: true });
  console.log('Feedback submitted!');
}

Complete Example

Here's everything together — a complete script you can run:

import { Trix } from '@trixdb/client';

async function main() {
  // Initialize the client
  const trix = new Trix({
    apiKey: process.env.TRIX_API_KEY
  });

  // Store some memories
  await trix.memories.create({ content: 'User is a backend developer' });
  await trix.memories.create({ content: 'User prefers Python over JavaScript' });
  await trix.memories.create({ content: 'User is working on a recommendation engine' });

  console.log('Stored 3 memories');

  // Search for relevant context
  const results = await trix.memories.list({
    q: 'What programming language should I use?'
  });

  console.log('\nRelevant memories:');
  for (const mem of results.data) {
    console.log(`  [${mem.relevance.toFixed(2)}] ${mem.content}`);
  }

  // Submit feedback on the most relevant memory
  if (results.data.length > 0) {
    await trix.feedback.submit({ memoryId: results.data[0].id, helpful: true });
    console.log('\nFeedback submitted');
  }
}

main().catch(console.error);

Run it:

npx ts-node demo.ts

Next Steps

You've got the basics! Here's where to go next: