diff --git a/setup-claude-code.sh b/setup-claude-code.sh index 019633e..c21914f 100644 --- a/setup-claude-code.sh +++ b/setup-claude-code.sh @@ -83,10 +83,10 @@ test_api_connection() { "https://newapi.sususu.cf" ) - print_info "Testing API connections..." + print_info "Testing API connections..." >&2 for base_url in "${test_urls[@]}"; do - print_info "Testing $base_url..." + print_info "Testing $base_url..." >&2 local test_endpoint="$base_url/v1/models" @@ -102,25 +102,25 @@ test_api_connection() { local model_count model_count=$(cat /tmp/claude_test_response | jq -r '.data | length' 2>/dev/null || echo "0") if [ "$model_count" -gt "0" ]; then - print_success "API connection successful! Found $model_count models at $base_url" + print_success "API connection successful! Found $model_count models at $base_url" >&2 rm -f /tmp/claude_test_response echo "$base_url" return 0 else - print_warning "API responded but no models found at $base_url" + print_warning "API responded but no models found at $base_url" >&2 fi elif [ "$response" = "401" ]; then - print_warning "API key authentication failed for $base_url" + print_warning "API key authentication failed for $base_url" >&2 elif [ "$response" = "000" ]; then - print_warning "Cannot connect to $base_url" + print_warning "Cannot connect to $base_url" >&2 else - print_warning "API test failed for $base_url with HTTP status: $response" + print_warning "API test failed for $base_url with HTTP status: $response" >&2 fi rm -f /tmp/claude_test_response done - print_error "All API connections failed. Please check your API key and internet connection." + print_error "All API connections failed. Please check your API key and internet connection." >&2 return 1 } @@ -129,20 +129,21 @@ create_settings() { local base_url="$1" local api_key="$2" + # Create JSON using jq to ensure proper escaping local settings_json - settings_json=$(cat < /dev/null 2>&1; then