Personalized medicine aims to effectively and efficiently provide customized drugs that cater to diverse populations, which is a significant yet challenging task. Recently, the integration of artificial intelligence (AI) and three-dimensional (3D) printing technology has transformed the medical field, and was expected to facilitate the efficient design and development of customized drugs through the synergy of their respective advantages. In this study, we present an innovative method that combines AI and 3D printing technology to design and fabricate customized capsules. Initially, we discretized and encoded the geometry of the capsule, simulated the dissolution process of the capsule with classical drug dissolution model, and verified it by experiments. Subsequently, we employed a genetic algorithm to explore the capsule geometric structure space and generate a complex multi-layer structure that satisfies the target drug release profiles, including stepwise release and zero-order release. Finally, Two model drugs, isoniazid and acetaminophen, were selected and fused deposition modeling (FDM) 3D printing technology was utilized to precisely print the AI-designed capsule. The reliability of the method was verified by comparing the in vitro release curve of the printed capsules with the target curve, and the f2 value was more than 50. Notably, accurate and autonomous design of the drug release curve was achieved mainly by changing the geometry of the capsule. This approach is expected to be applied to different drug needs and facilitate the development of customized oral dosage forms.