Between 2014 and 2019, researchers conducted a retrospective 3-center analysis using electronic medical record data for patients with stage IV NSCLC. The latter were treated with pembrolizumab as first-line therapy, either alone or with chemotherapy. Variables were classified as covariates or confounders. Pre-treatment body mass index (BMI), neutrophil-to-lymphocyte ratio (NLR), albumin, and antibiotic exposure were among the covariates studied because of their developing predictive relevance. Sex, age at the start of immunotherapy, PD-L1 expression, performance status (PS), tumor mutational burden (TMB), and whether therapy as combination therapy or monotherapy were among the confounders that emphasized the characteristics of each patient and their malignancy. The Kaplan-Meier technique and Cox proportional hazards models were used to analyze the relationship between these variables and time to treatment failure (TTF) and overall survival (OS). The research covered 136 patients. TTF had univariate associations with antibiotic use, serum albumin, and NLR. Serum albumin, NLR, and BMI were univariate studies linked to OS. Antibiotic use exhibited a strong negative correlation with TTF after controlling for all 6 variables in a multivariate analysis. Antibiotic use and albumin, NLR, and BMI might predict treatment outcomes in patients with advanced NSCLC who were undergoing first-line immunotherapy.