Skip to main content
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.
Self-hosted AI is available for the @forestadmin/agent Node.js agent.

Installation

npm install @forestadmin/ai-proxy

Configuration

Pass a provider built with createAiProvider to addAi:
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',
    }),
  );

Options

OptionTypeRequiredDescription
namestringYesUnique identifier for this AI configuration
provider'openai' | 'anthropic'YesAI provider
modelstringYesModel to use (see supported models below)
apiKeystringNoAPI key (defaults to OPENAI_API_KEY or ANTHROPIC_API_KEY env var)
All provider-specific options are also supported: ChatOpenAI options (configuration, temperature, maxTokens, etc.) and ChatAnthropic options (anthropicApiUrl, temperature, maxTokens, topK, etc.).

Supported models

Any model with function/tool calling support works. See the list of unsupported models for details.