Quick Start
Get Astrocyte running — pick the deployment model that fits your stack and follow the commands.
Fastest path: memory for your coding agent
Section titled “Fastest path: memory for your coding agent”Give Claude Code, Codex CLI, Cursor, Gemini CLI, Windsurf, or Copilot CLI
persistent memory in two commands — no database or server, and no new API key (fact
extraction uses your Claude Code login, or OPENAI_API_KEY if Claude Code isn’t installed):
uv tool install 'astrocyte[local]'astrocyte setupastrocyte setup keeps memories in one local SQLite file, extracts facts with
the claude CLI when it is on your PATH (otherwise OPENAI_API_KEY), embeds
with a local model, proves the memory server starts, and then registers it with
every agent it finds — verifying each registration took effect.
astrocyte doctor checks the whole chain end to end; astrocyte doctor --fix
repairs it after an upgrade or a moved install.
In Claude Code, Codex and Antigravity, setup also turns on automatic memory for interactive sessions
(headless claude -p / codex exec / agy -p runs — scripts, benchmarks — are left alone): each finished turn is
saved to the project’s local memory, and genuinely relevant memories are added
to new prompts — so the agent knows what was decided last week without being
asked to look. A new session opens with where the previous one in that project left off
(its last few exchanges, whichever agent it was in). Conversations are stored only on your machine. Pause with
ASTROCYTE_HOOKS=off; turn off with astrocyte setup --no-hooks. Codex runs new hooks only
once you trust them: run /hooks in Codex after setup.
Windows: the memory tools (MCP) work natively, and so do the pieces of automatic memory
(the hooks, which run the same under cmd, PowerShell and Git Bash, and the background process),
each tested on Windows in CI. They have not yet been checked against a real agent session on
a Windows machine, so WSL remains the recommended way to get automatic memory there for now.
astrocyte doctor runs every installed hook through each shell and says if one doesn’t work.
File recall (opt-in, Claude Code): astrocyte setup --claude --file-recall also adds, after the agent
reads or edits a file, the memories of earlier turns that touched that file (captured turns record the files
they read or edited; Codex turns record only the files they edited, since Codex reads files through shell
commands). Each file is answered once per session. It runs a hook on every file read, so it is off
unless you turn it on; --no-file-recall turns it off again.
Setup remembers what you switch off: after astrocyte uninstall --claude or
astrocyte setup --no-hooks, a later astrocyte setup (after an upgrade, say) leaves it off.
Name the agent to turn it back on: astrocyte setup --claude.
See what your agents remember about the project you’re in with astrocyte memory;
astrocyte memory search "…" shows what a prompt would recall, and
astrocyte memory forget <id> erases a memory from disk (--all --yes for the whole project).
Memory starts empty. Seed it with what your project already tells agents:
astrocyte memory import CLAUDE.md AGENTS.md docs/ (setup suggests the files it finds).
Each file becomes one memory per section, and re-importing a file syncs it. Move a project’s
memory between machines with astrocyte memory export project.ama.jsonl and import on the other.
Share a project’s memory with your team through an Astrocyte gateway the team runs (token mode; an admin creates each person a token, see authentication setup):
astrocyte team join https://memory.example.com --token … # in the project; previews, then asksastrocyte team sync # push what's new, pull teammates' memoriesastrocyte team status # last sync, what's waiting, token checkastrocyte team leave # stop; erases teammates' memories hereWhat an agent saved and what you imported are shared; captured conversation stays on your
machine unless you join with --share-captured (run team join again to change it; it previews
first), and a memory tagged private never leaves it. For one memory, astrocyte memory share <id>
sends it anyway (a captured turn goes with all its chunks), and astrocyte memory unshare <id> keeps
it here: one already on the gateway is taken off it, so teammates’ copies go at their next sync,
while yours stays. astrocyte doctor checks each shared project’s token, gateway and last sync.
Teammates’ memories are copied into your local store under the same ids, so recall stays local
and works offline, and they are labelled with who saved them: - [2026-10-02] (alice) Deploys go out on Tuesdays. “Where you left off” only ever shows your own sessions. While an agent is open,
the background process syncs every joined project every five minutes
(ASTROCYTE_TEAM_SYNC_SECONDS); astrocyte team sync does it now. Forgetting a shared memory asks
for the scope: astrocyte memory forget <id> --team erases it for everyone (it needs the forget
permission on the gateway; each teammate’s copy goes at their next sync), --local on this machine
only. The token goes to the OS keychain when the keyring package is installed, else to team.json
beside your config (readable only by you).
The rest of this page covers embedding Astrocyte in your own application or running it as a shared service.
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)
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 Astrocyte gateway service — see the Standalone Gateway tab in Choose your deployment model above.
# 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.
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": "Alice 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.mcp import create_mcp_server
brain = Astrocyte.from_config("astrocyte.yaml") # wires the pipeline + storesserver = create_mcp_server(brain, brain.config)For a coding agent on your own machine, astrocyte setup (above) registers the
server for you. To run it by hand:
astrocyte-mcp --config astrocyte.yaml # --config defaults to ~/.config/astrocyte/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.