From 368280d3e49c91db579d0e1f7eede1e76811cb53 Mon Sep 17 00:00:00 2001 From: smhanan Date: Sun, 7 Dec 2025 11:08:30 -0800 Subject: [PATCH] Add support for custom Anthropic API URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds the ability to use local proxies or custom Anthropic API endpoints (e.g., localhost:4000) for development and testing purposes. Changes: - Add superdesign.anthropicUrl configuration setting to package.json - Update customAgentService.ts to support custom Anthropic URLs - Conditionally include Helicone headers only when using default URL When a custom Anthropic URL is configured, the extension will: 1. Use the custom URL instead of the default Helicone endpoint 2. Skip adding Helicone authentication headers 3. Log the custom URL being used for debugging This is particularly useful for: - Using local Claude API proxies (ccproxy-api, etc.) - Testing with custom API endpoints - Development and debugging scenarios 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- package.json | 5 +++++ src/services/customAgentService.ts | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 55607b2..727028b 100644 --- a/package.json +++ b/package.json @@ -162,6 +162,11 @@ "description": "Anthropic API key for Claude Code integration (required for claude-api provider)", "scope": "application" }, + "superdesign.anthropicUrl": { + "type": "string", + "description": "Custom Anthropic API URL (for local proxies like localhost:4000)", + "scope": "application" + }, "superdesign.claudeCodePath": { "type": "string", "description": "Path to claude binary (defaults to 'claude' for npm install, use 'claude-code' if installed via shell script)", diff --git a/src/services/customAgentService.ts b/src/services/customAgentService.ts index 580fa52..5e50408 100644 --- a/src/services/customAgentService.ts +++ b/src/services/customAgentService.ts @@ -128,13 +128,23 @@ export class CustomAgentService implements AgentService { } this.outputChannel.appendLine(`Anthropic API key found: ${anthropicKey.substring(0, 12)}...`); - + + const anthropicUrl = config.get('anthropicUrl'); + const isCustomAnthropicUrl = !!anthropicUrl; + + if (isCustomAnthropicUrl) { + this.outputChannel.appendLine(`Using custom Anthropic URL: ${anthropicUrl}`); + } + const anthropic = createAnthropic({ apiKey: anthropicKey, - baseURL: "https://anthropic.helicone.ai/v1", - headers: { - "Helicone-Auth": `Bearer sk-helicone-utidjzi-eprey7i-tvjl25y-yl7mosi`, - } + baseURL: anthropicUrl || "https://anthropic.helicone.ai/v1", + // Only include Helicone headers when using default URL + ...(isCustomAnthropicUrl ? {} : { + headers: { + "Helicone-Auth": `Bearer sk-helicone-utidjzi-eprey7i-tvjl25y-yl7mosi`, + } + }) }); // Use specific model if available, otherwise default to claude-4-sonnet