In summary, we identified bacterial species and metabolic pathways that might be associated with the occurrence of irAEs in gastric, esophageal, and colon cancers. Ruminococcus callidus and Bacteroides xylanisolvens were enriched in patients without severe irAEs. Several microbial metabolic pathways involved in the urea cycle, including citrulline and arginine biosynthesis, were associated with irAEs. We also found that irAEs in different cancer types and toxicity in specific organs and the endocrine system were associated with different gut microbiota profiles. These findings provide the basis for future mechanistic exploration.