Antidiabetic medication may modulate the gut microbiota and thereby alter plasma and faecal bile acid (BA) composition, which may improve metabolic health. Here we show that treatment with Acarbose, but not Glipizide, increases the ratio between primary BAs and secondary BAs and plasma levels of unconjugated BAs in treatment-naive type 2 diabetes (T2D) patients, which may beneficially affect metabolism. Acarbose increases the relative abundances of Lactobacillus and Bifidobacterium in the gut microbiota and depletes Bacteroides, thereby changing the relative abundance of microbial genes involved in BA metabolism. Treatment outcomes of Acarbose are dependent on gut microbiota compositions prior to treatment. Compared to patients with a gut microbiota dominated by Prevotella, those with a high abundance of Bacteroides exhibit more changes in plasma BAs and greater improvement in metabolic parameters after Acarbose treatment. Our work highlights the potential for stratification of T2D patients based on their gut microbiota prior to treatment.