Aukid Phumsirichat / EyeEm

If your worst nightmare is to be trapped in a room with six billion roaches flying around you, here's the bad news.

With the help of artificial intelligence, folks at a Chinese pharmaceutical company are breeding cockroaches by the billions every year, South China Morning Post reported Thursday. Their purpose: To make a "healing potion" that can cure respiratory, gastric and other diseases.

The "potion," consumed by over 40 million people in China, is made by crushing the cockroaches once they reach a desired weight and size, according to the publication. There is a "slightly fishy smell" to the potion, which tastes "slightly sweet" and looks like tea, it added.

Some insects are known to have potential health benefits. Besides China's cockroach potion, scientists are also exploring how milk-like protein crystals in roaches could be an excellent source of calories and nutrition. Chowing down on bugs like crickets and mealworms can also give us more protein, according to studies.

The population of cockroaches at China's largest roach farm is so massive that it's been warned there would be a "catastrophe" if the roaches were to be suddenly released.

The giant facility is managed with the help of a "smart manufacturing" system powered by AI algorithms. The system is responsible for collecting and analysing over 80 categories of data to ensure an optimal environment for the cockroaches to grow, according to the SCMP. These include factors such as humidity, temperature, food supply and consumption, as well as changes like genetic mutations. The system also "learns" from its historical data so it can make improvements to grow the population.

AI has been implemented in several fields in China. It's also part of the country's surveillance system, which has received plenty of attention over the past few months. Last December, a BBC reporter was taken into custody in just seven minutes as part of a test showing how effective the system works. Its facial recognition abilities also played a role in identifying and detaining a fugitive among 50,000 people attending a concert.

In the Chinese city of Shenzhen, an AI company is working with local authorities to identify jaywalkers and send them a text informing them about a fine. Offenders will also see their faces appear on a board alongside their family names.

Now playing: Watch this: Elon Musk warns about dangers of AI, Moto X4 leaks

CNET Magazine: Check out a sample of the stories in CNET's newsstand edition.

Rebooting the Reef: CNET dives deep into how tech can help save Australia's Great Barrier Reef.