Skip to content

Reference

Python SDK reference

ItemValue
PyPI packagesurrealdb-memory (its own distribution, pulled in by the surrealdb[memory] extra)
Installpip install --pre 'surrealdb[memory]'
Importfrom surrealdb.memory import Memory, AsyncMemory
Submodulesurrealdb.memory (models, namespaces, errors)

The client is versioned independently of the driver, so the extra pins >=, not ==; surrealdb alone installs the driver without it.

Memory(context: str, endpoint: str, api_key: str,
    timeout: float = 30.0, max_retries: int = 3)
AsyncMemory(...)  # same arguments; methods are async

Requests use Authorization: Bearer <api_key>. Optional on_behalf_of on every verb sets X-Spectron-On-Behalf-Of for delegation.

MethodHTTP
remember(...)POST /api/v1/{ctx}/facts
remember_many(...)POST /api/v1/{ctx}/facts/batch
recall(...)POST /api/v1/{ctx}/query
forget(...)POST /api/v1/{ctx}/forget
chat(...)POST /api/v1/{ctx}/chat (SSE when stream=True)
consolidate(...)POST /api/v1/{ctx}/consolidate
reflect(...)POST /api/v1/{ctx}/reflect
elaborate(...)POST /api/v1/{ctx}/elaborate
query_context(...)POST /api/v1/{ctx}/context
inspect(ref, ...)GET /api/v1/{ctx}/inspect
state()GET /api/v1/{ctx}/state
whoami()GET /api/v1/{ctx}/me
profile()GET /api/v1/{ctx}/profile
audit(...)GET /api/v1/{ctx}/audit
health()GET /api/v1/health (not context-scoped)
NamespaceMethods
documentsupload, get, delete, list, query, fetch_raw, reprocess, recompute_links, chunks
documents.keywordslist, get, search, for_document
sessionscreate, delete, context, turns
entitieslist, get, delete, history
scopesregister, list, delete, forget
principalslist, get, grant, revoke, effective
keyscreate, list, delete, rotate
traceslist, get, stats
lifecycledecay, expire, fsck

Full REST tables: REST API.

Import from surrealdb.memory:

ModelUsed for
RememberResponse, RememberBatchResponse, ExtractionResultFact ingest
RecallResponse, RecallHitSemantic recall
ChatResponse, ChatChunkChat (streaming chunks)
ContextQueryResponseComposed context string
StateResponseWorking-memory snapshot
UploadResponse, Document, DocumentPage, Chunk, ChunkPageDocument corpus
DocumentQueryResponse, DocumentQueryHitDocument search
Keyword, KeywordSearchResponse, …Keyword index
Session, Turn, TurnListResponseSessions
EntityDetail, EntityListResponse, …Knowledge graph entities
WhoamiResponse, ProfileResponseCaller identity
TraceRecord, AuditResponse, FsckReportObservability / maintenance

Nested graph and extraction payloads may remain dict values where the server shape evolves (“slim model” convention).

ClassHTTP
MemoryServiceErrorBase
MemoryAPIErrorAny non-2xx without a subclass (status_code, message, trace_id, body)
MemoryAuthError401
MemoryScopeError403
MemoryNotFoundError404

Errors and retries

Python SDK

Was this page helpful?