Depression is a genetical disease characterized by neuroinflammatory symptoms and is difficult to diagnose and treat effectively. Recently, modification of N6-methyladenosine (m6A) at the gene level was shown to be closely related to immune regulation. This study was conducted to explore the effect of m6A modifications on the occurrence of depression and composition of the immune microenvironment. We downloaded gene expression profile data of healthy and depressed rats from the Gene Expression Omnibus. We described the overall expression of m6A regulators in animal models of depression and constructed risk and clinical prediction models using training and validation sets. Bioinformatics analysis was performed using gene ontology functions, gene set enrichment analysis, gene set variation analysis, weighted gene co-expression network analysis, and protein-protein interaction networks. We used CIBERSORT to identify immune-infiltrating cells in depression and perform correlation analysis. We then constructed two molecular subtypes of depression and assessed the correlation between the key genes and molecular subtypes. Through differential gene analysis of m6A regulators in depressed rats, we identified seven m6A regulators that were significantly upregulated in depressed rats and successfully constructed a clinical prediction model. Gene Ontology functional annotation showed that the m6A regulators enriched differentially expressed genes in biological processes, such as the regulation of mRNA metabolic processes. Further, 12 hub genes were selected from the protein-protein interaction network. Immune cell infiltration analysis showed that levels of inflammatory cells, such as CD4 T cells, were significantly increased in depressed rats and were significantly correlated with the depression hub genes. Depression was divided into two subtypes, and the correlation between hub genes and these two subtypes was clarified. We described the effect of m6A modification on the pathogenesis of depression, focusing on the role of inflammatory infiltration.