> ## Documentation Index
> Fetch the complete documentation index at: https://forest-chore-open-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-hosted AI

> Route Forest AI features through your own back-end (OpenAI or Anthropic) so your data never leaves your infrastructure

By default, AI features in Forest are processed by Forest servers. To keep your data private, you can route AI requests through your own back-end using the `addAi` method, your data never leaves your infrastructure.

<Note>
  Self-hosted AI is available for the `@forestadmin/agent` Node.js agent.
</Note>

## Installation

```bash theme={null}
npm install @forestadmin/ai-proxy
```

## Configuration

Pass a provider built with `createAiProvider` to `addAi`:

<CodeGroup>
  ```javascript OpenAI theme={null}
  import { createAiProvider } from '@forestadmin/ai-proxy';

  const agent = createAgent(options)
    .addDataSource(/* ... */)
    .addAi(
      createAiProvider({
        name: 'my-assistant',
        provider: 'openai',
        apiKey: process.env.OPENAI_API_KEY,
        model: 'gpt-4o',
      }),
    );
  ```

  ```javascript Anthropic theme={null}
  import { createAiProvider } from '@forestadmin/ai-proxy';

  const agent = createAgent(options)
    .addDataSource(/* ... */)
    .addAi(
      createAiProvider({
        name: 'my-assistant',
        provider: 'anthropic',
        apiKey: process.env.ANTHROPIC_API_KEY,
        model: 'claude-sonnet-4-5',
      }),
    );
  ```
</CodeGroup>

## Options

| Option     | Type                        | Required | Description                                                           |
| ---------- | --------------------------- | -------- | --------------------------------------------------------------------- |
| `name`     | `string`                    | Yes      | Unique identifier for this AI configuration                           |
| `provider` | `'openai'` \| `'anthropic'` | Yes      | AI provider                                                           |
| `model`    | `string`                    | Yes      | Model to use (see supported models below)                             |
| `apiKey`   | `string`                    | No       | API key (defaults to `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` env var) |

All provider-specific options are also supported: [ChatOpenAI options](https://docs.langchain.com/oss/javascript/integrations/chat/openai) (`configuration`, `temperature`, `maxTokens`, etc.) and [ChatAnthropic options](https://docs.langchain.com/oss/javascript/integrations/chat/anthropic) (`anthropicApiUrl`, `temperature`, `maxTokens`, `topK`, etc.).

## Supported models

Any model with function/tool calling support works. See the [list of unsupported models](https://github.com/ForestAdmin/agent-nodejs/blob/main/packages/ai-proxy/src/supported-models.ts) for details.
