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

# Quickstart

> Get from zero to your first memory write in under 5 minutes.

# Quickstart

Get your first memory written and searched in under 5 minutes.

## 1. Get an API key

Create an account at [withfoundry.ai](https://withfoundry.ai) and copy your API key from the dashboard. Keys start with `key_`.

## 2. Install the SDK

<CodeGroup>
  ```bash npm theme={null}
  npm install @withfoundry/sdk
  ```

  ```bash yarn theme={null}
  yarn add @withfoundry/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @withfoundry/sdk
  ```
</CodeGroup>

## 3. Write a memory

Create a file `index.mjs` (or `index.ts` with your bundler):

```javascript theme={null}
import { Foundry } from '@withfoundry/sdk';

const foundry = new Foundry({ apiKey: process.env.FOUNDRY_API_KEY });

async function main() {
  const { data } = await foundry.memory.write({
    namespace: 'my-app',
    entries: [
      {
        content: 'Our API uses API keys with prefix key_ in Authorization: Bearer header.',
        metadata: { source: 'quickstart' },
      },
    ],
  });
  console.log('Written:', data.ids);
}

main().catch(console.error);
```

Run it (with your key set):

```bash theme={null}
export FOUNDRY_API_KEY=key_your_key_here
node index.mjs
```

You should see something like `Written: ['mem_abc123...']`.

## 4. Search memories

Add a search call to the same script:

```javascript theme={null}
const { data: results } = await foundry.memory.search({
  namespace: 'my-app',
  query: 'How do we authenticate?',
  limit: 5,
});
console.log('Search results:', results);
```

Re-run. You’ll get semantically similar entries (e.g. the one about API keys).

## 5. Use context in a prompt

To build a context string for an LLM prompt:

```javascript theme={null}
const { data: context } = await foundry.memory.getContext({
  namespace: 'my-app',
  query: 'How do we authenticate?',
  limit: 3,
});
console.log('Context for prompt:', context.text);
```

Use `context.text` as part of your system or user message when calling your LLM.

## Summary

| Step | What you did                                          |
| ---- | ----------------------------------------------------- |
| 1    | Got an API key from the dashboard                     |
| 2    | Installed `@withfoundry/sdk`                          |
| 3    | Wrote a memory with `memory.write()`                  |
| 4    | Queried with `memory.search()`                        |
| 5    | Fetched injectable context with `memory.getContext()` |

Next: [Memory Engine overview](/memory/overview) for namespaces, metadata, and limits, or [Security Scanner](/security/overview) to scan a repo.
