> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mengram.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get your API key and add your first memory in under 2 minutes.

## Fastest path — paste one prompt into your agent

If you have a coding agent (Claude Desktop, Cursor, Claude Code, Codex, Windsurf), skip the manual steps entirely. Paste this prompt:

```
Install Mengram for me. Fetch the canonical install
guide at https://mengram.io/agent-install.txt and
follow it precisely. My email is YOUR_EMAIL_HERE.
```

The agent reads our [install guide](/agent-install), runs `pip install`, signs you up, configures the MCP server in its host, and verifies the install end-to-end with `mengram doctor`. Walk away — it tells you when it's done.

Want to do it manually? Continue below.

## 1. Get an API key

Sign up at [mengram.io](https://mengram.io/#signup) to get your free API key. It starts with `om-`.

You can also do it from the terminal — `mengram signup --email you@example.com` sends a 6-digit code; `mengram signup --email you@example.com --code 123456` exchanges it for a key and saves it to `~/.mengram/config.json`.

## 2. Install the SDK

<CodeGroup>
  ```bash Python theme={null}
  pip install mengram-ai
  ```

  ```bash JavaScript theme={null}
  npm install mengram-ai
  ```
</CodeGroup>

## 3. Add your first memory

<CodeGroup>
  ```python Python theme={null}
  from mengram import Mengram

  m = Mengram(api_key="om-your-key")

  # Add memories from a conversation
  result = m.add([
      {"role": "user", "content": "I deployed the app on Railway. Using PostgreSQL."},
      {"role": "assistant", "content": "Got it, noted the Railway + PostgreSQL stack."},
  ])

  # result contains a job_id for background processing
  print(result)  # {"status": "accepted", "job_id": "job-..."}
  ```

  ```javascript JavaScript theme={null}
  const { MengramClient } = require('mengram-ai');
  const m = new MengramClient('om-your-key');

  await m.add([
      { role: 'user', content: 'I deployed the app on Railway. Using PostgreSQL.' },
  ]);
  ```
</CodeGroup>

## 4. Search your memories

```python theme={null}
# Semantic search
results = m.search("deployment stack")
for r in results:
    print(f"{r['entity']} (score={r['score']:.2f})")
    for fact in r.get("facts", []):
        print(f"  - {fact}")

# Unified search — all 3 memory types at once
all_results = m.search_all("deployment issues")
print(all_results["semantic"])    # knowledge graph results
print(all_results["episodic"])    # events and experiences
print(all_results["procedural"]) # learned workflows
```

## 5. Get a Cognitive Profile

Generate a ready-to-use system prompt that captures who a user is:

```python theme={null}
profile = m.get_profile()
system_prompt = profile["system_prompt"]

# Use in any LLM call
response = openai.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": "What should I work on next?"},
    ]
)
```

## 6. Claude Code — Full Memory Loop

If you use Claude Code, set up automatic memory in one command:

```bash theme={null}
mengram setup
```

This creates your account (if needed), saves your API key, and installs hooks — all from the terminal. Or manually: `export MENGRAM_API_KEY=om-your-key` → `mengram hook install`.

This installs 3 hooks:

* **Session context** — loads your profile when Claude Code starts
* **Auto-recall** — searches relevant memories on every prompt
* **Auto-save** — captures conversations in the background

Claude Code remembers you across sessions automatically. See [Claude Code Integration](/claude-code) for details.

## 7. Verify the install end-to-end

```bash theme={null}
mengram doctor
```

Runs an auth + add + search round-trip against the cloud API. Final line is `OK: round-trip succeeded.` on success, or `FAIL: <reason>` with a fix-it hint.

<Tip>
  Use the environment variable `MENGRAM_API_KEY` so you don't have to pass the key every time: `m = Mengram()`
</Tip>
