Rub beef roast with sea salt and black pepper. Heat a large cast-iron skillet over medium-high heat; sear roast on all sides in the hot skillet, 2 to 3 minutes per side. Turn roast so the ribs and fat side are facing up.
Roast prime rib in the preheated oven for 45 minutes; scatter onion quarters around roast and continue cooking until an instant-read meat thermometer inserted into the thickest part of the meat reads 130 degrees F (54 degrees C) for rare, about 2 more hours.
Remove roast from skillet, wrap meat in aluminum foil, and let rest for 15 to 20 minutes to let juices reabsorb into the meat. Leave onion pieces in skillet.
Pour drippings from skillet into a bowl and skim off excess grease. Return degreased drippings to skillet with onion pieces, place over medium heat, and melt butter in the drippings. Whisk flour into mixture to make a paste, 1 to 2 minutes. Stir red wine into flour paste until smooth. Mix beef stock into pan gravy until smooth; stir thyme sprigs into gravy.
Reduce heat to low and simmer gravy until thickened, 5 to 8 minutes. Strain gravy, discard onion pieces and thyme, and serve with prime rib.