How to extract text from images using API?

Free generally means doing computation and work on your own computer, not someone else’s.

The keyword you are looking for when you search for software you can run yourself is OCR: Optical Character Recognition. These also tend to be paid software at the high end of performance.

Free software to use to simply do what you want with a GUI:

For an API, a callable API that you can have AI code for you and not a nonexistent cloud service someone is giving away, the strongest recommendation is to use tesseract library as part of your code.

For a heavy-duty solution using local machine learning models, and needing AI hardware for best performance: