Use the Type field to determine which variant is active, then access the corresponding field:
switch imageGenerationProviderPreferencesSort.Type { case components.ImageGenerationProviderPreferencesSortTypeProviderSort: // imageGenerationProviderPreferencesSort.ProviderSort is populated case components.ImageGenerationProviderPreferencesSortTypeProviderSortConfig: // imageGenerationProviderPreferencesSort.ProviderSortConfig is populated}