> For the complete documentation index, see [llms.txt](https://documentation.astera.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.astera.com/dataflows/sources/text-converter/using-custom-ocr-api-model.md).

# Using Custom OCR API Model

The *Custom OCR API* model in the *Text Convertor* object lets you connect any external OCR service via a Centerprise *API flow*. Instead of a built-in engine, the *Text Converter* executes an API flow you build, which calls your OCR endpoint and returns the extracted text.

**To configure it in&#x20;*****Text Convertor*****:**

<figure><img src="/files/ulYZl9t5jYkegPX6Oilj" alt=""><figcaption></figcaption></figure>

1. Set *Text Converter Model* to `CustomOCRApi`. An *API Flow Path* field appears.
2. Set *API Flow Path* to the path of an `.api` flow file you have built to call your OCR service.

**Requirements for the API flow:**

The *API Flow Path* you provide in the *Text Convertor* object must point to an *API flow* for the `CustomOCRApi` model. The flow takes the document as input and returns the converted text in the response. You can customize the logic between the Request and Response objects.

For example, the API flow below includes a *Post* API call to *<https://api.openai.com/v1/files>* to upload the file, followed by a *Post* API call to *<https://api.openai.com/v1/responses>* with the file ID and an OCR prompt embedded in a JSON request body.

<figure><img src="/files/r2GhBIMwXbGQCiyIFLeJ" alt=""><figcaption></figcaption></figure>

The *API flow* must contain two things:

* A *Variables* object with a parameter named `file` (case-insensitive). The *Text Converter* automatically injects the source file path into this parameter at runtime — you do not need to set it manually.
* It must contain a *REST Request* action that sends the file to your OCR endpoint.

**Expected response:**

The OCR API must return a JSON response containing a `text` or `Text` field with the extracted text as a string. If the field is absent or empty, the Text Converter raises an error.

No shared connection is required on the Text Converter itself — authentication is handled inside the API flow.

**Using Split Output with CustomOCRApi:**

If you intend to use **Split Output**, the `text` field in the API response must use form feed characters (`\f`) as page separators — the Text Converter splits output records on `\f`.

For example, if your Custom OCR API calls an OpenAI model to perform the OCR, instruct it to insert `\f` between pages in the system prompt:

> "Separate each page's text with a form feed character (`\f`)."

***Example API request***

{% code overflow="wrap" %}

```bat
curl -X POST "https://api.openai.com/v1/responses" -H "Authorization: Bearer YOUR-OPENAI-KEY" -H "Content: {"model":"gpt-4.1-mini","input":[{"role": "user","content":[{"type":"input_file","file_id":"file-Ac3VRJwgdVmNwbK9xAZU6x"},{"type":"input_text","text":"You are an OCR-like data extraction tool that extracts from document. 1. Extract ALL visible data from the image. 4. Ensure that pipes (|) are used to separate table columns and that the table hierarchy is flattened without any loss of information in the extracted text. 5. Do not summarize or interpret or bring any extra text — just extract. 6. Separate each page's text with a form feed character (\f)."}]}]}" 
```

{% endcode %}

The model will then include `\f` in the response between each page's content, which the Text Converter uses to split the output into one record per page.

Using *CustomOCRApi* as the model, ensuring that the API flow seperates pages with `\f` , we can enable *Split Output* option in *Text Convertor* if we want to split pages.

<figure><img src="/files/rQ0lBxMr1tpJfiQ6qSxL" alt=""><figcaption></figcaption></figure>

*Preview* the *Text Convertor* object to ensure we are recieving each page's converted text as an individual record.

<figure><img src="/files/ZAdkbgbg2eMbmPsOB5PO" alt=""><figcaption></figcaption></figure>

This concludes the guide to set-up *Custom OCR API* in *Text Convertor* object in Astera.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://documentation.astera.com/dataflows/sources/text-converter/using-custom-ocr-api-model.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
