Skip to content

Reference

Swift SDK reference

The AgentMemory product in surrealdb.swift is the Swift client for SurrealDB Agent Memory. This page covers adding the package and configuring a client.

ItemValue
Packagesurrealdb.swift
ProductAgentMemory
Install.product(name: "AgentMemory", package: "surrealdb.swift")
Importimport AgentMemory
let memory = try AgentMemory(
    context: "acme-prod",
    endpoint: "https://api.memory.example",
    apiKey: "sk-spec-..."
)
SettingPurpose
contextPath segment after /api/v1/
endpointBase URL (no trailing slash)
apiKeyContext API key
Authorization: Bearer <key>
SDK areaHTTP
FactsPOST /api/v1/{ctx}/facts, POST .../facts/batch
Query / contextPOST .../query, POST .../context
ChatPOST .../chat
DocumentsPOST/GET/DELETE .../documents
SessionsPOST/GET/DELETE .../sessions
EntitiesGET/DELETE .../entities/{type}/{name}
Governance.../scopes, .../principals, .../keys

Full tables: REST API.

  • Pass onBehalfOf: to act as another principal. It is sent as the X-Spectron-On-Behalf-Of header.

  • Writes carry an Idempotency-Key header for safe retry deduplication.

All failures throw AgentMemoryError with fields status, title, detail, retryAfter, typeURI, instance and extensions. The kind maps to .base, .auth, .scope, .notFound, .validation, .rateLimit or .server. See Errors.

See Swift SDK for usage patterns.

Was this page helpful?