Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions apps/api/src/utils/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import { chartTypes, operators, timeWindows } from '@openpanel/constants';
import { mapKeys } from '@openpanel/validation';

export const getChatModel = () => {
switch (process.env.AI_MODEL) {
const model = process.env.AI_MODEL;
switch (model) {
case 'gpt-4o':
return openai('gpt-4o');
case 'claude-3-5':
return anthropic('claude-3-5-haiku-latest');
case 'claude':
return anthropic('claude-sonnet-4-20250514');
default:
if (model?.startsWith('claude-')) {
return anthropic(model);
}
if (model?.startsWith('gpt-') || model?.startsWith('o')) {
return openai(model);
}
return openai('gpt-4.1-mini');
}
};
Expand Down
2 changes: 1 addition & 1 deletion apps/public/content/docs/self-hosting/deploy-coolify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Coolify will automatically configure most settings, but you may want to customiz
- `RESEND_API_KEY`: Your Resend API key for email features
- `EMAIL_SENDER`: Email sender address
- `OPENAI_API_KEY`: OpenAI API key for AI features (optional)
- `AI_MODEL`: AI model to use (`gpt-4o-mini`, `gpt-4o`, or `claude-3-5`)
- `AI_MODEL`: AI model to use (`gpt-4o`, `claude`, or any model identifier)

<Callout>
Coolify automatically handles:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Enable AI-powered features:

```yaml
config:
aiModel: "gpt-4o-mini" # Options: gpt-4o, gpt-4o-mini, claude-3-5
aiModel: "gpt-4o-mini" # Options: gpt-4o, claude, or any model identifier

secrets:
openaiApiKey: "sk-xxxxxxxxxxxxx" # For OpenAI models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ ALLOW_INVITATION=false
**Required**: No
**Default**: `gpt-4.1-mini`

AI model to use for the analytics assistant. Options: `gpt-4o`, `gpt-4o-mini`, `claude-3-5`.
AI model to use for the analytics assistant. Options: `gpt-4o`, `claude`, or any model identifier (e.g. `claude-sonnet-4-20250514`, `gpt-4.1-mini`). Models prefixed with `claude-` use Anthropic; models prefixed with `gpt-` or `o` use OpenAI.

**Example**:
```bash
Expand All @@ -294,7 +294,7 @@ OPENAI_API_KEY=sk-your-openai-api-key-here
**Required**: No (required if using Claude models)
**Default**: None

Anthropic API key for Claude AI models. Required if `AI_MODEL` is set to `claude-3-5`.
Anthropic API key for Claude AI models. Required if `AI_MODEL` is set to `claude` or any `claude-*` model.

**Example**:
```bash
Expand Down
5 changes: 3 additions & 2 deletions apps/public/content/docs/self-hosting/self-hosting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ OpenPanel includes an AI-powered analytics assistant that can help you analyze d
- `gpt-4o` - More powerful but higher cost
- `gpt-4o-mini` - Default model, good balance of performance and cost
- **Anthropic**
- `claude-3-5-haiku-latest` - Fast and cost-effective
- `claude` - Uses `claude-sonnet-4-20250514` by default
- Any `claude-*` model identifier (e.g. `claude-haiku-3-5-20241022`)

#### Configuration

Expand All @@ -141,7 +142,7 @@ AI_MODEL=gpt-4o-mini # Optional: defaults to gpt-4o-mini

```bash title=".env"
ANTHROPIC_API_KEY=your-anthropic-api-key-here
AI_MODEL=claude-3-5
AI_MODEL=claude
```

#### Getting API Keys
Expand Down