A practical, cost-optimized guide for stable generation of templated documents using Large Language Models