From ddb311d10f86d0ddc6892ae6853d18ee7d558fd2 Mon Sep 17 00:00:00 2001 From: Niels Kaspers Date: Mon, 23 Mar 2026 09:46:15 +0200 Subject: [PATCH] fix(api): update deprecated Claude model and support arbitrary model strings (#314) - Replace deprecated `claude-3-5` config with `claude` shorthand - Allow passing any model identifier via AI_MODEL env var - Models prefixed with `claude-` route to Anthropic, `gpt-`/`o` to OpenAI - Update self-hosting docs to reflect new config options --- apps/api/src/utils/ai.ts | 13 ++++++++++--- .../content/docs/self-hosting/deploy-coolify.mdx | 2 +- .../content/docs/self-hosting/deploy-kubernetes.mdx | 2 +- .../docs/self-hosting/environment-variables.mdx | 4 ++-- .../content/docs/self-hosting/self-hosting.mdx | 5 +++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/api/src/utils/ai.ts b/apps/api/src/utils/ai.ts index 0fcf69de3..1b6fa622d 100644 --- a/apps/api/src/utils/ai.ts +++ b/apps/api/src/utils/ai.ts @@ -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'); } }; diff --git a/apps/public/content/docs/self-hosting/deploy-coolify.mdx b/apps/public/content/docs/self-hosting/deploy-coolify.mdx index 720a9cb34..b5b49b28d 100644 --- a/apps/public/content/docs/self-hosting/deploy-coolify.mdx +++ b/apps/public/content/docs/self-hosting/deploy-coolify.mdx @@ -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) Coolify automatically handles: diff --git a/apps/public/content/docs/self-hosting/deploy-kubernetes.mdx b/apps/public/content/docs/self-hosting/deploy-kubernetes.mdx index fe33a7c0f..686f860b6 100644 --- a/apps/public/content/docs/self-hosting/deploy-kubernetes.mdx +++ b/apps/public/content/docs/self-hosting/deploy-kubernetes.mdx @@ -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 diff --git a/apps/public/content/docs/self-hosting/environment-variables.mdx b/apps/public/content/docs/self-hosting/environment-variables.mdx index df823f0dd..f47ba91a1 100644 --- a/apps/public/content/docs/self-hosting/environment-variables.mdx +++ b/apps/public/content/docs/self-hosting/environment-variables.mdx @@ -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 @@ -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 diff --git a/apps/public/content/docs/self-hosting/self-hosting.mdx b/apps/public/content/docs/self-hosting/self-hosting.mdx index 9a53825ed..829037677 100644 --- a/apps/public/content/docs/self-hosting/self-hosting.mdx +++ b/apps/public/content/docs/self-hosting/self-hosting.mdx @@ -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 @@ -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