I am not sure I follow here.
In any case, if your model can be cast into a brms model, then maybe just do that and grab the reduce_sum branch from the brms github location. This will generate a working reduce_sum Stan model for you which you can modify further if needed. Be warned that this is ongoing development and not released yet.