The Sloan Digital Sky Survey (SDSS) has recently initiated its fifth survey generation (SDSS-V), with a central focus on stellar spectroscopy. In particular, SDSS-V's Milky Way Mapper program will deliver multiepoch optical and near-infrared spectra for more than 5 × 106 stars across the entire sky, covering a large range in stellar mass, surface temperature, evolutionary stage, and age. About 10% of those spectra will be of hot stars of OBAF spectral types, for whose analysis no established survey pipelines exist. Here we present the spectral analysis algorithm, ZETA-PAYNE, developed specifically to obtain stellar labels from SDSS-V spectra of stars with these spectral types and drawing on machine-learning tools. We provide details of the algorithm training, its test on artificial spectra, and its validation on two control samples of real stars. Analysis with ZETA-PAYNE leads to only modest internal uncertainties in the near-IR with APOGEE (optical with BOSS): 3%–10% (1%–2%) for T
eff, 5%–30% (5%–25%) for
v
sin
i
, 1.7–6.3 km s−1 (0.7–2.2 km s−1) for radial velocity, <0.1 dex (<0.05 dex) for
log
g
, and 0.4–0.5 dex (0.1 dex) for [M/H] of the star, respectively. We find a good agreement between atmospheric parameters of OBAF-type stars when inferred from their high- and low-resolution optical spectra. For most stellar labels, the APOGEE spectra are (far) less informative than the BOSS spectra of these stars, while
log
g
,
v
sin
i
, and [M/H] are in most cases too uncertain for meaningful astrophysical interpretation. This makes BOSS low-resolution optical spectra better for stellar labels of OBAF-type stars, unless the latter are subject to high levels of extinction.