Skip to main content

Quickstart

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

1. Get an API key

Create an account at withfoundry.ai and copy your API key from the dashboard. Keys start with key_.

2. Install the SDK

npm install @withfoundry/sdk

3. Write a memory

Create a file index.mjs (or index.ts with your bundler):
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):
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:
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:
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

StepWhat you did
1Got an API key from the dashboard
2Installed @withfoundry/sdk
3Wrote a memory with memory.write()
4Queried with memory.search()
5Fetched injectable context with memory.getContext()
Next: Memory Engine overview for namespaces, metadata, and limits, or Security Scanner to scan a repo.