> ## 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.

# SDK installation

> Install and configure the Foundry SDK.

# SDK installation

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

## Install

<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>

## Configure

Create a client with your API key. Prefer environment variables over hardcoding.

```javascript theme={null}
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):

```javascript theme={null}
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](/memory/overview).
* **Security:** `foundry.security.scanRepo()`, `foundry.security.getScanResult()` — see [Security Scanner](/security/overview).

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](/sdk/reference)).

## TypeScript

The package ships with types. Use as usual in TS:

```typescript theme={null}
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](/sdk/reference) for method signatures and options.
