Use the Type field to determine which variant is active, then access the corresponding field:
switch imageGenerationProviderPreferencesOrder.Type { case components.ImageGenerationProviderPreferencesOrderTypeProviderName: // imageGenerationProviderPreferencesOrder.ProviderName is populated case components.ImageGenerationProviderPreferencesOrderTypeStr: // imageGenerationProviderPreferencesOrder.Str is populated}