> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neosantara.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# OCR Dokumen

> Ekstraksi teks, tabel, dan formula dari gambar atau pindaian dokumen via /v1/ocr.

Endpoint `/v1/ocr` mengekstraksi teks dari dokumen, invoice, formulir, dan tabel secara terstruktur dengan model OCR berbasis AI (DeepSeek OCR dan GLM OCR).

<CodeGroup>
  ```python Python icon="python" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  import requests
  import base64
  import os

  url = "https://api.neosantara.xyz/v1/ocr"
  headers = {
      "Authorization": f"Bearer {os.environ['NEOSANTARA_API_KEY']}",
      "Content-Type": "application/json"
  }

  with open("faktur.png", "rb") as f:
      encoded_image = base64.b64encode(f.read()).decode("utf-8")

  payload = {
      "model": "deepseek-ocr",
      "image": encoded_image,
      "image_type": "base64",
      "prompt": "Ekstrak seluruh baris invoice ke dalam tabel Markdown."
  }

  response = requests.post(url, headers=headers, json=payload)
  data = response.json()
  print(data.get("extracted_text"))
  ```

  ```bash cURL (URL Gambar) icon="terminal" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  curl -X POST https://api.neosantara.xyz/v1/ocr \
    -H "Authorization: Bearer $NEOSANTARA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "deepseek-ocr",
      "image": "https://example.com/invoice.jpg",
      "image_type": "url"
    }'
  ```
</CodeGroup>

## Parameter Permintaan

| Parameter      | Tipe      | Wajib    | Keterangan                                                             |
| :------------- | :-------- | :------- | :--------------------------------------------------------------------- |
| `model`        | `string`  | Ya       | `deepseek-ocr`, `glm-ocr`, atau `zai-ocr`.                             |
| `image`        | `string`  | Ya       | URL gambar publik atau string Base64.                                  |
| `image_type`   | `string`  | Ya       | Nilai: `"url"` atau `"base64"`.                                        |
| `prompt`       | `string`  | Opsional | Instruksi khusus untuk penataan format teks (didukung pada `glm-ocr`). |
| `return_image` | `boolean` | Opsional | Kembalikan data visual yang telah diproses. Default `false`.           |

## Model OCR yang Tersedia

| Model ID       | Provider | Context Window | Capabilities | Pricing (Input/Output per 1M) |
| :------------- | :------- | :------------- | :----------- | :---------------------------- |
| `deepseek-ocr` | DeepSeek | N/A            | Vision, OCR  | Rp 100/img                    |
| `glm-ocr`      | zAI      | N/A            | OCR          | Rp 100/img                    |


## Related topics

- [Vision Multimodal](/id/gateway/chat-completions/vision.md)
- [Manajemen File](/id/gateway/operations/files.md)
- [Katalog Model](/id/gateway/models.md)
