PowerMem Go SDK
January 31, 2026 ยท View on GitHub
Official Go SDK for PowerMem.
โจ Features
- ๐ Simple Integration: Lightweight SDK with automatic
.envconfiguration loading - ๐ง Intelligent Memory: Automatic fact extraction, duplicate detection, and memory merging
- ๐ Ebbinghaus Curve: Time-decay weighting based on cognitive science principles
- ๐ค Multi-Agent Support: Independent memory spaces with flexible sharing and isolation
- โก Async Operations: Full async/await support for high-performance scenarios
- ๐จ Multimodal Memory: Support for text, images, and audio content
- ๐พ Flexible Storage: SQLite for development, PostgreSQL/OceanBase for production
- ๐ Hybrid Retrieval: Vector search, full-text search, and graph traversal
๐ฆ Installation
go get github.com/oceanbase/powermem-go
๐ Quick Start
Prerequisites
- Go 1.19 or higher
- API keys for LLM and embedding providers (OpenAI, Qwen, etc.)
- Vector database (SQLite/OceanBase/PostgreSQL)
Basic Usage
โจ Simplest Way: Create memory from .env file automatically!
- Create a
.envfile (see.env.examplefor reference):
# LLM Configuration
LLM_PROVIDER=qwen
LLM_API_KEY=your_api_key_here
LLM_MODEL=qwen-plus
# Embedding Configuration
EMBEDDER_PROVIDER=qwen
EMBEDDER_API_KEY=your_api_key_here
EMBEDDER_MODEL=text-embedding-v4
# Database Configuration (alternative to PostgreSQL/OceanBase)
DATABASE_PROVIDER=sqlite
SQLITE_COLLECTION=memories
- Use the SDK:
package main
import (
"context"
"fmt"
"log"
powermem "github.com/oceanbase/powermem-go/pkg/core"
)
func main() {
// Load configuration from .env file
config, err := powermem.LoadConfigFromEnv()
if err != nil {
log.Fatal(err)
}
// Create memory client
client, err := powermem.NewClient(config)
if err != nil {
log.Fatal(err)
}
defer client.Close()
ctx := context.Background()
userID := "user123"
// Add memory
memory, err := client.Add(ctx, "User likes coffee",
powermem.WithUserID(userID),
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Added memory: %s (ID: %d)\n", memory.Content, memory.ID)
// Search memories
results, err := client.Search(ctx, "user preferences",
powermem.WithUserIDForSearch(userID),
powermem.WithLimit(10),
)
if err != nil {
log.Fatal(err)
}
fmt.Println("\nSearch results:")
for _, result := range results {
fmt.Printf("- %s (score: %.4f)\n", result.Memory, result.Score)
}
}
๐ Documentation
-
API Reference - Complete API documentation
-
Examples - Working code examples for various scenarios
๐ง Configuration
Environment Variables
PowerMem supports automatic configuration loading from .env files. Copy .env.example to .env and configure.
cp .env.example .env
Programmatic Configuration
You can also create configuration programmatically:
config := &powermem.Config{
LLM: powermem.LLMConfig{
Provider: "qwen",
APIKey: "your_api_key",
Model: "qwen-plus",
},
Embedder: powermem.EmbedderConfig{
Provider: "qwen",
APIKey: "your_api_key",
Model: "text-embedding-v4",
},
VectorStore: powermem.VectorStoreConfig{
Provider: "sqlite",
CollectionName: "memories",
},
}
Supported Providers
LLM Providers:
- OpenAI (GPT-4, GPT-3.5)
- Qwen (Qwen-Plus, Qwen-Turbo)
- Anthropic (Claude)
- DeepSeek
- Ollama (local)
Embedding Providers:
- OpenAI
- Qwen
Vector Stores:
- SQLite (development)
- PostgreSQL (production)
- OceanBase (production, recommended)
๐งช Testing
Run tests:
# Run all tests
make test
๐ ๏ธ Development
# Install dependencies
make install
# Run linter
make lint
# Build project
make build
# Build examples
make examples
๐ License
Apache License 2.0. See LICENSE for details.
๐ Links
- Main Repository - Python SDK and documentation
- OceanBase - Recommended production database
- Documentation - Comprehensive guides and examples