When a task needs many different IPs, changing them by hand is suicide. IP rotation solves it: each request or batch goes from a new address. Services with an API hand out addresses automatically — the script takes the next one itself.
A simple way: before each request you hit the API and get a fresh address. But do not request for every single request — that is load and limits. Better take a batch of 10-20 addresses at once and rotate, refreshing the batch every few minutes.
Automatic IP change is needed in scraping so the site does not detect a bot by one address. With proxy rotation each request looks like a new user.
Important: rotation is not a cure-all. For social media and ad accounts it is harmful — they need a stable IP. Use rotation where address novelty matters, not persistence.