Background. Immunotherapy has been considered as a promising cancer treatment for hepatocellular carcinoma (HCC). However, due to the particular immune environment of the liver, identifying patients who could benefit from immunotherapy is critical in clinical practice. Methods. The pyroptosis gene expression database of 54 candidates from The Cancer Genome Atlas (TCGA) were collected to discover the critical prognostic-related pyroptosis genes. A novel pyroptosis gene model was established to calculate the risk score. Kaplan–Meier analysis and receiver operating characteristic curve (ROC) were used to verify its predictive ability. The International Cancer Genome Consortium (ICGC) data was collected as external validation data to verify the model’s accuracy. We employed multiple bioinformatics tools and algorithms to evaluate the tumor immune microenvironment (TIME) and the response to immunotherapy. Results. Our study found that most pyroptosis genes were expressed differently in normal and tumor tissues and that their expression was associated with the prognosis. Then, a precise four-pyroptosis gene model was generated. The one-year area under the curves (AUCs) among the training, internal, and external validation patients were 0.901, 0.727, and 0.671, respectively. An analysis of survival data revealed that individuals had a worse prognosis than patients with low risk. The analysis of TIME revealed that the low-risk group had more antitumor cells, fewer immunosuppressive cells, stronger immune function, less immune checkpoint gene expression, and better immunotherapy response than the high-risk group. Immunophenoscore (IPS) analysis also demonstrated that the low-risk score was related to superior immune checkpoint inhibitors therapy. Conclusion. A nomogram based on the four-pyroptosis gene signature was a novel tool to predict the effectiveness of immunotherapy for HCC. Therefore, individualized treatment targeting the pyroptosis genes may influence TIME and play an essential role in improving the prognosis in HCC patients.