Obtain gradient of function (e.g. multi_student_t_lpdf) within Stan? Estimating approximate density functions

I feel like this has been discussed here before but couldn’t find it. I’m interested in estimating an approximate density function from a few samples of the density and gradient around the mode. I figure leveraging the gradient information should help, though maybe this creates some kind of autodiff breaking recursion? Happy for any random pointers on the topic too, there are probably better ideas around…

Re the title, check this: https://cran.r-project.org/web/packages/StanHeaders/vignettes/stanmath.html

Can you describe the boundary conditions a little more?

This sounds like some sorta kernel density estimation thing but maybe the solution is simpler or harder depending on what you wanna do.