You're talking about fruit fly?
This means you use fresh food. The food needs to be discarded as soon as the birds have eaten. Only give it to them during main meals & offer pellet & seed for the in between meals. This will help eliminate the fruit fly & will not hurt the birds in any way doing this for a few days.
They also LOVE red wine. Use a small soft drink bottle with only the lid take off. Add just a little wine in there & hang it around the areas of the cages, not where the birds can get to them. The flies can't resist red wine & get trapped (or drunk) in it & die.
Another way to go: take a small glass fill it 1/2" with Apple Cider Vinegar and 2 drops of dishwashing liquid, mix well. You will find those flies drawn to the cup and gone forever!
Or put some fruit juice in small dishes around the house. The fruit flies go in there and get stuck and die.
Or get a ziplock bag. Put apple peal, banana (any kind of strong fruit smell). The fruit flies go to that bag and when seen that there are many of them, spray them with windex (ammonia kills them instantly). I don't spray a lot, just enough to get them & not around birds.