feat: add custom base URL support for Anthropic-compatible endpoints (#246)

Support ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN in .env to route
SDK requests through proxies or gateways. Preflight now validates the
custom endpoint is reachable instead of skipping credential checks.
This commit is contained in:
ezl-keygraph
2026-03-18 00:53:44 +05:30
committed by GitHub
parent 629c52ed3b
commit ae4bd45a30
4 changed files with 73 additions and 9 deletions
+5 -2
View File
@@ -142,9 +142,12 @@ cmd_start() {
exit 1
fi
# Check for API key (Bedrock and router modes can bypass this)
# Check for API key (Bedrock, Vertex, router, and custom base URL modes can bypass this)
if [ -z "$ANTHROPIC_API_KEY" ] && [ -z "$CLAUDE_CODE_OAUTH_TOKEN" ]; then
if [ "$CLAUDE_CODE_USE_BEDROCK" = "1" ]; then
if [ -n "$ANTHROPIC_BASE_URL" ] && [ -n "$ANTHROPIC_AUTH_TOKEN" ]; then
# Custom base URL mode — use auth token as API key for SDK initialization
echo "Using custom base URL: $ANTHROPIC_BASE_URL"
elif [ "$CLAUDE_CODE_USE_BEDROCK" = "1" ]; then
# Bedrock mode — validate required AWS credentials
MISSING=""
[ -z "$AWS_REGION" ] && MISSING="$MISSING AWS_REGION"