Skip to main content

REST API: Memories

Create, search, update, and delete memories via the REST API.

Overview

The Memories API is the core of Trix. Use it to store, search, update, and manage memories. Memories can contain text, markdown, code, URLs, audio, and more.

Create Memory

Store any content type: text, markdown, URLs, audio files, code, JSON, and more. Content type is auto-detected or can be specified explicitly.

POST /v1/memories

Endpoint
POST /v1/memories

Request Body Fields

ParameterTypeRequiredDescription
contentstringYesMemory content (text, URL, base64 audio, etc.)
typestringNotext, markdown, code, json, html, url, audio, note
tagsstring[]NoTags for categorization (max 100)
metadataobjectNoCustom key-value metadata
prioritynumberNo (default: 0)Priority level (0-100)
space_idstringNoSpace to store memory in
expires_atstringNoISO 8601 expiration timestamp
saliencenumberNo (default: 1.0)Memory importance 0-1
is_privatebooleanNo (default: false)Creator-only access
clustersstring[]NoCluster IDs to add memory to
idempotency_keystringNoFor duplicate detection

Processing Options

ParameterTypeDescription
options.splitstringnone, paragraph, sentence, chunk, heading
options.chunk_sizenumberChunk size in tokens (100-10000, default 1000)
options.chunk_overlapnumberOverlap between chunks (0-500, default 100)
options.embedbooleanGenerate embeddings (default true)
options.asyncbooleanAsync embedding (default true)
options.transcribebooleanTranscribe audio (default true)
const memory = await fetch('https://api.trixdb.com/v1/memories', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    content: 'User prefers dark mode and compact layouts',
    type: 'text',
    tags: ['preferences', 'ui'],
    metadata: { source: 'settings_page', version: '2.0' },
    priority: 7,
    salience: 0.9
  })
}).then(r => r.json());

Response (201 Created)

Response (201 Created)
{
  "id": "mem_abc123xyz",
  "content": "User prefers dark mode and compact layouts",
  "content_type": "text",
  "tags": ["preferences", "ui"],
  "metadata": { "source": "settings_page", "version": "2.0" },
  "priority": 7,
  "salience": 0.9,
  "is_private": false,
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z"
}

Get Memory

Endpoint
GET /v1/memories/:id
curl -X GET "https://api.trixdb.com/v1/memories/mem_abc123xyz" \
  -H "Authorization: Bearer YOUR_API_KEY"

Use include parameter to get related data:

curl -X GET "https://api.trixdb.com/v1/memories/mem_abc123xyz?include=relationships,clusters" \
  -H "Authorization: Bearer YOUR_API_KEY"

Update Memory

Endpoint
PATCH /v1/memories/:id
curl -X PATCH "https://api.trixdb.com/v1/memories/mem_abc123xyz" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Updated: User prefers dark mode with high contrast",
    "tags": ["preferences", "accessibility"],
    "priority": 9
  }'

Updating content will trigger re-embedding. Use options.embed: false if you only want to update metadata.

Delete Memory

Endpoint
DELETE /v1/memories/:id
curl -X DELETE "https://api.trixdb.com/v1/memories/mem_abc123xyz" \
  -H "Authorization: Bearer YOUR_API_KEY"

Bulk Operations

Bulk Create

Endpoint
POST /v1/memories/bulk
curl -X POST "https://api.trixdb.com/v1/memories/bulk" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "memories": [
      {"content": "User completed onboarding", "tags": ["onboarding"]},
      {"content": "User selected premium plan", "tags": ["billing"]},
      {"content": "User invited team members", "tags": ["team"]}
    ]
  }'

Bulk Update

Endpoint
PATCH /v1/memories/bulk
curl -X PATCH "https://api.trixdb.com/v1/memories/bulk" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "updates": [
      {"id": "mem_abc123", "priority": 10},
      {"id": "mem_def456", "tags": ["important"]}
    ]
  }'

Bulk Delete

Endpoint
DELETE /v1/memories/bulk
curl -X DELETE "https://api.trixdb.com/v1/memories/bulk" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["mem_abc123", "mem_def456", "mem_ghi789"]}'

Audio & Video Memories

Store and transcribe audio and video files with advanced features including speaker diarization, entity detection, content safety, auto chapters, and summarization.

Supported audio formats: mp3, mp4, m4a, wav, webm, ogg, flac, aac
Supported video formats: mp4, webm, mov, avi, mkv, flv, mpeg

File Size Limits: Audio files are limited to 100MB. Video files are limited to 200MB. For larger files, consider using external storage and providing a URL instead.

Rate Limits: Transcription requests are limited to 10 per hour per API key. This applies to both audio and video transcription endpoints.

Upload Audio/Video

curl -X POST "https://api.trixdb.com/v1/memories" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "data:audio/mp3;base64,//uQxAAAAAANIAAAAAE...",
    "type": "audio",
    "metadata": {"meeting": "standup_2024_01_15"},
    "options": {"transcribe": true}
  }'

Stream Audio/Video

Endpoint
GET /v1/memories/:id/stream

Supports HTTP Range requests for efficient streaming and seeking. The server responds with HTTP 206 Partial Content when a Range header is provided.

# Stream full audio
curl -X GET "https://api.trixdb.com/v1/memories/mem_audio123/stream" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Stream with Range request (bytes 0-999999)
curl -X GET "https://api.trixdb.com/v1/memories/mem_audio123/stream" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Range: bytes=0-999999"

Get Transcript

Endpoint
GET /v1/memories/:id/transcript
curl -X GET "https://api.trixdb.com/v1/memories/mem_audio123/transcript" \
  -H "Authorization: Bearer YOUR_API_KEY"

Transcribe with Advanced Options

Endpoint
POST /v1/memories/:id/transcribe

Request Body

ParameterTypeDescription
languagestringLanguage code (e.g., 'en', 'es')
promptstringContext to improve transcription accuracy
providerstring'assemblyai' or 'openai' (default: account preference)
enableSpeakerDiarizationbooleanEnable speaker identification and labeling
enableEntityDetectionbooleanEnable entity detection in transcript
enableContentSafetybooleanEnable content safety labeling
enableAutoChaptersbooleanEnable automatic chapter generation
enableAutoSummarizationbooleanEnable automatic summarization
speakersExpectednumberExpected number of speakers (hint for diarization)

Example: Basic Transcription

curl -X POST "https://api.trixdb.com/v1/memories/mem_audio123/transcribe" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "language": "en"
  }'

Example: Advanced Transcription with Speaker Diarization

curl -X POST "https://api.trixdb.com/v1/memories/mem_audio123/transcribe" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "assemblyai",
    "enableSpeakerDiarization": true,
    "speakersExpected": 2,
    "enableEntityDetection": true,
    "enableAutoChapters": true,
    "enableAutoSummarization": true,
    "language": "en",
    "prompt": "This is a meeting between two executives discussing Q1 results"
  }'

Provider Features & Limits

FeatureAssemblyAIOpenAI Whisper
Max File Size5GB25MB
Speaker DiarizationYesNo
Entity DetectionYesNo
Content SafetyYesNo
Auto ChaptersYesNo
Auto SummarizationYesNo
Word-level TimestampsYesYes

Audio Clip Streaming

Stream specific time ranges from audio files without downloading the entire file. This is ideal for playing back specific segments, creating highlights, or building audio players with precise seeking.

Endpoint
GET /v1/audio/:id/clip

Query Parameters

ParameterTypeRequiredDescription
startnumberYesStart time in seconds (e.g., 30.5)
endnumberYesEnd time in seconds (e.g., 120.0)
contextnumberNo (default 0)Additional seconds of context before/after
formatstringNo (default mp3)Output format: mp3, wav, ogg, m4a, webm

Maximum Duration: Clips are limited to 3600 seconds (1 hour). Requests exceeding this limit will return a 400 Bad Request error.

const clipUrl = new URL('https://api.trixdb.com/v1/audio/aud_abc123/clip');
clipUrl.searchParams.set('start', '60');
clipUrl.searchParams.set('end', '90');
clipUrl.searchParams.set('format', 'mp3');

const response = await fetch(clipUrl, {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
const blob = await response.blob();
const audioUrl = URL.createObjectURL(blob);
const audio = new Audio(audioUrl);
audio.play();

Get Clip Metadata

Endpoint
GET /v1/audio/:id/clip/info
curl -X GET "https://api.trixdb.com/v1/audio/aud_abc123/clip/info?start=60&end=90" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response (200 OK)

Response (200 OK)
{
  "id": "aud_abc123",
  "start": 60,
  "end": 90,
  "duration": 30,
  "source_duration": 3600,
  "byte_size": 480000,
  "byte_range": "1920000-2400000",
  "format": "mp3",
  "sample_rate": 44100,
  "channels": 2,
  "bitrate": 128000,
  "clip_url": "/v1/audio/aud_abc123/clip?start=60&end=90&format=mp3"
}

Video Metadata

Retrieve detailed metadata about video files including resolution, frame rate, codec information, duration, and audio track details.

Endpoint
GET /v1/memories/:id/video/metadata
curl -X GET "https://api.trixdb.com/v1/memories/mem_video123/video/metadata" \
  -H "Authorization: Bearer YOUR_API_KEY"

AI Video Interpretation

Use AI to analyze and interpret video content. Extract scene descriptions, detect objects, identify text via OCR, and generate comprehensive summaries.

Endpoint
POST /v1/memories/:id/video/interpret

Request Body

ParameterTypeDescription
frames_to_analyzenumberNumber of frames to analyze (max: 100, default 10)
include_ocrbooleanExtract text from frames via OCR (default false)
frame_selectionstringFrame selection strategy: uniform, keyframes, scene_change (default uniform)
start_timenumberStart time in seconds for analysis range
end_timenumberEnd time in seconds for analysis range
curl -X POST "https://api.trixdb.com/v1/memories/mem_video123/video/interpret" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "frames_to_analyze": 20,
    "include_ocr": true,
    "frame_selection": "scene_change"
  }'

Processing Time: Video interpretation is an asynchronous operation. For longer videos, consider using the job status endpoint to poll for completion, or configure webhooks for notification.

Reinforce Memory

Boost a memory's salience when it proves useful:

Endpoint
POST /v1/memories/:id/reinforce
curl -X POST "https://api.trixdb.com/v1/memories/mem_abc123/reinforce" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"boost": 0.1, "accessed": true}'