Skip to main content

SDK installation

The official Node/TypeScript SDK is @withfoundry/sdk. It talks to https://api.withfoundry.ai and uses the standard response envelope.

Install

npm install @withfoundry/sdk

Configure

Create a client with your API key. Prefer environment variables over hardcoding.
import { Foundry } from '@withfoundry/sdk';

const foundry = new Foundry({
  apiKey: process.env.FOUNDRY_API_KEY,
});
Optional: override the base URL (e.g. for self-hosting or tests):
const foundry = new Foundry({
  apiKey: process.env.FOUNDRY_API_KEY,
  baseUrl: 'https://api.your-foundry-instance.com',
});

Usage

  • Memory: foundry.memory.write(), foundry.memory.search(), foundry.memory.getContext() — see Memory Engine.
  • Security: foundry.security.scanRepo(), foundry.security.getScanResult() — see Security Scanner.
All methods return Promises. Response shape follows the API envelope: { data, meta } on success; errors are thrown or returned depending on SDK design (check SDK reference).

TypeScript

The package ships with types. Use as usual in TS:
import { Foundry } from '@withfoundry/sdk';

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

const { data } = await foundry.memory.write({
  namespace: 'my-app',
  entries: [{ content: 'Hello', metadata: {} }],
});
// data.ids: string[]
Next: SDK reference for method signatures and options.