feat: allow custom models for Anthropic provider with custom base URLs #8489
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses Issue #8488 by enabling custom model IDs when using the Anthropic API provider with custom base URLs. This enhancement allows users to leverage services like z.ai that provide Anthropic-compatible endpoints with their own custom models (e.g., glm-4.6-cc-max, glm-4.5v).
Changes
Backend (
src/api/providers/anthropic.ts)getModel()method to detect when a custom base URL is configuredFrontend (
webview-ui/src/components/settings/providers/Anthropic.tsx)UI Flow (
webview-ui/src/components/settings/ApiOptions.tsx)Testing
src/api/providers/__tests__/anthropic.custom-models.spec.tsUse Case
Users of services like z.ai can now:
https://api.z.ai/api/anthropic)glm-4.6-cc-max)Testing Instructions
https://api.z.ai/api/anthropic)glm-4.6-cc-max)Backward Compatibility
Fixes #8488
Important
Adds support for custom model IDs and base URLs for the Anthropic provider, with frontend and backend changes ensuring backward compatibility.
src/api/providers/anthropic.ts):getModel()now supports custom model IDs with custom base URLs, providing default settings for unknown models.webview-ui/src/components/settings/providers/Anthropic.tsx):ModelPickerfor custom model selection when a custom base URL is set.webview-ui/src/components/settings/ApiOptions.tsx):src/api/providers/__tests__/anthropic.custom-models.spec.tsfor custom model handling, including API calls and token counting.This description was created by
for a995d97. You can customize this summary. It will automatically update as commits are pushed.