A young man from California who worked as a babysitter and camp counselor was sentenced to 30 years in prison this week for producing and conspiring to distribute child pornography.

Ryan Michael Spencer, 21, of Aptos, had been using images of the kids he watched to produce the X-rated content, according to federal prosecutors.

He pleaded guilty in October and was sentenced Wednesday.

Prosecutors claimed that Spencer — who was also a teacher-in-training — molested at least two of the children he had been caring for, including a boy who was said to be younger than 10 years old. He cut a plea deal, however, and was only convicted of producing and conspiring to distribute the kiddie porn.

Authorities had been alerted to Spencer after discovering explicit content on a computer belonging to an acquaintance of his, who was also a babysitter, as well as a chess coach and tutor.

When FBI agents executed a search warrant on the pal’s home, they found thousands of images and videos that had been sent by Spencer. An investigation was then promptly launched.

“Spencer admitted that he and [the friend] shared child pornography using Kik Messenger and that, in the spring of 2016, he filled a hard drive with more than 30,000 images and videos of child pornography and gave it to [the friend],” prosecutors alleged in court papers.

“In pleading guilty, Spencer admitted that he produced pornographic images of more than a dozen children with whom he came into contact through his jobs as a babysitter and camp counselor in the Santa Cruz area,” the prosecutors added. “One set of such images depicted Spencer molesting a child that he was babysitting. Spencer created other images by surreptitiously photographing the children’s genitalia and pubic areas while the children were naked and in his care.”

Spencer will have to serve a 15-year term of supervised release, in addition to his prison sentence, officials said. He’s also been ordered to pay restitution to the victims.