Supermemory Cartesia SDK
Memory-enhanced voice agents with Supermemory and Cartesia Line.
Installation
pip install supermemory-cartesia
Quick Start
import os
from line.llm_agent import LlmAgent, LlmConfig
from line.voice_agent_app import VoiceAgentApp
from supermemory_cartesia import SupermemoryCartesiaAgent
async def get_agent(env, call_request):
# Use the caller's user ID as the Supermemory namespace
namespace = call_request.metadata.get("user_id", "default-user")
# Create base LLM agent
base_agent = LlmAgent(
model="gemini/gemini-2.5-flash-preview-09-2025",
api_key=os.getenv("GEMINI_API_KEY"),
config=LlmConfig(
system_prompt="You are a helpful voice assistant with memory.",
introduction="Hello! Great to talk with you again!"
)
)
# Wrap with Supermemory
memory_agent = SupermemoryCartesiaAgent(
agent=base_agent,
api_key=os.getenv("SUPERMEMORY_API_KEY"),
namespace=namespace,
custom_id=call_request.call_id,
)
return memory_agent
# Create voice agent app
app = VoiceAgentApp(get_agent=get_agent)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
Configuration
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
agent |
LlmAgent | Yes | The Cartesia Line agent to wrap |
namespace |
str | Yes | Supermemory namespace for memory scoping (e.g., user ID) |
custom_id |
str | Yes | Document ID that groups a conversation's messages into one document |
add_memory |
Literal | No | Memory persistence mode: "always" (default) or "never" |
api_key |
str | No | Supermemory API key (or set SUPERMEMORY_API_KEY env var) |
config |
MemoryConfig | No | Advanced configuration |
base_url |
str | No | Custom API endpoint |
container_tag still works as a deprecated alias for namespace; container_tags is deprecated and ignored.
Advanced Configuration
from supermemory_cartesia import SupermemoryCartesiaAgent
memory_agent = SupermemoryCartesiaAgent(
agent=base_agent,
namespace="user-123",
custom_id="conversation-456",
add_memory="always", # "always" (default) or "never"
config=SupermemoryCartesiaAgent.MemoryConfig(
search_limit=10, # Max memories to retrieve
search_threshold=0.1, # Similarity threshold
mode="full", # "profile", "query", or "full"
system_prompt="Based on previous conversations, I recall:\n\n",
),
)
# Read-only mode - retrieve memories but don't save new ones
read_only_agent = SupermemoryCartesiaAgent(
agent=base_agent,
namespace="user-123",
custom_id="conversation-456",
add_memory="never", # Only retrieve, don't save
)
Memory Modes
| Mode | Static Profile | Dynamic Profile | Search Results |
|---|---|---|---|
"profile" |
Yes | Yes | No |
"query" |
No | No | Yes |
"full" |
Yes | Yes | Yes |
How It Works
- Intercepts events - Listens for
UserTurnEndedevents from Cartesia Line - Retrieves memories - Fetches the profile (
POST /ns/{namespace}/profile) and searches with the user's message (POST /ns/{namespace}/search) - Enriches context - Passes memories as non-persistent context for the current turn
- Stores messages - Sends conversation to Supermemory (background, non-blocking)
- Passes to agent - Forwards enriched event to wrapped LlmAgent
What Gets Stored
User and assistant messages are appended to one document per conversation with POST /ns/{namespace}/document:
{
"content": "User: What's the weather?\nAssistant: It's sunny today!",
"id": "conversation-456",
"metadata": { "platform": "cartesia" }
}
Architecture
Cartesia Line uses an event-driven architecture:
User Speaks (Audio)
↓
[Ink STT] → Automatic speech recognition
↓
UserTurnEnded Event {content: "user message", history: [...]}
↓
┌──────────────────────────────────────────────┐
│ SUPERMEMORY CARTESIA AGENT (Wrapper) │
│ │
│ process(env, event): │
│ 1. Intercept UserTurnEnded │
│ 2. Extract user message │
│ 3. Query Supermemory API │
│ 4. Add memories as per-turn context │
│ 5. Pass to wrapped LlmAgent │
│ 6. Store conversation (async background) │
└──────────────────────────────────────────────┘
↓
AgentSendText Event {text: "response"}
↓
[Sonic TTS] → Ultra-fast speech synthesis
↓
Audio Output
Comparison with Pipecat SDK
| Aspect | Pipecat | Cartesia Line |
|---|---|---|
| Integration Pattern | Extends FrameProcessor |
Wrapper around LlmAgent |
| Event Handling | process_frame() method |
process() method |
| Events | LLMContextFrame, LLMMessagesFrame |
UserTurnEnded, CallStarted |
| Context Object | LLMContext.get_messages() |
event.history |
| Memory Injection | Modify context.add_message() |
Pass per-turn context |
Full Example with Tools
import os
from line.llm_agent import LlmAgent, LlmConfig, loopback_tool
from line.voice_agent_app import VoiceAgentApp
from supermemory_cartesia import SupermemoryCartesiaAgent
# Define custom tools
@loopback_tool
async def get_weather(ctx, location: str) -> str:
"""Get current weather for a location"""
return f"The weather in {location} is sunny, 72°F"
async def get_agent(env, call_request):
namespace = call_request.metadata.get("user_id", "default-user")
# Create LLM agent with tools
base_agent = LlmAgent(
model="gemini/gemini-2.5-flash-preview-09-2025",
api_key=os.getenv("GEMINI_API_KEY"),
tools=[get_weather],
config=LlmConfig(
system_prompt="You are a personal assistant with memory and tools.",
introduction="Hi! How can I help you today?"
)
)
# Wrap with Supermemory
memory_agent = SupermemoryCartesiaAgent(
agent=base_agent,
api_key=os.getenv("SUPERMEMORY_API_KEY"),
namespace=namespace,
custom_id=call_request.call_id,
config=SupermemoryCartesiaAgent.MemoryConfig(
mode="full",
search_limit=15,
search_threshold=0.15,
)
)
return memory_agent
app = VoiceAgentApp(get_agent=get_agent)
Development
# Clone repository
git clone https://github.com/supermemoryai/supermemory
cd supermemory/packages/cartesia-sdk-python
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black .
isort .
License
MIT
Metadata
Release files for supermemory-cartesia 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| supermemory_cartesia-0.2.0.tar.gz | 15.0 kB | With provenance | Details for supermemory_cartesia-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| supermemory_cartesia-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for supermemory_cartesia-0.2.0-py3-none-any.whl |
Total release size: 28.7 kB
Release files / supermemory_cartesia-0.2.0.tar.gz
| Download URL | supermemory_cartesia-0.2.0.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe038044a0b192f36d62127196e966fb0b55dbcaaed04c44f2d13d4aa63b04ef
|
|
BLAKE2b-256 checksum How to use checksums |
95d75315ff478573cf8aad108fbda61c03348a7df392b0dfe503abaa6e158b6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / supermemory_cartesia-0.2.0-py3-none-any.whl
| Download URL | supermemory_cartesia-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7bded4a58a889c43f55134a609c97e2b720eec7e9475785f34f21af8111deb30
|
|
BLAKE2b-256 checksum How to use checksums |
b97bf8a015ca1f49538c2690be31813bb10b0c83ee0dab9418a225392f2f0c71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for supermemory-cartesia 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for supermemory_cartesia-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.