Quick Start
Get Astrocyte running — pick the deployment model that fits your stack and follow the commands.
Choose your deployment model
Section titled “Choose your deployment model”Embed Astrocyte directly in your Python application. No separate server — memory operations run in-process.
Best for: prototyping, single-process agents, notebooks, custom orchestrators.
# Recommended — installs astrocyte + astrocyte-postgres (the default stack).pip install astrocyte-stack
# Or pick a specific backend:pip install "astrocyte[postgres]" # same as above, explicitpip install "astrocyte[qdrant]" # Qdrant vector storepip install "astrocyte[neo4j]" # Neo4j graph storepip install "astrocyte[elasticsearch]" # Elasticsearch document store
# Or in-memory only (tests, evals, embedded use; no DB required):pip install astrocyteThe default stack (astrocyte-stack) is what the rest of this guide assumes.
See ecosystem and packaging for the full
matrix of optional dependencies.
from astrocyte import Astrocyte
brain = Astrocyte.from_config("astrocyte.yaml")
await brain.retain("Calvin prefers dark mode.", bank_id="user-123")hits = await brain.recall("What theme does Calvin prefer?", bank_id="user-123")The library alone does not start an HTTP server. See the architecture overview and provider SPI for wiring storage backends and LLM providers.
Run Astrocyte as a REST API (astrocyte-gateway-py) with Docker Compose. Agents call /v1/retain, /v1/recall, /v1/reflect over HTTP. No repo clone needed — pull the published images from GHCR.
Best for: multi-agent deployments, microservice architectures, teams that want a shared memory service.
Save as docker-compose.yml — no repo clone needed, images are pulled from GHCR:
services: postgres: image: ghcr.io/astrocyteai/astrocyte/astrocyte-postgres:latest environment: POSTGRES_USER: astrocyte POSTGRES_PASSWORD: astrocyte POSTGRES_DB: astrocyte ports: ["5433:5432"] healthcheck: test: ["CMD-SHELL", "pg_isready -U astrocyte"] interval: 3s retries: 5
gateway: image: ghcr.io/astrocyteai/astrocyte/astrocyte-gateway-py:latest environment: DATABASE_URL: postgresql://astrocyte:astrocyte@postgres:5432/astrocyte ASTROCYTE_VECTOR_STORE: postgres ASTROCYTE_GRAPH_STORE: age OPENAI_API_KEY: ${OPENAI_API_KEY} ports: ["8080:8080"] depends_on: postgres: condition: service_healthyStart it:
OPENAI_API_KEY=sk-... docker compose upExercise the API end-to-end:
# 1. Health check (also confirms the DB is reachable)curl http://127.0.0.1:8080/health
# 2. Retain a memorycurl -X POST http://127.0.0.1:8080/v1/retain \ -H "Content-Type: application/json" \ -d '{"content": "Calvin prefers dark mode.", "bank_id": "user-123"}'
# 3. Recall itcurl -X POST http://127.0.0.1:8080/v1/recall \ -H "Content-Type: application/json" \ -d '{"query": "What theme does Calvin prefer?", "bank_id": "user-123"}'The retain/recall/reflect triple is just the entry point. The full surface is browsable at /docs on the running gateway:
- Memory lifecycle:
/v1/forget,/v1/history,/v1/compile - Mental models:
/v1/mental-models[/{id}](CRUD),/v1/mental-models/{id}/refresh - Knowledge graph:
/v1/graph/search,/v1/graph/neighbors - Governance & compliance:
/v1/dsar/forget_principal,/v1/audit,/v1/admin/banks/{id}/hold(legal holds) - Portability:
/v1/export,/v1/import(AMA archives) - Ingestion:
/v1/ingest/webhook/{source_id} - Ops:
/v1/admin/lifecycle,/v1/admin/banks/health
See Production-grade HTTP service for auth, TLS, rate limits, and observability.
Add long-term memory to LLM calls routed through an existing API gateway — zero agent code changes. Each plugin intercepts OpenAI-compatible /chat/completions requests and transparently calls Astrocyte for recall (pre-hook) and retain (post-hook).
Best for: organizations already routing LLM traffic through Kong, APISIX, or Azure APIM.
Requires: a running standalone gateway (see the Standalone Gateway tab) that the plugin calls via HTTP.
# Copy plugin files to your Kong plugins directorycp gateway-plugins/kong/handler.lua /path/to/kong/plugins/astrocyte/cp gateway-plugins/kong/schema.lua /path/to/kong/plugins/astrocyte/
# Enable via Admin APIcurl -X POST http://localhost:8001/services/my-llm/plugins \ -d "name=astrocyte" \ -d "config.astrocyte_url=http://astrocyte-gateway:8900" \ -d "config.default_bank_id=shared"See gateway-plugins/kong/README.md for declarative config and full options.
# Copy plugin to APISIX plugins directorycp gateway-plugins/apisix/astrocyte.lua /path/to/apisix/plugins/
# Enable via Admin APIcurl -X PUT http://127.0.0.1:9180/apisix/admin/routes/1 \ -H "X-API-KEY: $APISIX_ADMIN_KEY" \ -d '{ "uri": "/v1/chat/completions", "upstream": { "nodes": { "llm-api:443": 1 }, "type": "roundrobin" }, "plugins": { "astrocyte": { "astrocyte_url": "http://astrocyte-gateway:8900", "default_bank_id": "shared" } } }'See gateway-plugins/apisix/README.md for declarative YAML config.
cd gateway-plugins/azure-apim
# Interactive — prompts for deployment method and config./deploy.sh
# Or pass flags directly (Bicep example)./deploy.sh --method bicep \ --apim-name my-apim \ --resource-group my-rg \ --astrocyte-url https://astrocyte.internal:8900 \ --api-key sk-...Supports Bicep, Terraform, APIOps, and portal (manual paste). After deployment, add the fragments to your API policy:
<policies> <inbound> <base /> <include-fragment fragment-id="astrocyte-recall-inject" /> </inbound> <outbound> <base /> <include-fragment fragment-id="astrocyte-retain-extract" /> </outbound></policies>See gateway-plugins/azure-apim/README.md for all deployment methods.
Limitations: Gateway plugins are request-scoped. They support recall and retain but not reflect, event streams, or poll connectors. See Gateway edge & API gateways for the full comparison.
Prerequisites
Section titled “Prerequisites”- Python 3.11+ (library and standalone gateway)
- Docker and Docker Compose (recommended for standalone gateway)
- Kong, APISIX, or Azure APIM (gateway plugin mode only)
Wire an AI agent
Section titled “Wire an AI agent”Astrocyte does not run the agent loop (tools, checkpoints, multi-step graphs). Your framework does. Integrations map each framework’s memory hooks to retain / recall / reflect through the same policy layer — see agent framework middleware for the full matrix.
from astrocyte import Astrocytefrom astrocyte.integrations.langgraph import AstrocyteMemory
brain = Astrocyte.from_config("astrocyte.yaml")memory = AstrocyteMemory(brain, bank_id="user-123")
await memory.save_context( inputs={"question": "Theme preference?"}, outputs={"answer": "Calvin prefers dark mode."}, thread_id="thread-abc",)vars_for_prompt = await memory.load_memory_variables({})# Run the Astrocyte MCP server — agents connect via MCP protocolfrom astrocyte import Astrocytefrom astrocyte.config import load_configfrom astrocyte.mcp import create_mcp_server
config = load_config("astrocyte.yaml")brain = Astrocyte(config)server = create_mcp_server(brain, config)The CLI form is usually simpler for local agents:
astrocyte-mcp --config astrocyte.yamlExposes memory_retain, memory_recall, memory_reflect, and optionally memory_forget, graph, compile, and admin tools depending on mcp: configuration.
from astrocyte import Astrocytefrom astrocyte.integrations.crewai import AstrocyteCrewMemory
brain = Astrocyte.from_config("astrocyte.yaml")memory = AstrocyteCrewMemory(brain, bank_id="team-support")
# Use as crew memorycrew = Crew(agents=[support_agent], memory=memory)Per-framework guides live under Integrations (LangGraph, CrewAI, Pydantic AI, OpenAI Agents SDK, Claude Agent SDK, MCP, and 12 more).
Declarative routing with MIP
Section titled “Declarative routing with MIP”The Memory Intent Protocol (MIP) lets you declare routing rules so Astrocyte decides which bank, tags, and policies to apply — without routing logic in your application code.
# mip.yaml — route student answers to per-student banksrules: - name: student-answer match: all: - content_type: student_answer - metadata.student_id: present action: bank: "student-{metadata.student_id}" tags: ["{metadata.topic}"]brain = Astrocyte.from_config("astrocyte.yaml")
# MIP routes this to bank "student-stu-42" with tag "algebra"await brain.retain( "2x + 3 = 7, so x = 2", bank_id="default", # MIP overrides this metadata={"student_id": "stu-42", "topic": "algebra"}, content_type="student_answer",)Mechanical rules resolve deterministically with zero LLM cost. When no rule matches, an optional intent layer can ask an LLM to decide. See the MIP developer guide for the full match DSL, PII lockdown rules, compliance profiles, and testing recipes.
Next steps
Section titled “Next steps”- API reference: Memory API reference — full retain/recall/reflect/forget signatures and examples.
- Configure everything: Configuration reference — complete
astrocyte.yamlschema. - Organize banks: Bank management — multi-bank queries, tenant patterns, lifecycle.
- MIP routing rules: MIP developer guide — write, test, and debug routing rules.
- Agent + memory patterns: 100 Agents in 100 Days.
- Operate and harden HTTP: Production-grade HTTP service (security, auth, grants, observability).
- Gateway edge patterns: Gateway edge & API gateways (reverse proxy, gateway plugins, connector track).
- Implement a provider or transport: Plugin developer docs (SPI, entry points, packaging).
- Understand the design: start with Neuroscience & vocabulary and Architecture.