Back to Supermemory

Add Memories Overview

apps/docs/add-memories/overview.mdx

latest5.1 KB
Original Source

Add any type of content to Supermemory - text, files, URLs, images, videos, and more. Everything is automatically processed into searchable memories that form part of your intelligent knowledge graph.

Prerequisites

Before adding memories, you need to set up the Supermemory client:

  • Install the SDK for your language
  • Get your API key from Supermemory Console
  • Initialize the client with your API key
<CodeGroup>
bash
npm install supermemory
bash
pip install supermemory
</CodeGroup> <CodeGroup>
typescript
import Supermemory from 'supermemory';

const client = new Supermemory({
  apiKey: process.env.SUPERMEMORY_API_KEY!
});
python
from supermemory import Supermemory
import os

client = Supermemory(
    api_key=os.environ.get("SUPERMEMORY_API_KEY")
)
</CodeGroup>

Quick Start

<CodeGroup>
typescript
// Add text content
const result = await client.add({
  content: "Machine learning enables computers to learn from data",
  containerTag: "ai-research",
  metadata: { priority: "high" }
});

console.log(result);
// Output: { id: "abc123", status: "queued" }
python
# Add text content
result = client.add(
    content="Machine learning enables computers to learn from data",
    container_tags=["ai-research"],
    metadata={"priority": "high"}
)

print(result)
# Output: {"id": "abc123", "status": "queued"}
bash
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Machine learning enables computers to learn from data",
    "containerTag": "ai-research",
    "metadata": {"priority": "high"}
  }'

# Response: {"id": "abc123", "status": "queued"}
</CodeGroup>

Key Concepts

<Note> **New to Supermemory?** Read [How Supermemory Works](/how-it-works) to understand the knowledge graph architecture and the distinction between documents and memories. </Note>

Quick Overview

  • Documents: Raw content you upload (PDFs, URLs, text)
  • Memories: Searchable chunks created automatically with relationships
  • Container Tags: Group related content for better context
  • Metadata: Additional information for filtering

Content Sources

Add content through three methods:

  1. Direct Text: Send text content directly via API
  2. File Upload: Upload PDFs, images, videos for extraction
  3. URL Processing: Automatic extraction from web pages and platforms

Endpoints

<Warning> Remember, these endpoints add documents. Memories are inferred by Supermemory. </Warning>

Add Content

POST /v3/documents

Add text content, URLs, or any supported format.

<CodeGroup>
typescript
await client.add({
  content: "Your content here",
  containerTag: "project"
});
python
client.add(
  content="Your content here",
  container_tags=["project"]
)
bash
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "Your content here", "containerTag": "project"}'
</CodeGroup>

Upload File

POST /v3/documents/file

Upload files directly for processing.

<CodeGroup>
typescript
await client.documents.uploadFile({
  file: fileStream,
  containerTag: "project"
});
python
client.documents.upload_file(
  file=open('file.pdf', 'rb'),
  container_tags='project'
)
bash
curl -X POST "https://api.supermemory.ai/v3/documents/file" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -F "[email protected]" \
  -F "containerTags=project"
</CodeGroup>

Update Memory

PATCH /v3/documents/{id}

Update existing document content or metadata. Content changes trigger reindexing; metadata-only updates do not.

<CodeGroup>
typescript
await client.documents.update("doc_id", {
  content: "Updated content"
});
python
client.documents.update("doc_id", {
  "content": "Updated content"
})
bash
curl -X PATCH "https://api.supermemory.ai/v3/documents/doc_id" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "Updated content"}'
</CodeGroup>

Supported Content Types

Documents

  • PDF with OCR support
  • Google Docs, Sheets, Slides
  • Notion pages
  • Microsoft Office files

Media

  • Images (JPG, PNG, GIF, WebP) with OCR

Web Content

  • Twitter/X posts
  • YouTube videos with captions

Text Formats

  • Plain text
  • Markdown
  • CSV files

<Note> Refer to the connectors guide to learn how you can connect Google Drive, Notion, and OneDrive and sync files in real-time. </Note>

Response Format

json
{
  "id": "D2Ar7Vo7ub83w3PRPZcaP1",
  "status": "queued"
}
  • id: Unique document identifier
  • status: Processing state (queued, processing, done)

Next Steps