Skip to content

Add custom base URL support for Anthropic provider#12718

Open
melissa-barca wants to merge 5 commits intomainfrom
feature/anthropic-custom-url
Open

Add custom base URL support for Anthropic provider#12718
melissa-barca wants to merge 5 commits intomainfrom
feature/anthropic-custom-url

Conversation

@melissa-barca
Copy link
Copy Markdown
Contributor

@melissa-barca melissa-barca commented Mar 27, 2026

Summary

Addresses #8007

Adds custom base URL support for Anthropic.

  • Adds a Base URL input field to the Configure Language Model Providers modal
  • Supports both the native Anthropic SDK provider and the Vercel AI SDK provider
  • Supports ANTHROPIC_BASE_URL environment variable for automatic configuration
  • Handles URL normalization for both SDK flavors (native SDK omits /v1, Vercel SDK requires it)
  • Relaxes API key format validation when a custom base URL is set
  • Treats 404 from /v1/models as a successful connection for custom endpoints that don't expose model listing
  • Updates the auth extension's Anthropic key validator to use the configured base URL
  • Migrates Anthropic env variable authentication from Assistant to the Authentication extension.

@:assistant

melissa-barca and others added 4 commits March 25, 2026 10:30
Support custom base URLs for the Anthropic provider to enable
corporate proxies, litellm, and other Anthropic-compatible endpoints.

- Add baseUrl to supportedOptions so the config dialog renders the field
- Add baseUrl getter with /v1 suffix and trailing slash normalization
- Pass baseURL to the Anthropic SDK client constructor
- Relax sk-ant- key format validation when a custom URL is set
- Handle 404 gracefully in resolveConnection for custom endpoints
- Read ANTHROPIC_BASE_URL env var for autoconfigure and config dialog
- Add tests for baseUrl getter, validateCredentials, and env var support
…8007)

Add baseUrl support to the Anthropic Vercel provider, update the auth
extension validator to derive the models endpoint from config.baseUrl,
and fix the close-modal warning for autoconfigured providers.
)

Route ANTHROPIC_API_KEY environment variable credentials through the
auth extension's credential chain pattern so they appear as standard
auth sessions. This lets other extensions access Anthropic credentials
via vscode.authentication.getSession without knowing how they were
configured.

- Add credential chain to Anthropic auth provider for env var resolution
- Add authentication.anthropic.baseUrl config setting synced from
  ANTHROPIC_BASE_URL env var
- Protect chain sessions from UI deletion (must unset env var to remove)
- Delegate env var credential checks from positron-assistant to auth
  extension sessions for migrated providers
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:assistant

readme  valid tags

@melissa-barca melissa-barca marked this pull request as draft March 27, 2026 17:04
…8007)

- Validate ANTHROPIC_API_KEY against the configured base URL during
  credential chain resolution, preventing sign-in with invalid keys
- Sync ANTHROPIC_BASE_URL to config before chain resolution so
  validation uses the correct endpoint
- Block removal of chain sessions when the credential source is still
  available (env var still set), preventing inconsistent state where
  models work but UI shows signed out
- Show informational message when sign-out is blocked explaining that
  env var credentials cannot be removed from the UI
@melissa-barca melissa-barca marked this pull request as ready for review March 27, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant