Cost-quality optimization for model selection, cascades, offloading, mixture-of-experts, and multi-model serving