There are several ways to retrieve bookcovers for archive.org and OpenLibrary items.
If you're looking for an endpoint which will automatically determine the appropriate image to represent an item, you should use the above service. It is also used by the Archive.org website for displaying item previews to the end-user.
If you know the item you're working with is a book (of mediatype 'text') and you prefer a full sized image, you can extract it directly from the item with the following syntax:
Of course, you can also follow the "Retrieving Book Pages" instructions to manually retrieve the bookcover image, the title page, or any other book page as an image.
The OpenLibrary (run by the Internet Archive) also provides its own API Book Cover service which extends to include works which the Internet Archive has not net digitized or made available. These APIs provide a programmatic method to access the book covers and author photos which are available in the Open Library Covers Repository.
Read more about this service here: