The best Instagram carousel size is 1080 × 1350 px (4:5) for every slide. A square 1080 × 1080 px (1:1) works too. The app keeps photos as tall as 1080 × 1440 px (3:4), but the publishing API stops at 4:5, so scheduled carousels should stay at 1080 × 1350 px.
Instagram gives every slide in a carousel the same shape, so use one size for all of them. Through the publishing API, every slide is cropped to the first slide's shape. The app takes up to 20 photos and videos in one carousel, and the publishing API takes up to 10 photos and videos.
Sources: Instagram Help Centre, "Image resolution of photos you share on Instagram" and "Share a post with multiple photos or videos on Instagram"; Meta for Developers, "IG User Media" reference.
For a step-by-step walkthrough, read how to make a carousel on Instagram.