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',
}),
);
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',
}),
);
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 (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.