---
title: "Extract data from Arabic invoices with a vision LLM API"
description: "Send an invoice or receipt photo to a vision model on BroadNet Inference and get the total, date and vendor back as JSON, with questions in Arabic or English."
url: https://broadrouter.com/guides/read-arabic-invoices-with-vision/
lang: en
updated: 2026-11-16
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# Read Arabic invoices and receipts with a vision model

Updated 2026-11-16

Send the image as a base64 data URL in the message content to a vision model such as broadnet/qwen3.8-27b or broadnet/gemma-4-26b-a4b, and ask for the fields you need as JSON. Keep the MIME type accurate. On pay-as-you-go an image counts as input tokens; larger images use more.

Three chat models on BroadNet Inference take images: DeepSeek V4.1 Flash, Qwen3.8 27B and BroadNet Gemma 4 VL 26B. GLM 5.3 is text only. For Arabic documents, Qwen3.8 27B is the one BroadNet tested in Arabic: fluent writing, Gulf and Egyptian dialects understood, and accurate Arabic–English translation. Gemma 4 VL 26B is the cheapest of the three on BroadNet and works on the free credit.

## Ask a question about one invoice

```python
import base64, os
from openai import OpenAI

client = OpenAI(base_url="https://inference.broadnet.ai/v1", api_key=os.environ["BROADNET_API_KEY"])
invoice = base64.b64encode(open("invoice.jpg", "rb").read()).decode()

response = client.chat.completions.create(
    model="broadnet/gemma-4-26b-a4b",
    messages=[{"role": "user", "content": [
        {"type": "text", "text": "ما هو المبلغ الإجمالي في هذه الفاتورة؟"},
        {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + invoice}},
    ]}],
)
print(response.choices[0].message.content)
```

The question asks “What is the total amount on this invoice?” in Arabic. Use `image/png` in the data URL for PNG files: the MIME type must match. To set it from the file name:

```python
import mimetypes
mime = mimetypes.guess_type("invoice.png")[0]   # "image/png"
url = f"data:{mime};base64," + base64.b64encode(open("invoice.png", "rb").read()).decode()
```

## Get structured fields back

Ask for JSON and say exactly which keys you want:

```python
prompt = (
    "Read this invoice. Reply with JSON only, keys: vendor, date (YYYY-MM-DD), "
    "currency, total (number), vat (number or null). Keep the vendor name in Arabic if it is written in Arabic."
)
response = client.chat.completions.create(
    model="broadnet/qwen3.8-27b",
    max_tokens=2000,  # Qwen3.8 27B reasons first
    messages=[{"role": "user", "content": [
        {"type": "text", "text": prompt},
        {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + invoice}},
    ]}],
)
```

Qwen3.8 27B reasons before answering, so give it room. See [why reasoning models return empty answers](https://broadrouter.com/guides/reasoning-tokens-empty-response/). BroadNet’s docs list structured output for Qwen3.8 27B; see [structured output](https://broadrouter.com/glossary/structured-output/) for how JSON schemas work in general. Parse the reply with `json.loads` and check the fields before you store them.

## Cost

On pay-as-you-go, an image is billed as input tokens at the model’s input price, so resize very large photos first; the [image token calculator](https://broadrouter.com/tools/image-token-calculator/) shows how many tokens a given size costs. On an [unlimited DeepSeek V4.1 Flash plan](https://broadrouter.com/guides/unlimited-llm-api-sessions/), images are part of the unlimited use.

[Compare the vision models’ prices](https://broadrouter.com/pricing/), or see how a vision model compares with Google, Azure, Textract and Mistral OCR in the [Arabic OCR API comparison](https://broadrouter.com/blog/arabic-ocr-api-comparison/).

## Troubleshooting

-   **Empty answer from Qwen3.8 27B or DeepSeek V4.1 Flash.** Reasoning used up `max_tokens`. Raise it or set `reasoning_effort` to `low`.
-   **400 or 422 on the image.** Check that the data URL starts with `data:image/jpeg;base64,` or `data:image/png;base64,` and that the MIME type matches the file.
-   **403 or an error on the model.** GLM 5.3 does not take images, and Qwen3.8 27B and DeepSeek V4.1 Flash need a top-up. Use BroadNet Gemma 4 VL 26B on the free credit.
-   **Request too large or context errors.** A big photo uses many tokens, and Gemma 4 VL 26B has the smallest context window of the three (listed in pricing.json). Resize to a sensible width or crop to the totals area.
-   **Wrong totals or swapped digits.** Arabic-Indic digits (٠١٢٣) and Latin digits can both appear on one receipt. Ask the model to return numbers in Latin digits, and check totals against line items in your code.
-   **Invalid JSON.** Ask for “JSON only”, strip any code fences before parsing, and retry once if parsing fails.

_[image: An Arabic and English invoice beside a phone showing the JSON {"total":125.00,"currency":"AED"}, with the text "From documents to structured data."]_

Illustrative example; the figures are not real output.

## Terms in this guide

[Token](https://broadrouter.com/glossary/token/)

A token is the unit of text a language model reads and writes: a word, part of a word, a punctuation mark or a byte sequence produced by the model's tokenizer. LLM APIs count, limit and usually bill usage in tokens.

[Structured output](https://broadrouter.com/glossary/structured-output/)

Structured output is an LLM API feature that constrains a model's reply to a format the developer specifies, usually a JSON Schema, so code can parse it reliably. It is stricter than JSON mode, which guarantees valid JSON but not a particular shape.

[Vision-language model](https://broadrouter.com/glossary/vision-language-model/)

A vision-language model (VLM) is a model that takes images and text together as input and produces text, so it can describe pictures, answer questions about them and read documents, charts or screenshots. VLMs are also called image-text-to-text or multimodal models.

[Context window](https://broadrouter.com/glossary/context-window/)

A context window is the maximum number of tokens a language model can work with in a single request. It covers the prompt, conversation history, tool definitions, images and the generated output, including any reasoning tokens. Anything that does not fit must be cut, summarised or split across several requests.

[Input and output tokens](https://broadrouter.com/glossary/input-and-output-tokens/)

Input tokens are the tokens a language model reads in a request, including the system prompt, conversation history, tool definitions and images. Output tokens are the tokens it generates in reply, including any reasoning. LLM APIs usually price them separately, and output usually costs more.

[JSON Schema](https://broadrouter.com/glossary/json-schema/)

JSON Schema is a vocabulary, written in JSON, for describing and validating the structure of JSON data: types, required fields, allowed values and nesting. The current version is 2020-12. LLM APIs use it to define tool parameters and the exact shape a structured output must follow.

[Pay-as-you-go](https://broadrouter.com/glossary/pay-as-you-go/)

Pay-as-you-go is a pricing model in which you pay only for what you use, metered per unit such as tokens, requests or audio minutes, with no subscription or minimum commitment. Most LLM APIs bill this way, from a prepaid balance or a periodic invoice.

[Prepaid credit](https://broadrouter.com/glossary/prepaid-credit/)

Prepaid credit is money added to an API account before use. Each request deducts its cost from the balance, and when the balance runs out, metered requests stop until you top up. It caps spend at what you have paid in.

## Questions

### Which BroadNet models can read images?

DeepSeek V4.1 Flash, Qwen3.8 27B and BroadNet Gemma 4 VL 26B accept images through chat completions. GLM 5.3 is text only, and the transcription models take audio.

### How do I send a local image file to a vision LLM API?

Read the file, base64-encode it and put it in an image\_url content part as a data URL, such as data:image/jpeg;base64, followed by the encoded bytes. The MIME type in the URL must match the file.

### Can I extract invoice data on the free credit?

Yes, with BroadNet Gemma 4 VL 26B, which runs on the free starting credit. Qwen3.8 27B and DeepSeek V4.1 Flash open after a top-up.

### Can I send a PDF invoice?

BroadNet's docs describe images sent as data URLs, not PDF files. Render each PDF page to a JPEG or PNG first, for example with pdftoppm, and send the pages as images.

## Related guides

-   [Arabic speech-to-text API, step by step](https://broadrouter.com/guides/arabic-speech-to-text-api/)
-   [Use the OpenAI Python SDK with BroadNet Inference](https://broadrouter.com/guides/openai-python-sdk/)
-   [Why a reasoning model returns an empty answer](https://broadrouter.com/guides/reasoning-tokens-empty-response/)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=guides-read-arabic-invoices-with-vision&utm_content=page-cta) ·

**Sources**

-   [BroadNet Inference API reference, chat with an image](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=guides-read-arabic-invoices-with-vision&utm_content=sources#requests)
-   [BroadNet Inference pricing (Qwen3.8 27B Arabic test notes)](https://inference.broadnet.ai/pricing?utm_source=broadrouter&utm_medium=referral&utm_campaign=guides-read-arabic-invoices-with-vision&utm_content=sources)
-   [Machine-readable model list with modalities and context length (pricing.json)](https://inference.broadnet.ai/pricing.json?utm_source=broadrouter&utm_medium=referral&utm_campaign=guides-read-arabic-invoices-with-vision&utm_content=sources)
