The capability to design microbiomes with predictable functions would enable new technologies for applications in health, agriculture, and bioprocessing. Towards this goal, we develop a model-guided approach to design synthetic human gut microbiomes for production of the health-relevant metabolite butyrate. Our data-driven model quantifies microbial interactions impacting growth and butyrate production separately, providing key insights into ecological mechanisms driving butyrate production. We use our model to explore a vast community design space using a design-test-learn cycle to identify high butyrate-producing communities. Our model can accurately predict community assembly and butyrate production across a wide range of species richness. Guided by the model, we identify constraints on butyrate production by high species richness and key molecular factors driving butyrate production, including hydrogen sulfide, environmental pH, and resource competition. In sum, our model-guided approach provides a flexible and generalizable framework for understanding and accurately predicting community assembly and metabolic functions.