With this API you can generate random avatars for free based on user names or a random string if you'd prefer that. Below are some examples.
UI Avatars has a simple-to-use API with no limiting or login. No usage tracking and no information is stored. The final images are cached, but nothing else. Just write name or surname, or both.
All requests returns a image stream to be used directly in a <img/>
tag.
https://ui-avatars.com/api/?name=John+Doe
https://ui-avatars.com/api/?background=0D8ABC&color=fff