Welcome to the forum.
If I understand you correctly then I did that the other day as an example for another problem, it even used an image of an invoice.
Note: This uses ChatGPT but the same should work for the API if the same model is used. Sorry I can not give you any working API code as I do not use that often but this should show that what you seek is doable.
Also check the OpenAI cookbook: https://cookbook.openai.com/