Heat your oil in a pot (to around 225-250 degrees F) In the meantime, in a bowl add your minced shallot, garlic, star anise, peppercorns, cinnamon, ginger, salt, sugar and thai chili flakes. Mix well.
Once your oil is hot, slowly add the hot oil over the chili mixture and stir. Pour the hot oil in batches and mix up. Let cool. Store the chili oil in an air tight container in the fridge for up to 5-6 months.