Skip to content

feat: add configurable API base URL (fixes #7, closes #9)#10

Open
shivamtiwari3 wants to merge 1 commit intosachaa:masterfrom
shivamtiwari3:feat/custom-base-url
Open

feat: add configurable API base URL (fixes #7, closes #9)#10
shivamtiwari3 wants to merge 1 commit intosachaa:masterfrom
shivamtiwari3:feat/custom-base-url

Conversation

@shivamtiwari3
Copy link

Summary

Adds a new API Base URL field to the Settings page, letting users point the app at any proxy or compatible endpoint instead of the hardcoded Anthropic URL.


Problem

The API endpoint was hardcoded to https://api.anthropic.com/v1/messages in config.ts and used directly in agent-worker.ts. Users who run a local proxy, a corporate gateway, or want to experiment with OpenAI-compatible endpoints that mirror the Anthropic messages API had no way to override it.


Solution

  • src/config.ts — added BASE_URL key to CONFIG_KEYS.
  • src/types.ts — added optional baseUrl?: string to InvokePayload and CompactPayload.
  • src/orchestrator.ts — new private baseUrl field loaded from IndexedDB on init(); new getBaseUrl() / setBaseUrl() methods; field forwarded in both invoke and compact worker messages.
  • src/agent-worker.tshandleInvoke and handleCompact resolve apiUrl = baseUrl || ANTHROPIC_API_URL, so the default is completely unchanged when the field is blank.
  • src/components/settings/SettingsPage.tsx — new API Base URL card between the API Key and Model sections with a URL input, Save button, and confirmation feedback.

Leaving the field empty keeps existing behaviour — no breaking change.


Testing

  • npm run typecheck — passes with zero errors.
  • Manually tested: blank field uses default Anthropic endpoint as before; setting a custom URL routes requests to that endpoint.

Checklist

  • Fixes the reported issue
  • Existing behaviour unchanged when field is left blank (no regressions)
  • TypeScript type-checks cleanly (npm run typecheck)
  • Code style matches project conventions (single quotes, no extra abstractions)

Allow users to set a custom API endpoint in Settings. The configured URL
is persisted in IndexedDB and forwarded to the agent worker, which uses
it in place of the hardcoded Anthropic endpoint. Leaving the field blank
continues to use https://api.anthropic.com/v1/messages unchanged.

This enables pointing the app at any proxy or compatible endpoint,
including OpenAI-format gateways that implement the Anthropic messages
API surface.
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.

Are there plans to support OpenAI endpoints Request to add a custom baseUrl

1 participant