The AgentMemory product in surrealdb.swift is the Swift client for SurrealDB Agent Memory. This page covers adding the package and configuring a client.
| Item | Value |
|---|---|
| Package | surrealdb.swift |
| Product | AgentMemory |
| Install | .product(name: "AgentMemory", package: "surrealdb.swift") |
| Import | import AgentMemory |
Configuration
let memory = try AgentMemory(
context: "acme-prod",
endpoint: "https://api.memory.example",
apiKey: "sk-spec-..."
)| Setting | Purpose |
|---|---|
context | Path segment after /api/v1/ |
endpoint | Base URL (no trailing slash) |
apiKey | Context API key |
Auth header
Authorization: Bearer <key>Core operations (REST mapping)
| SDK area | HTTP |
|---|---|
| Facts | POST /api/v1/{ctx}/facts, POST .../facts/batch |
| Query / context | POST .../query, POST .../context |
| Chat | POST .../chat |
| Documents | POST/GET/DELETE .../documents |
| Sessions | POST/GET/DELETE .../sessions |
| Entities | GET/DELETE .../entities/{type}/{name} |
| Governance | .../scopes, .../principals, .../keys |
Full tables: REST API.
Delegation and idempotency
Pass
onBehalfOf:to act as another principal. It is sent as theX-Spectron-On-Behalf-Ofheader.Writes carry an
Idempotency-Keyheader for safe retry deduplication.
Errors
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.
User guide
See Swift SDK for usage patterns.