The wide application of immune checkpoint inhibitors has significantly improved the survival expectation of cancer patients. While immunotherapy brings benefits to patients, it also results in a series of immune-related adverse events (irAEs). Increasing evidence suggests that the gut microbiome is critical for immunotherapy response and the development of irAEs. In this prospective study, we recruited 95 patients with advanced/unresectable gastrointestinal cancers treated with immunotherapy and report a comprehensive analysis of the association of the gut microbiome with irAEs. Metagenome sequencing was used to analyze the differences in bacterial composition and metabolic pathways of baseline fecal samples.