### Install and Run MemoryBench Source: https://supermemory.ai/docs/memorybench/github Install dependencies, set up environment variables with API keys, and run a benchmark. This example shows how to run the 'locomo' benchmark with the 'supermemory' provider. ```bash bun install cp .env.example .env.local # Add your API keys bun run src/index.ts run -p supermemory -b locomo ``` -------------------------------- ### Python Development Setup with uv Source: https://supermemory.ai/docs/integrations/openai Installs uv, clones the repository, sets up the Python project, and runs tests, type checking, and formatting. ```bash # Install uv curl -LsSf https://astral.sh/uv/install.sh | sh # Setup project git clone cd packages/openai-sdk-python uv sync --dev # Run tests uv run pytest # Type checking uv run mypy src/supermemory_openai # Formatting uv run black src/ tests/ uv run isort src/ tests/ ``` -------------------------------- ### Environment Variables Setup Source: https://supermemory.ai/docs/cookbook/ai-sdk-integration Ensure these environment variables are set for all examples. This includes API keys for Supermemory, OpenAI, and Anthropic. ```bash SUPERMEMORY_API_KEY=your_supermemory_key OPENAI_API_KEY=your_openai_key ANTHROPIC_API_KEY=your_anthropic_key ``` -------------------------------- ### JavaScript Development Setup Source: https://supermemory.ai/docs/integrations/openai Installs npm dependencies, runs tests, type checking, and linting for the JavaScript project. ```bash # Install dependencies npm install # Run tests npm test # Type checking npm run type-check # Linting npm run lint ``` -------------------------------- ### Backend Server Start Command Source: https://supermemory.ai/docs/cookbook/personal-assistant Command to start the backend server. Ensure this is running before starting the frontend. ```bash python main.py ``` -------------------------------- ### Production-like .env Configuration Source: https://supermemory.ai/docs/self-hosting/configuration Example environment file for a production-like setup. It specifies the data directory and an API key for an LLM provider. ```dotenv # Persistent data location SUPERMEMORY_DATA_DIR=/var/lib/supermemory # One LLM provider OPENAI_API_KEY=sk-... ``` -------------------------------- ### Install Supermemory with bunx Source: https://supermemory.ai/docs/self-hosting/quickstart Use this command to download and install the Supermemory server using bunx. ```bash bunx supermemory local ``` -------------------------------- ### Install Supermemory Source: https://supermemory.ai/docs/self-hosting/overview Download and install the Supermemory binary using curl or npx. ```bash curl -fsSL https://supermemory.ai/install | bash ``` ```bash npx supermemory local ``` -------------------------------- ### Start Web UI Source: https://supermemory.ai/docs/memorybench/cli Start the MemoryBench web user interface. The UI will be accessible at http://localhost:3000. ```bash bun run src/index.ts serve ``` -------------------------------- ### Install Supermemory with npx Source: https://supermemory.ai/docs/self-hosting/quickstart Use this command to download and install the Supermemory server using npx. ```bash npx supermemory local ``` -------------------------------- ### Next.js Project Setup for Personal AI Source: https://supermemory.ai/docs/cookbook/personal-assistant Commands to create a new Next.js project with TypeScript, Tailwind CSS, and install necessary AI SDK packages. ```bash npx create-next-app@latest personal-ai --typescript --tailwind --app cd personal-ai npm install @supermemory/tools ai @ai-sdk/openai ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://supermemory.ai/docs/memorybench/installation Clone the MemoryBench repository and install its dependencies using Bun. Ensure you have Bun installed and the git command-line tool available. ```bash git clone https://github.com/supermemoryai/memorybench cd memorybench bun install ``` -------------------------------- ### Quick Install MCP Source: https://supermemory.ai/docs/supermemory-mcp/mcp Install the MCP client with a specified AI assistant. Replace 'claude' with your client like 'cursor' or 'windsurf'. ```bash npx -y install-mcp@latest https://mcp.supermemory.ai/mcp --client claude --oauth=yes ``` -------------------------------- ### Quick Start: Supermemory SDK (TypeScript) Source: https://supermemory.ai/docs/integrations/supermemory-sdk Initialize the Supermemory client and perform basic operations like adding a memory, searching memories, and getting a user profile. Ensure your API key is set as an environment variable or passed directly. ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env.SUPERMEMORY_API_KEY, // Default, can be omitted }); // Add a memory await client.add({ content: "Meeting notes from Q1 planning", containerTags: ["user_123"] }); // Search memories const response = await client.search.documents({ q: "planning notes", containerTags: ["user_123"] }); console.log(response.results); // Get user profile const profile = await client.profile({ containerTag: "user_123" }); console.log(profile.profile.static); console.log(profile.profile.dynamic); ``` -------------------------------- ### Install @supermemory/bash with bun Source: https://supermemory.ai/docs/smfs/bash-tool Install the bash tool package using bun. ```bash bun add @supermemory/bash ``` -------------------------------- ### Install supermemory-bash Source: https://supermemory.ai/docs/smfs/bash-tool-python Install the supermemory-bash package using pip or uv. ```bash pip install supermemory-bash ``` ```bash uv add supermemory-bash ``` -------------------------------- ### Install SMFS in Daytona Sandbox (Python) Source: https://supermemory.ai/docs/smfs/providers/daytona Installs the SMFS binary from GitHub Releases and adds it to the PATH. Also configures FUSE and installs the Python SDK. Use this when your agent runs within the sandbox. ```python SMFS_INSTALL = ( "mkdir -p $HOME/.local/bin && " "curl -sL https://github.com/supermemoryai/smfs/releases/download/" "v0.0.1-rc2/smfs-linux-x64 -o $HOME/.local/bin/smfs && " "chmod +x $HOME/.local/bin/smfs && " "echo 'user_allow_other' | sudo tee -a /etc/fuse.conf > /dev/null && " "pip install claude-agent-sdk" ) ``` -------------------------------- ### Start Server Source: https://supermemory.ai/docs/cookbook/perplexity-supermemory Initializes and starts the Express server on the specified port, defaulting to 3000. ```javascript const PORT = process.env.PORT || 3000; app.listen(PORT, () => console.log(`Listening on http://localhost:${PORT}`)); ``` -------------------------------- ### Install Supermemory AI SDK Source: https://supermemory.ai/docs/integrations/ai-sdk Install the Supermemory tools package using npm. ```bash npm install @supermemory/tools ``` -------------------------------- ### Install Supermemory with curl Source: https://supermemory.ai/docs/self-hosting/quickstart Use this command to download and install the Supermemory server using curl. ```bash curl -fsSL https://supermemory.ai/install | bash ``` -------------------------------- ### Install SMFS in Daytona Sandbox (TypeScript) Source: https://supermemory.ai/docs/smfs/providers/daytona Installs the SMFS binary from GitHub Releases and adds it to the PATH. Also configures FUSE and installs the Python SDK. Use this when your agent runs within the sandbox. ```typescript const SMFS_INSTALL = "mkdir -p $HOME/.local/bin && " + "curl -sL https://github.com/supermemoryai/smfs/releases/download/" + "v0.0.1-rc2/smfs-linux-x64 -o $HOME/.local/bin/smfs && " + "chmod +x $HOME/.local/bin/smfs && " + "echo 'user_allow_other' | sudo tee -a /etc/fuse.conf > /dev/null && " + "pip install claude-agent-sdk"; ``` -------------------------------- ### Install SMFS Binary Source: https://supermemory.ai/docs/smfs/install Installs the SMFS binary to ~/.local/bin. Compatible with macOS and Linux. Ensure ~/.local/bin is in your PATH. ```bash curl -fsSL https://smfs.ai/install | bash ``` -------------------------------- ### Frontend Server Start Command Source: https://supermemory.ai/docs/cookbook/personal-assistant Command to start the Streamlit frontend application. Access it via http://localhost:8501. ```bash streamlit run streamlit_app.py ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://supermemory.ai/docs/memorybench/contributing Clone your fork of the MemoryBench repository and install project dependencies using Bun. ```bash git clone https://github.com/YOUR_USERNAME/memorybench cd memorybench bun install ``` -------------------------------- ### Install Supermemory Tools and Mastra Core Source: https://supermemory.ai/docs/integrations/mastra Install the necessary packages for integrating Supermemory with Mastra AI agents. ```bash npm install @supermemory/tools @mastra/core ``` -------------------------------- ### Install LangChain and Supermemory Packages Source: https://supermemory.ai/docs/integrations/langchain Install the necessary Python packages for LangChain, OpenAI integration, Supermemory, and environment variable loading. ```bash pip install langchain langchain-openai supermemory python-dotenv ``` -------------------------------- ### Quickstart: Create and use Bash instance Source: https://supermemory.ai/docs/smfs/bash-tool-python Initialize the bash tool and execute a command. Ensure the SUPERMEMORY_API_KEY environment variable is set. ```python import asyncio import os from supermemory_bash import create_bash async def main() -> None: result = await create_bash( api_key=os.environ["SUPERMEMORY_API_KEY"], container_tag="user_42", ) bash = result.bash r = await bash.exec("ls /") print(r.stdout) asyncio.run(main()) ``` -------------------------------- ### Install Supermemory and Convex Packages Source: https://supermemory.ai/docs/integrations/convex Install the necessary npm packages for Supermemory and Convex integration. For AI chat examples, also install AI SDK packages. ```bash npm install supermemory convex ``` ```bash npm install @supermemory/tools @ai-sdk/openai ai ``` -------------------------------- ### Quickstart: Initialize and use Bash Tool Source: https://supermemory.ai/docs/smfs/bash-tool Initialize the bash tool with your API key and container tag, then execute a command. ```typescript import { createBash } from "@supermemory/bash"; const { bash, toolDescription } = await createBash({ apiKey: process.env.SUPERMEMORY_API_KEY!, containerTag: "user_42", }); const result = await bash.exec("ls /"); console.log(result.stdout); ``` -------------------------------- ### Quick Start with Python SDK Source: https://supermemory.ai/docs/integrations/openai Initialize OpenAI client and Supermemory tools to enable chat completions with memory access. Handles tool calls if present. ```python import asyncio import openai from supermemory_openai import SupermemoryTools, execute_memory_tool_calls async def main(): # Initialize OpenAI client client = openai.AsyncOpenAI(api_key="your-openai-api-key") # Initialize Supermemory tools tools = SupermemoryTools( api_key="your-supermemory-api-key", config={"project_id": "my-project"} ) # Chat with memory tools response = await client.chat.completions.create( model="gpt-5", messages=[ { "role": "system", "content": "You are a helpful assistant with access to user memories." }, { "role": "user", "content": "Remember that I prefer tea over coffee" } ], tools=tools.get_tool_definitions() ) # Handle tool calls if present if response.choices[0].message.tool_calls: tool_results = await execute_memory_tool_calls( api_key="your-supermemory-api-key", tool_calls=response.choices[0].message.tool_calls, config={"project_id": "my-project"} ) print("Tool results:", tool_results) print(response.choices[0].message.content) asyncio.run(main()) ``` -------------------------------- ### Configure Custom Container Tags Source: https://supermemory.ai/docs/integrations/openclaw Example of configuring custom container tags during the advanced setup. This allows for specific routing of memories based on channel or topic. ```text twitter-bookmarks:Twitter bookmarks saved from Twitter ``` -------------------------------- ### Python SDK Quick Start Source: https://supermemory.ai/docs/integrations/openai Initialize OpenAI client and Supermemory tools, then use them in a chat completion to interact with user memories. ```APIDOC ## Python SDK Quick Start ### Description Initialize OpenAI client and Supermemory tools, then use them in a chat completion to interact with user memories. ### Usage ```python import asyncio import openai from supermemory_openai import SupermemoryTools, execute_memory_tool_calls async def main(): # Initialize OpenAI client client = openai.AsyncOpenAI(api_key="your-openai-api-key") # Initialize Supermemory tools tools = SupermemoryTools( api_key="your-supermemory-api-key", config={"project_id": "my-project"} ) # Chat with memory tools response = await client.chat.completions.create( model="gpt-5", messages=[ { "role": "system", "content": "You are a helpful assistant with with access to user memories." }, { "role": "user", "content": "Remember that I prefer tea over coffee" } ], tools=tools.get_tool_definitions() ) # Handle tool calls if present if response.choices[0].message.tool_calls: tool_results = await execute_memory_tool_calls( api_key="your-supermemory-api-key", tool_calls=response.choices[0].message.tool_calls, config={"project_id": "my-project"} ) print("Tool results:", tool_results) print(response.choices[0].message.content) asyncio.run(main()) ``` ``` -------------------------------- ### Complete Migration Example: Zep AI vs. Supermemory Source: https://supermemory.ai/docs/migration/from-zep A comprehensive example comparing the full workflow of adding and searching memories in Zep AI versus Supermemory, illustrating the API mapping and parameter changes. ```python from zep_python import ZepClient client = ZepClient(api_key="...") session = client.session.create(session_id="user_123", user_id="user_123") client.memory.add("user_123", { "content": "I love Python", "role": "user" }) results = client.memory.search("user_123", { "text": "programming", "limit": 3 }) ``` ```python from supermemory import Supermemory client = Supermemory(api_key="...") containerTag = ["user_123"] client.add({ "content": "I love Python", "containerTag": containerTag, "metadata": {"role": "user"} }) results = client.search.execute({ "q": "programming", "containerTag": containerTag, "limit": 3 }) ``` -------------------------------- ### Get User Profile - Python Source: https://supermemory.ai/docs/user-profiles Retrieve a user's static facts and dynamic context. Profiles are built automatically as you ingest content; no setup is required. ```python from supermemory import Supermemory client = Supermemory() result = client.profile(container_tag="user_123") print(result.profile.static) # Long-term facts print(result.profile.dynamic) # Recent context ``` -------------------------------- ### Get User Profile - TypeScript Source: https://supermemory.ai/docs/user-profiles Retrieve a user's static facts and dynamic context. Profiles are built automatically as you ingest content; no setup is required. ```typescript import Supermemory from 'supermemory'; const client = new Supermemory(); const { profile } = await client.profile({ containerTag: "user_123" }); console.log(profile.static); // Long-term facts console.log(profile.dynamic); // Recent context ``` -------------------------------- ### Setup OpenClaw Supermemory Plugin Source: https://supermemory.ai/docs/integrations/openclaw Run the setup command for the OpenClaw Supermemory plugin and enter your Supermemory API key when prompted. ```bash openclaw supermemory setup ``` -------------------------------- ### Run Web UI Development Server Source: https://supermemory.ai/docs/memorybench/contributing Navigate to the UI directory and start the development server for the Next.js web interface. ```bash cd ui bun run dev ``` -------------------------------- ### RAG Examples for Customer Support Source: https://supermemory.ai/docs/concepts/memory-vs-rag RAG is suitable for accessing FAQs, troubleshooting guides, and policy documents. It provides answers to common questions and procedural information. ```python # Good for RAG "How do I reset my password?" "What's your return policy?" "Troubleshooting WiFi issues" ``` -------------------------------- ### Quick Start: Add Memory to Mastra Agent Source: https://supermemory.ai/docs/integrations/mastra Wrap your Mastra agent configuration with `withSupermemory` for a zero-config setup. Ensure `containerTag` and `customId` are provided for memory scoping and context. ```typescript import { Agent } from "@mastra/core/agent" import { withSupermemory } from "@supermemory/tools/mastra" import { openai } from "@ai-sdk/openai" // Create agent with memory-enhanced config const agent = new Agent(withSupermemory( { id: "my-assistant", name: "My Assistant", model: openai("gpt-4o"), instructions: "You are a helpful assistant.", }, { containerTag: "user-123", // Required: scopes memories to this user customId: "conv-456", // Required: groups messages for contextual memory mode: "full", } )) const response = await agent.generate("What do you know about me?") ``` -------------------------------- ### Parallel Memory Operations in LangGraph Source: https://supermemory.ai/docs/integrations/langgraph Fetch and categorize memories concurrently. This setup allows multiple operations to run in parallel after the start node and must complete before proceeding to the 'respond' node. ```python from langgraph.graph import StateGraph, START, END graph = StateGraph(State) graph.add_node("retrieve", retrieve_context) graph.add_node("categorize", categorize) graph.add_node("respond", respond) # Both run in parallel after START graph.add_edge(START, "retrieve") graph.add_edge(START, "categorize") # Both must complete before respond graph.add_edge("retrieve", "respond") graph.add_edge("categorize", "respond") graph.add_edge("respond", END) ``` -------------------------------- ### Direct API Calls for Supermemory (Bash) Source: https://supermemory.ai/docs/vibe-coding Examples of direct API calls using curl to interact with Supermemory for adding documents, getting profiles, and searching. Ensure your SUPERMEMORY_API_KEY is set. ```bash # Add memory curl -X POST https://api.supermemory.ai/v3/documents \ -H "x-supermemory-api-key: $SUPERMEMORY_API_KEY" \ -d '{"content": "conversation", "containerTag": "userId"}' # Get profile curl -X POST https://api.supermemory.ai/v4/profile \ -H "x-supermemory-api-key: $SUPERMEMORY_API_KEY" \ -d '{"containerTag": "userId", "q": "search query"}' # Search curl -X POST https://api.supermemory.ai/v4/search \ -H "x-supermemory-api-key: $SUPERMEMORY_API_KEY" \ -d '{"q": "query", "containerTag": "userId", "searchMode": "hybrid"}' ``` -------------------------------- ### User Profiles with Middleware Source: https://supermemory.ai/docs/integrations/ai-sdk Automatically inject user profiles into every LLM call for instant personalization using the `withSupermemory` middleware. This example demonstrates basic setup with required `containerTag` and `customId`. ```APIDOC ## User Profiles with Middleware Automatically inject user profiles into every LLM call for instant personalization. ```typescript import { generateText } from "ai" import { withSupermemory } from "@supermemory/tools/ai-sdk" import { openai } from "@ai-sdk/openai" const modelWithMemory = withSupermemory(openai("gpt-5"), { containerTag: "user-123", customId: "conversation-456", }) const result = await generateText({ model: modelWithMemory, messages: [{ role: "user", content: "What do you know about me?" }] }) ``` ### Required fields Both `containerTag` and `customId` are required. * **`containerTag`** — *who* the memories belong to. Use a stable identifier per user, workspace, or tenant (e.g. `"user-123"`, `"acme-workspace"`). Memory search and writes are scoped to this tag. * **`customId`** — *which conversation* this turn belongs to. Use it to group messages from the same chat session into a single document (e.g. `"chat-2026-04-25"`, a thread ID, or a UUID per session). **Memory saving is enabled by default** (`addMemory: "always"`). New conversations are persisted automatically. To opt out, set `addMemory: "never"`: ```typescript const modelWithMemory = withSupermemory(openai("gpt-5"), { containerTag: "user-123", customId: "conversation-456", addMemory: "never", }) ``` ``` -------------------------------- ### List and Configure GitHub Repositories Source: https://supermemory.ai/docs/connectors/github This section provides code examples for listing available GitHub repositories for a user and then configuring which repositories should be synced. It includes examples in TypeScript, Python, and cURL. ```APIDOC ## List and Configure Repositories ### Description This operation allows you to list available repositories for a user and then configure which specific repositories to sync with Supermemory. This is a crucial step for the GitHub connector as it requires explicit repository selection. ### TypeScript Example ```typescript // List available repositories for the user const repositories = await client.connections.github.listRepositories( connectionId, { page: 1, perPage: 100 } ); // Display repositories in your UI repositories.forEach(repo => { console.log(`${repo.full_name} - ${repo.description}`); console.log(`Private: ${repo.private}`); console.log(`Default branch: ${repo.default_branch}`); console.log(`Last updated: ${repo.updated_at}`); }); // After user selects repositories, configure them await client.connections.github.configure(connectionId, { repositories: [ { id: repo.id, name: repo.full_name, defaultBranch: repo.default_branch } ] }); console.log('Repository sync initiated'); ``` ### Python Example ```python # List available repositories for the user repositories = client.connections.github.list_repositories( connection_id, page=1, per_page=100 ) # Display repositories in your UI for repo in repositories: print(f'{repo.full_name} - {repo.description}') print(f'Private: {repo.private}') print(f'Default branch: {repo.default_branch}') print(f'Last updated: {repo.updated_at}') # After user selects repositories, configure them client.connections.github.configure( connection_id, repositories=[ { 'id': repo.id, 'name': repo.full_name, 'defaultBranch': repo.default_branch } ] ) print('Repository sync initiated') ``` ### cURL Example #### List available repositories ```bash curl -X GET "https://api.supermemory.ai/v3/connections/{connectionId}/resources?page=1&per_page=100" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" ``` #### Configure selected repositories ```bash curl -X POST "https://api.supermemory.ai/v3/connections/{connectionId}/configure" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "resources": [ { "id": 123456789, "name": "your-org/documentation", "defaultBranch": "main" }, { "id": 987654321, "name": "your-org/api-docs", "defaultBranch": "main" } ] }' ``` ### Note Supermemory provides the API endpoints to list and configure repositories. You need to build the UI in your application where your end-users can view their available GitHub repositories, select which repositories to sync, and confirm the selection. This gives you complete control over the user experience and allows you to integrate repository selection seamlessly into your application's workflow. ``` -------------------------------- ### GitHub Repository Selection and Configuration Source: https://supermemory.ai/docs/memory-api/connectors/managing-resources This example demonstrates the full workflow for selecting and configuring a GitHub repository for synchronization. It covers creating a connection, fetching available resources after an OAuth callback, and finally configuring the selected repositories. Ensure you have a valid Supermemory API key and have completed the OAuth flow. ```typescript // 1. Create connection (see creating-connection.mdx) const connection = await client.connections.create('github', { redirectUrl: 'https://yourapp.com/callback', }); // 2. After OAuth callback, fetch available repositories const resourcesResponse = await fetch( `https://api.supermemory.ai/v3/connections/${connection.id}/resources?page=1&per_page=100`, { headers: { 'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`, }, } ); const { resources } = await resourcesResponse.json(); // 3. Display repositories to user and let them select // (Build your UI here) // 4. Configure selected repositories const configureResponse = await fetch( `https://api.supermemory.ai/v3/connections/${connection.id}/configure`, { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ resources: selectedRepositories, // User's selection }), } ); const result = await configureResponse.json(); console.log('Sync initiated:', result.success); ``` ```python # 1. Create connection (see creating-connection.mdx) connection = client.connections.create( 'github', redirect_url='https://yourapp.com/callback' ) # 2. After OAuth callback, fetch available repositories resources_response = requests.get( f"https://api.supermemory.ai/v3/connections/{connection.id}/resources", params={"page": 1, "per_page": 100}, headers={"Authorization": f"Bearer {api_key}"} ) resources = resources_response.json()["resources"] # 3. Display repositories to user and let them select # (Build your UI here) # 4. Configure selected repositories configure_response = requests.post( f"https://api.supermemory.ai/v3/connections/{connection.id}/configure", json={"resources": selected_repositories}, # User's selection headers={"Authorization": f"Bearer {api_key}"} ) result = configure_response.json() print(f"Sync initiated: {result['success']}") ``` ```bash # 1. Create connection (see creating-connection.mdx) # ... (OAuth flow) ... # 2. Fetch available repositories curl -X GET \ "https://api.supermemory.ai/v3/connections/{connectionId}/resources?page=1&per_page=100" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" # 3. Configure selected repositories curl -X POST \ "https://api.supermemory.ai/v3/connections/{connectionId}/configure" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "resources": [ { "id": 123456789, "name": "your-org/documentation", "defaultBranch": "main" } ] }' ``` -------------------------------- ### Define System Prompt for AI Assistant Source: https://supermemory.ai/docs/cookbook/personal-assistant Sets the system prompt for the AI assistant, guiding its behavior to be personalized, proactive in learning user preferences, context-aware, and privacy-respecting. This prompt is injected at the start of every conversation. ```python SYSTEM_PROMPT = """You are a highly personalized AI assistant. MEMORY MANAGEMENT: 1. When users share personal information, store it immediately 2. Search for relevant context before responding 3. Use past conversations to inform current responses Always be helpful while respecting privacy.""" ``` -------------------------------- ### Pipecat Voice Agent with Supermemory Source: https://supermemory.ai/docs/integrations/pipecat A complete example of a Pipecat voice agent integrating Supermemory. This setup includes STT, LLM, TTS services, and configures the Supermemory service with specific input parameters for mode, search limit, and search threshold. ```python import os from fastapi import FastAPI, WebSocket from fastapi.middleware.cors import CORSMiddleware from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import LLMMessagesFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.serializers.protobuf import ProtobufFrameSerializer from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.openai.tts import OpenAITTSService from pipecat.services.openai.stt import OpenAISTTService from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) from supermemory_pipecat import SupermemoryPipecatService from supermemory_pipecat.service import InputParams app = FastAPI() SYSTEM_PROMPT = """You are a helpful voice assistant with memory capabilities. You remember information from past conversations and use it to provide personalized responses. Keep responses brief and conversational.""" async def run_bot(websocket_client, user_id: str, session_id: str): transport = FastAPIWebsocketTransport( websocket=websocket_client, params=FastAPIWebsocketParams( audio_in_enabled=True, audio_out_enabled=True, vad_enabled=True, vad_analyzer=SileroVADAnalyzer(), vad_audio_passthrough=True, serializer=ProtobufFrameSerializer(), ), ) stt = OpenAISTTService(api_key=os.getenv("OPENAI_API_KEY")) llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), model="gpt-5-mini") tts = OpenAITTSService(api_key=os.getenv("OPENAI_API_KEY"), voice="alloy") # Supermemory memory service memory = SupermemoryPipecatService( user_id=user_id, session_id=session_id, params=InputParams( mode="full", search_limit=10, search_threshold=0.1, ), ) context = OpenAILLMContext([{"role": "system", "content": SYSTEM_PROMPT}]) context_aggregator = llm.create_context_aggregator(context) pipeline = Pipeline([ transport.input(), stt, context_aggregator.user(), memory, llm, tts, transport.output(), context_aggregator.assistant(), ]) task = PipelineTask(pipeline, params=PipelineParams(allow_interruptions=True)) @transport.event_handler("on_client_disconnected") async def on_client_disconnected(transport, client): await task.cancel() runner = PipelineRunner(handle_sigint=False) await runner.run(task) @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): await websocket.accept() await run_bot(websocket, user_id="alice", session_id="session-123") if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000) ``` -------------------------------- ### Start the Server Source: https://supermemory.ai/docs/cookbook/perplexity-supermemory Command to run the backend server for the AI search application. ```bash node server.js ``` -------------------------------- ### Quick Start: Chat with Claude Memory Tool Source: https://supermemory.ai/docs/integrations/claude-memory Initialize the Claude memory tool and use it within an Anthropic SDK chat. This example demonstrates sending a message, handling memory tool calls, and optionally sending tool results back to Claude. ```typescript import Anthropic from "@anthropic-ai/sdk" import { createClaudeMemoryTool } from "@supermemory/tools/claude-memory" const anthropic = new Anthropic() const memoryTool = createClaudeMemoryTool(process.env.SUPERMEMORY_API_KEY!, { projectId: "my-app", }) async function chatWithMemory(userMessage: string) { // Send message to Claude with memory tool const response = await anthropic.beta.messages.create({ model: "claude-sonnet-4-5", max_tokens: 2048, messages: [{ role: "user", content: userMessage }], tools: [{ type: "memory_20250818", name: "memory" }], betas: ["context-management-2025-06-27"], }) // Handle any memory tool calls const toolResults = [] for (const block of response.content) { if (block.type === "tool_use" && block.name === "memory") { const toolResult = await memoryTool.handleCommandForToolResult( block.input as any, block.id ) toolResults.push(toolResult) } } // Send tool results back to Claude if needed if (toolResults.length > 0) { const finalResponse = await anthropic.beta.messages.create({ model: "claude-sonnet-4-5", max_tokens: 2048, messages: [ { role: "user", content: userMessage }, { role: "assistant", content: response.content }, { role: "user", content: toolResults }, ], tools: [{ type: "memory_20250818", name: "memory" }], betas: ["context-management-2025-06-27"], }) return finalResponse } return response } // Example usage const response = await chatWithMemory( "Remember that I prefer React with TypeScript for my projects" ) console.log(response.content[0]) ``` -------------------------------- ### Quick Start with JavaScript/TypeScript SDK Source: https://supermemory.ai/docs/integrations/openai Initialize OpenAI client and Supermemory tools for chat completions. Executes tool calls if any are returned. ```typescript import { supermemoryTools, getToolDefinitions, createToolCallExecutor } from "@supermemory/tools/openai" import OpenAI from "openai" const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY!, }) // Get tool definitions for OpenAI const toolDefinitions = getToolDefinitions() // Create tool executor const executeToolCall = createToolCallExecutor(process.env.SUPERMEMORY_API_KEY!, { projectId: "your-project-id", }) // Use with OpenAI Chat Completions const completion = await client.chat.completions.create({ model: "gpt-5", messages: [ { role: "user", content: "What do you remember about my preferences?", }, ], tools: toolDefinitions, }) // Execute tool calls if any if (completion.choices[0]?.message.tool_calls) { for (const toolCall of completion.choices[0].message.tool_calls) { const result = await executeToolCall(toolCall) console.log(result) } } ``` -------------------------------- ### JavaScript/TypeScript SDK Quick Start Source: https://supermemory.ai/docs/integrations/openai Initialize OpenAI client and Supermemory tools, then use them in a chat completion to interact with user memories. ```APIDOC ## JavaScript/TypeScript SDK Quick Start ### Description Initialize OpenAI client and Supermemory tools, then use them in a chat completion to interact with user memories. ### Usage ```typescript import { supermemoryTools, getToolDefinitions, createToolCallExecutor } from "@supermemory/tools/openai" import OpenAI from "openai" const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY!, }) // Get tool definitions for OpenAI const toolDefinitions = getToolDefinitions() // Create tool executor const executeToolCall = createToolCallExecutor(process.env.SUPERMEMORY_API_KEY!, { projectId: "your-project-id", }) // Use with OpenAI Chat Completions const completion = await client.chat.completions.create({ model: "gpt-5", messages: [ { role: "user", content: "What do you remember about my preferences?", }, ], tools: toolDefinitions, }) // Execute tool calls if any if (completion.choices[0]?.message.tool_calls) { for (const toolCall of completion.choices[0].message.tool_calls) { const result = await executeToolCall(toolCall) console.log(result) } } ``` ``` -------------------------------- ### Install OpenClaw Supermemory Plugin Source: https://supermemory.ai/docs/integrations/openclaw Install the OpenClaw Supermemory plugin using the OpenClaw CLI. Restart OpenClaw after installation. ```bash openclaw plugins install @supermemory/openclaw-supermemory ``` -------------------------------- ### Run the Supermemory server Source: https://supermemory.ai/docs/self-hosting/quickstart Start the Supermemory server. This command initializes the graph engine, local embeddings, and saves credentials. ```bash supermemory-server ``` -------------------------------- ### Environment Variables Setup Source: https://supermemory.ai/docs/integrations/openai Sets up necessary environment variables for Supermemory and OpenAI API access. SUPERMEMORY_BASE_URL is optional. ```bash SUPERMEMORY_API_KEY=your_supermemory_key OPENAI_API_KEY=your_openai_key SUPERMEMORY_BASE_URL=https://custom-endpoint.com # optional ``` -------------------------------- ### Install Claude-Supermemory Plugin Source: https://supermemory.ai/docs/integrations/claude-code Install the Claude-Supermemory plugin after adding its marketplace. ```bash # Add the plugin marketplace /plugin marketplace add supermemoryai/claude-supermemory # Install the plugin /plugin install claude-supermemory ``` -------------------------------- ### Install OpenAI Agents and Supermemory SDKs Source: https://supermemory.ai/docs/integrations/openai-agents-sdk Install the necessary Python packages for OpenAI Agents and Supermemory integration. Ensure python-dotenv is also installed for environment variable management. ```bash pip install openai-agents supermemory python-dotenv ``` -------------------------------- ### Run Development Server Source: https://supermemory.ai/docs/cookbook/personal-assistant Command to start the development server for the personal AI assistant project. ```bash npm run dev ``` -------------------------------- ### Run First Benchmark Evaluation Source: https://supermemory.ai/docs/memorybench/quickstart Execute your initial benchmark with specified parameters for project, benchmark, provider, and run name. ```bash bun run src/index.ts run -p supermemory -b longmemeval -j gpt-4o -r my-first-run ```