2540 Background: For many tumor types, there is an option to start an immune checkpoint inhibitor (ICI) at the time of diagnosis or to sequence ICI after chemotherapies or targeted therapies. The risk of immune-related adverse events (irAE) may vary by the line of therapy. Prior systemic therapies might release cancer epitopes and increase the risk of an irAE through awakened subclinical autoimmunity. Conversely, prior systemic therapies may lead to residual immunosuppression and reduce the risk of irAEs. Methods: We created an IRB-approved retrospective registry of all patients who received at least one dose of an ICI for any indication between 2/1/2011 and 4/7/2022 at a comprehensive cancer center and its outreach clinics. Study personnel reviewed the electronic medical record and defined irAEs according to Common Terminology Criteria for Adverse Events. Research specialists at Vasta Global captured most clinical outcomes. Line of therapy was defined ordinal manner, with four or more combined into a single group due to data sparsity. A multivariable logistic regression model was built to assess effect of line of therapy on any irAE while controlling for confounders identified either a priori or in univariate analysis. Given potential for heterogeneity, interaction between tumor primary and line of therapy was tested. SAS v9.4 was used for all analyses. Results: Among the final cohort of 3,101 patients, 1,169 (38%) were noted to have an irAE of any grade. ICI were used as first-line therapy in 1,432 patients and second-, third-, or at least fourth-line in 1,119, 328, and 222 patients, respectively. The most common tumor type was non-small cell lung cancer (36%), followed by melanoma (14%). At baseline, any-grade irAE were more common among first-line ICI with 618 (43.2%) than for second-line (395, 35.3%), third-line (102, 31.1%), or at least fourth-line (54, 24.3%; p<0.01). After adjusting for age (over 65), sex, smoking history, and body mass index, the model revealed significant heterogeneity, indicated by a significant interaction between the ICI line and the primary tumor type (p=0.01). The impact of the ICI line on the odds ratio (OR) of irAE for each primary calculated: melanoma (OR) 0.54 (95% confidence interval [CI] 0.32-0.93), non-small cell lung cancer OR 1.14 (CI 0.96-1.35), head-neck cancer OR 0.82 (CI 0.58-1.14), and renal cell carcinoma OR 0.78 (CI 0.57-1.06). Conclusions: The effect of pre-treatment with prior systemic therapy was significantly associated with the odds of developing an irAE, though this effect was significantly heterogeneous between tumor primaries. Melanoma was significantly less likely to develop irAE when heavily pre-treated. In contrast, NSCLC suggested a trend of increased odds of irAE with more pre-treatment however it was not statistically significant. Further study is indicated to clarify the types of prior systemic therapy that may modulate the risk of irAE and better clarify the optimal sequencing of ICI.