ObjectiveHepatocellular carcinoma (HCC) immunotherapy is a focus of current research. We established a model that can effectively predict the prognosis and efficacy of HCC immunotherapy by analyzing the immune genes of HCC.MethodsThrough the data mining of hepatocellular carcinoma in The Cancer Genome Atlas (TCGA), the immune genes with differences in tumor and normal tissues are screened, and then the univariate regression analysis is carried out to screen the immune genes with differences related to prognosis. The prognosis model of immune related genes is constructed by using the minimum absolute contraction and selection operator (lasso) Cox regression model in the TCGA training set data, The risk score of each sample was calculated, and the survival was compared with the Kaplan Meier curve and the receiver operating characteristic (ROC) curve to evaluate the predictive ability. Data sets from ICGC and TCGA were used to verify the reliability of signatures. The correlation between clinicopathological features, immune infiltration, immune escape and risk score was analyzed.ResultsSeven immune genes were finally determined as the prognostic model of liver cancer. According to these 7 genes, the samples were divided into the high and low risk groups, and the results suggested that the high-risk group had a poorer prognosis, lower risk of immune escape, and better immunotherapy effect. In addition, the expression of TP53 and MSI was positively correlated in the high-risk group. Consensus clustering was performed to identify two main molecular subtypes (named clusters 1 and 2) based on the signature. It was found that compared with cluster 1, better survival outcome was observed in cluster 2.ConclusionSignature construction and molecular subtype identification of immune-related genes could be used to predict the prognosis of HCC, which may provide a specific reference for the development of novel biomarkers for HCC immunotherapy.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12920-023-01558-z.