They were a rainbow of heroin addicts: white, black, Asian, Hispanic; young and old; male and female.

And they came from near and far — in cars and on foot — to buy heroin Friday on a litter-strewn block on Chicago’s predominately African-American West Side.

Chicago Police officers posing as drug dealers caught dozens of them in a reverse sting on the 3600 block of West Flournoy Street, near the Eisenhower Expressway. It followed a separate roundup of a reputed gang leader and dozens of his crew members by the police and the U.S. Drug Enforcement Administration.

Friday’s operation targeting low-level buyers was different from most drug busts. These addicts were given the choice to go into treatment instead of jail. Forty-one of them took the police up on their offer.

It was an expansion of the Chicago Police Department’s unique drug diversion program that began in early 2016. Until now, the program was limited to people who were caught selling small quantities of drugs — mostly to pay for their own drug habits.

The low-level buyers taken into custody Friday were looking to purchase “dime bags” of heroin for $10.

Some rode the Blue Line L from the suburbs and walked to the open-air market looking to score their dope before going to work. Others walked from their homes in the neighborhood or drove up in vehicles. A van with an Uber logo even pulled into an alley on the block at one point.

Some of the buyers seemed confused they weren’t automatically going to jail or having their vehicles impounded. One man called his spouse from a police facility on Homan Avenue, where the addicts were taken, to ask his wife to pick up his car.

“I’m going to Haymarket for detox,” he said. “It’s better than being locked up, I guess.”

A woman suffering from withdrawals bummed a cigarette from a cop who warned her not to light up until she left the police facility. And a down-and-out looking man instructed officers on how to start up his car: “You need to touch the ignition wires together,” he said.

“This is the first time I heard of this,” the man told officers about the diversion program.

Dozens of people have been sent to drug treatment through the program since the spring of 2016. “Now we’re trying to scale it up,” said police Lt. Matthew Cline of the department’s narcotics section.

“Today we’re also sending a message to the customer base that this is not a good place to buy their dope,” he said.

The roundup came a day after authorities announced that dozens of people were charged in federal and state courts with selling cocaine and fentanyl-laced heroin on the West Side.

Last year, hundreds of people in Chicago died of overdoses from heroin boosted by the powerful narcotic additive fentanyl. Police have been hammering on drug-dealing gangs and their markets — like the one on the 3600 block of West Flournoy — because of those deaths.

Cline said marked cars will patrol the block in coming days and people involved with the department’s Chicago Alternative Policing Strategy will work with residents to discourage the dealers from returning.

Also, the city’s Streets and Sanitation Department will launch a cleanup of the block, whose alleys are festooned with empty liquor bottles, syringes and other garbage.

Friday’s addict dragnet was a spinoff of Operation Sweet Dreams, a criminal investigation that began in October 2015 after 74 people were sent to hospitals because they overdosed on fentanyl-spiked heroin over a three-day period.

Police and federal agents tracked the drugs to an Unknown Vice Lords street gang member on the West Side through a fingerprint on a baggie of heroin that was linked to an overdose.

The first arrests were of Alfonzo Sylvester and Mario Wofford after they allegedly sold $720 of heroin to an undercover cop in early October 2015.

The nearly year-and-a-half-long investigation, run by Chicago Police Sgt. Jason Brown, led to the seizure of three kilograms of heroin, three kilograms of cocaine, about $400,000 in drug profits and about a dozen guns, authorities said. More than 65 people have been charged in the case.

On Wednesday, Kenneth Hines, the reputed leader of the Unknown Vice Lords, was arrested at a Beverly Hills, Calif. restaurant. Authorities said they seized about $100,000 in cash and a $40,000 Rolex watch from Hines, who lives in California and a northwest suburb of Chicago.

On Friday, police arrested one of Hines’ co-defendants, Barry Smith, at Cook County’s Leighton Criminal Courthouse, at 26th and California. He appeared for a hearing on a gun-related charge for which he was free on bond. On Nov. 22, Smith allegedly had been carrying a gun in his waistband when he was stopped by an Illinois State Police trooper for a traffic violation on the Eisenhower Expressway, officials said.