Skip to content

Go SDK

The MemoryLayer Go SDK (github.com/scitrera/memorylayer/memorylayer-sdk-go) is a Go client for the MemoryLayer server. It mirrors the Python and TypeScript SDKs with one Client type, uses only the Go standard library, and is Apache-2.0 licensed.

Installation

Terminal window
go get github.com/scitrera/memorylayer/memorylayer-sdk-go
import memorylayer "github.com/scitrera/memorylayer/memorylayer-sdk-go"

The SDK requires Go 1.25.14 or newer. Releases are tagged as memorylayer-sdk-go/vX.Y.Z (currently v0.2.0). The optional Aether transport is a separate module, so HTTP-only callers don’t pull in the Aether SDK’s gRPC dependencies:

Terminal window
go get github.com/scitrera/memorylayer/memorylayer-sdk-go/aether

Features

  • Standard library only — The core module uses net/http and encoding/json, with no third-party dependencies
  • Context-first API — Every method takes a context.Context for cancellation and deadlines
  • Memory Operations — Remember, recall (including temporal filters and token budgets), reflect, forget, decay, browse and iterate
  • Versioned Memories — Conditional create/replace/delete/restore with ETags and idempotency keys, plus revision history
  • Relationship Graph — Associate, update, delete, and traverse typed relationships
  • Entity Registry — List, resolve, and merge canonical entities
  • Sessions — Working memory, commit, briefings, checkpoints, context packs, and context deltas
  • Chat Threads — User- or workspace-owned threads, sub-threads, and decomposition into memories
  • Namespaces — Skills, McpServers, Kb, Rpg, PromptNotes, AgentSpecifications, RefinementRecords, and WorkspaceViews
  • On-Behalf-Of — ActingFor / ForWorkspace proxies and per-call Authority
  • Pluggable Transport — Default HTTP transport with retries, or the Aether transport module
  • Typed Errors — Every error embeds *APIError, with errors.As-friendly types

Quick Start

package main
import (
"context"
"fmt"
"log"
memorylayer "github.com/scitrera/memorylayer/memorylayer-sdk-go"
)
func main() {
client, err := memorylayer.NewClient(
memorylayer.WithBaseURL("http://localhost:61001"),
memorylayer.WithWorkspaceID("my-workspace"),
)
if err != nil {
log.Fatal(err)
}
defer client.Close()
ctx := context.Background()
_, err = client.Remember(ctx, "User prefers Go for backend services", memorylayer.RememberOptions{
Type: memorylayer.MemoryTypeSemantic,
Subtype: string(memorylayer.MemorySubtypePreference),
Importance: 0.8,
Tags: []string{"preferences"},
})
if err != nil {
log.Fatal(err)
}
results, err := client.Recall(ctx, "what language does the user prefer?", memorylayer.RecallOptions{Limit: 5})
if err != nil {
log.Fatal(err)
}
for _, m := range results.Memories {
fmt.Println(m.Content)
}
}

Configuration

NewClient takes functional options:

client, err := memorylayer.NewClient(
memorylayer.WithBaseURL("http://localhost:61001"), // Default (memorylayer.DefaultBaseURL)
memorylayer.WithAPIKey(os.Getenv("MEMORYLAYER_API_KEY")),
memorylayer.WithWorkspaceID("my-workspace"),
memorylayer.WithSessionID("sess_123"), // Optional active session
memorylayer.WithTimeout(30*time.Second), // Default 30s
memorylayer.WithMaxRetries(3), // Default 3; 0 disables
)

See Client Construction for the full option list.

Next Steps

Other SDKs

  • Python SDK — memorylayer-client (async and sync)
  • TypeScript SDK — @scitrera/memorylayer-sdk for Node.js and browsers