-
Notifications
You must be signed in to change notification settings - Fork 334
fix(api): update deprecated Claude model and support arbitrary model strings #318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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); | ||||||||||
|
Comment on lines
+17
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overly broad prefix match for The condition Consider a more specific pattern: Proposed fix- if (model?.startsWith('gpt-') || model?.startsWith('o')) {
+ if (model?.startsWith('gpt-') || /^o\d/.test(model ?? '')) {
return openai(model);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| } | ||||||||||
| return openai('gpt-4.1-mini'); | ||||||||||
| } | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
Comment on lines
269
to
+271
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify the default model identifier. Line 269 documents the default as Additionally, line 271 mentions models prefixed with 🤖 Prompt for AI Agents |
||
|
|
||
| **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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
What are the valid Anthropic Claude model identifiers as of March 2026?💡 Result:
The valid Anthropic Claude model identifiers as of March 2026, primarily for the Claude API, are: Latest models (recommended): - claude-opus-4-6 - claude-sonnet-4-6 - claude-haiku-4-5-20251001 (alias: claude-haiku-4-5) Legacy models still available (consider migrating): - claude-sonnet-4-5-20250929 (alias: claude-sonnet-4-5) - claude-opus-4-5-20251101 (alias: claude-opus-4-5) - claude-opus-4-1-20250805 (alias: claude-opus-4-1) - claude-sonnet-4-20250514 (alias: claude-sonnet-4-0) - claude-opus-4-20250514 (alias: claude-opus-4-0) - claude-3-haiku-20240307 (deprecated, retires April 19, 2026) To get the complete, up-to-date list programmatically, use the Anthropic API endpoint GET /v1/models, which lists all available models with their IDs, capabilities, and details. Aliases resolve to the full ID via the API. On AWS Bedrock and Google Vertex AI, IDs differ (e.g., anthropic.claude-opus-4-6-v1).
Citations:
🌐 Web query:
What are the valid OpenAI model identifiers as of March 2026, specifically gpt-4-mini or gpt-4o-mini?💡 Result:
As of March 2026, gpt-4o-mini is a valid OpenAI model identifier. It is listed as a fast, affordable small model for focused tasks in official OpenAI API documentation, with dedicated model pages confirming its availability, pricing ($0.15/$0.60 per 1M input/output tokens), 128K context window, and support for text and image inputs. Specific snapshots include gpt-4o-mini and gpt-4o-mini-2024-07-18. It remains active in the API, distinct from ChatGPT retirements. gpt-4-mini is not a valid OpenAI model identifier. No official documentation, model pages, or lists mention gpt-4-mini. Searches for it return no confirming sources; instead, related models like gpt-4.1-mini, gpt-4o-mini, and o4-mini appear. Deprecation lists do not reference it, confirming it never existed as a standard model.
Citations:
Fix OpenAI model identifier on line 20.
gpt-4.1-miniis not a valid OpenAI model. Usegpt-4o-miniinstead (fast, affordable small model with 128K context window).Line 12:
claude-sonnet-4-20250514is a valid Anthropic model identifier as of March 2026 and requires no changes.🤖 Prompt for AI Agents