smaran-cartesia
Memory-enhanced voice agents with Smaran and Cartesia Line.
Installation
pip install smaran-cartesia
Quick Start
import os
from line.llm_agent import LlmAgent, LlmConfig
from line.voice_agent_app import VoiceAgentApp
from smaran_cartesia import SmaranCartesiaAgent
async def get_agent(env, call_request):
user_id = call_request.metadata.get("user_id", "default-user")
base_agent = LlmAgent(
model="gemini/gemini-2.5-flash-preview-09-2025",
config=LlmConfig(
system_prompt="You are a helpful voice assistant with memory.",
introduction="Hello! Great to talk with you again!"
)
)
memory_agent = SmaranCartesiaAgent(
agent=base_agent,
api_key=os.getenv("SMARAN_API_KEY"),
base_url=os.getenv("SMARAN_URL"),
user_id=user_id,
session_id=call_request.call_id,
)
return memory_agent
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 |
user_id |
str | Yes | User identifier memories are scoped to |
session_id |
str | Yes | Conversation/call ID, used to group saved messages |
api_key |
str | No | Smaran API key (or set SMARAN_API_KEY env var) |
base_url |
str | No | Smaran API base URL (or set SMARAN_URL env var) |
config |
MemoryConfig | No | Advanced configuration |
Advanced Configuration
from smaran_cartesia import SmaranCartesiaAgent
memory_agent = SmaranCartesiaAgent(
agent=base_agent,
user_id="user-123",
session_id="conversation-456",
config=SmaranCartesiaAgent.MemoryConfig(
search_limit=5, # Max memories to recall per turn
system_prompt="Based on previous conversations:\n\n",
save_memory=True, # Save new memories after each turn
),
)
How It Works
- Intercepts events — listens for
UserTurnEndedevents from Cartesia Line - Recalls memories — queries Smaran's
/v1/recallAPI with the user's message - Enriches context — injects recalled facts into the agent's system prompt
- Saves messages — sends conversation turns to Smaran's
/v1/memoriesAPI in the background, non-blocking - Passes to agent — forwards the enriched event to the wrapped
LlmAgent
Architecture
Cartesia Line uses an event-driven architecture:
User Speaks (Audio)
↓
[Ink STT] → Automatic speech recognition
↓
UserTurnEnded Event {content: "user message", history: [...]}
↓
┌──────────────────────────────────────────────┐
│ SMARAN CARTESIA AGENT (Wrapper) │
│ │
│ process(env, event): │
│ 1. Intercept UserTurnEnded │
│ 2. Extract user message │
│ 3. Recall from Smaran │
│ 4. Inject recalled memories into prompt │
│ 5. Pass to wrapped LlmAgent │
│ 6. Save conversation (async background) │
└──────────────────────────────────────────────┘
↓
AgentSendText Event {text: "response"}
↓
[Sonic TTS] → Ultra-fast speech synthesis
↓
Audio Output
Comparison with the Pipecat SDK
| Aspect | Pipecat | Cartesia Line |
|---|---|---|
| Integration pattern | Extends FrameProcessor |
Wrapper around LlmAgent |
| Event handling | process_frame() method |
process() method |
| Events | LLMContextFrame |
UserTurnEnded, CallStarted |
| Context object | LLMContext.get_messages() |
event.history |
Development
git clone https://github.com/Ayushpani/smaran
cd smaran/packages/cartesia-sdk-python
pip install -e ".[dev]"
pytest
License
MIT
Metadata
Release files for smaran-cartesia 0.1.1
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 |
|---|---|---|---|---|
| smaran_cartesia-0.1.1.tar.gz | 7.0 kB | With provenance | Details for smaran_cartesia-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smaran_cartesia-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for smaran_cartesia-0.1.1-py3-none-any.whl |
Total release size: 15.1 kB
Release files / smaran_cartesia-0.1.1.tar.gz
| Download URL | smaran_cartesia-0.1.1.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
963819978d62cde77e1a9cec383c00e5f063d1eb68c4ccbcdca3578ff6a1434c
|
|
BLAKE2b-256 checksum How to use checksums |
20fe7afe3a7fc97fa124e1ddec9cdd88b18d4b2b0a0d8eab3dd6bf6390e08075
|
| 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 Sep 5, 2026.
Transparency logRelease files / smaran_cartesia-0.1.1-py3-none-any.whl
| Download URL | smaran_cartesia-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d371df88c8842d3864e2dcc0c482b8313bfcaf72eef1f7ca2a0c105ac85f1da0
|
|
BLAKE2b-256 checksum How to use checksums |
238225a5905b37b205aa44aa79ad8d7812f080b7ec093ddaa93cd4299f9bf84c
|
| 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 Sep 5, 2026.
Transparency logSecurity for smaran-cartesia 0.1.1
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for smaran_cartesia-0.1.1.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 Sep 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.