Docs/Recipes

Read a photo or a PDF

Bills, forms, notices and screenshots: pass the file, get the answer.

read-bill.html
<input type="file" id="bill" accept="image/*,application/pdf">
<script type="module">
  bill.onchange = async () => {
    const reply = await charge.ai.chat('What is the total on this bill, and when is it due?', { files: [bill.files[0]] })
    out.textContent = reply.text
  }
</script>
  • files takes File or Blob objects: PNG, JPEG, WebP or PDF, about 3 MB in all, up to five at a time.
  • Files always go to the cloud, to a model that reads them. Reading a page costs about as much as a few paragraphs of text.
  • Shrink large phone photos before sending them; the reply is just as good and it costs less.

Read next

Still stuck? Talk to us and we'll help.