Core Concepts
Persistent Memory
Long-term storage referenced via
memory_id. Backed by the Unified 8-Operator Surface (store, retrieve, update, delete, merge, summarize, pin, verify).Context
Assembled data passed via
context object. Token-budget-aware context assembly for LLM system prompts via POST /api/v1/context/retrieve.Users & Sessions
Scoped via
user_id identifiers. Enterprise multi-tenancy enforced via strict namespace isolation (X-Namespace-Prefix header) and automated PHI/PII privacy redaction.Retrieval
Query via
client.search(). Hybrid search engine combining dense vector similarity (HNSW via pgvector) and BM25 trigram full-text search, fused using Reciprocal Rank Fusion (RRF_K=30).Knowledge
Structured domain data accessible through
knowledge.query(). PiyGraph Knowledge Graph tracking real-world validity (valid_at) separately from system recording time (system_at).Architecture
Request flows from your application through the PiyAPI Gateway to the Memory Engine, Cognitive Engine, and Integrations, then down to the Vector Substrate (pgvector + Redis).PiyAPI separates persistent memory from the application logic so your AI system can retrieve relevant context when it needs it.
System Architecture
Initialize the Client
Store and Retrieve Context
1
Create or initialize the client
Use the TypeScript SDK, Python SDK, or cURL to authenticate with your API key.
2
Send conversational information
Stream or batch events and messages into the system.
3
Store relevant memory
Persist facts, preferences, and context as tagged memory records.
4
Retrieve context when needed
Run a hybrid search query to pull back the most relevant memory.
5
Pass retrieved context to the model
Include the assembled context in the LLM prompt for generation.
Store a memory
example.js
Retrieve via Hybrid Search
example.js
Response
How PiyAPI Works
What’s Next?
Explore the architecture
Understand how PiyGraph, bitemporal
valid_at/system_at tracking, and Speculative Memory Branching are structured.Store your first memory
Create and persist your first record using
POST /api/v1/memories or the TypeScript SDK.Build an AI agent
Wire up memory and context using our MCP Server (
@piyapi/mcp-server, 30 tools, 3 resources, 3 prompts).Explore the API
Browse the full REST reference and OpenAPI JSON spec at
https://api.piyapi.cloud/docs/raw/openapi.json.