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

# Device Memory Quickstart

> Get started with client-owned memory in 5 minutes

<Warning>You'll need a Nebula API key before starting. Get one at [zeroset.com](https://zeroset.com)</Warning>

## Prerequisites

* A Nebula account at [zeroset.com](https://zeroset.com)
* An existing Nebula collection with some stored memories (see [Quick Start](/quickstart) to create one)
* **Python**: Python 3.10+ with `pip install nebula-sdk`
* **JavaScript/TypeScript**: Node.js 18+ with `npm install @nebula-ai/sdk`

## Install

<CodeGroup>
  ```bash Python theme={null}
  pip install nebula-sdk
  ```

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

## Walkthrough

<Steps>
  <Step title="Initialize the client">
    <CodeGroup>
      ```python Python theme={null}
      from nebula import Nebula

      client = Nebula(api_key="YOUR_API_KEY")
      ```

      ```typescript JavaScript theme={null}
      import Nebula from '@nebula-ai/sdk';

      const client = new Nebula({ apiKey: 'YOUR_API_KEY' });
      ```
    </CodeGroup>
  </Step>

  <Step title="Export a snapshot from an existing collection">
    <CodeGroup>
      ```python Python theme={null}
      snapshot = client.snapshots.export(collection_id="YOUR_COLLECTION_ID").results
      ```

      ```typescript JavaScript theme={null}
      const { results: snapshot } = await client.snapshots.export({
        collection_id: 'YOUR_COLLECTION_ID',
      });
      ```
    </CodeGroup>

    <Info>After export, the local snapshot is the canonical copy. Nebula does not retain a server-side copy.</Info>
  </Step>

  <Step title="Store memories against your snapshot">
    Use the same `memories.create()` method you already know -- just pass `snapshot` instead of `collection_id`.

    <CodeGroup>
      ```python Python theme={null}
      result = client.memories.create(
          snapshot=snapshot,
          raw_text="Had a meeting with Alice about the Q2 roadmap",
      ).results
      snapshot = result.snapshot
      ```

      ```typescript JavaScript theme={null}
      const { results } = await client.memories.create({
        snapshot,
        raw_text: 'Had a meeting with Alice about the Q2 roadmap',
      });

      snapshot = results.snapshot;
      ```
    </CodeGroup>
  </Step>

  <Step title="Search memory">
    Same `memories.search()` method -- pass `snapshot` instead of `collection_ids`.

    <CodeGroup>
      Snapshot search returns a graph shape (`entities` + `relationships`), distinct from the `MemoryResponse` returned by collection search.

      ```python Python theme={null}
      results = client.memories.search(
          query="What do I know about Alice?",
          snapshot=snapshot,
      ).results

      for entity in results.entities or []:
          print(f"{entity.name} ({entity.category}): {entity.description}")
      for rel in results.relationships or []:
          print(f"{rel.subject_id} -[{rel.predicate}]-> {rel.object_id}")
      ```

      ```typescript JavaScript theme={null}
      const { results } = await client.memories.search({
        query: 'What do I know about Alice?',
        snapshot,
      });

      for (const entity of results.entities ?? []) {
        console.log(`${entity.name} (${entity.category}): ${entity.description}`);
      }
      for (const rel of results.relationships ?? []) {
        console.log(`${rel.subject_id} -[${rel.predicate}]-> ${rel.object_id}`);
      }
      ```
    </CodeGroup>
  </Step>
</Steps>

## Next Steps

* [Device Memory API](/guides/device-memory-api) -- REST endpoint reference
* [Device Memory Architecture](/guides/device-memory) -- Conceptual overview
