> For the complete documentation index, see [llms.txt](https://docs.mindee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mindee.com/v1/integration/java-ocr-sdk/java-generated-ocr.md).

# Generated API

## Generated API Java

The Java OCR SDK supports generated APIs. Generated APIs can theoretically support all APIs in a catch-all generic format.

## Quick-Start

```java
import com.mindee.MindeeClient;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.common.AsyncPredictResponse;
import com.mindee.product.generated.GeneratedV1;
import com.mindee.http.Endpoint;
import java.io.File;
import java.io.IOException;

public class SimpleMindeeClient {

  public static void main(String[] args) throws IOException, InterruptedException {
    String apiKey = "my-api-key";
    String filePath = "/path/to/the/file.ext";

    // Init a new client
    MindeeClient mindeeClient = new MindeeClient(apiKey);

    // Load a file from disk
    LocalInputSource inputSource = new LocalInputSource(new File(filePath));

    // Configure the endpoint
    Endpoint endpoint = new Endpoint(
      "my-endpoint",
      "my-account",
      "my-version"
    );

    // Parse the file asynchronously
    AsyncPredictResponse<GeneratedV1> response = mindeeClient.enqueueAndParse(
      GeneratedV1.class,
      endpoint,
      inputSource
    );

    // Print a summary of the response
    System.out.println(response.toString());

    // Print a summary of the predictions
//  System.out.println(response.getDocumentObj().toString());

    // Print the document-level predictions
//    System.out.println(response.getDocumentObj().getInference().getPrediction().toString());

    // Print the page-level predictions
//    response.getDocumentObj().getInference().getPages().forEach(
//        page -> System.out.println(page.toString())
//    );
  }

}
```

## Generated Endpoints

As shown above, you will need to provide an account and an endpoint name at the very least.

Although it is optional, the version number should match the latest version of your build in most use-cases. If it is not set, it will default to "1".

## Field Types

### Generated Fields

By default, GeneratedV1 implements only one attribute:

* **fields**: this attribute is retrievable through `getFields()`, which will return a `Map<String, GeneratedFeature>`.

#### Generated Feature

A `GeneratedFeature` is a special type of custom list that extends `ArrayList<`[GeneratedObject](#generated-object-field)`>` and implements the following:

* **asStringField()** (`StringField`): the value of the field as a `StringField`.
* **asAmountField()** (`AmountField`): the value of the field as an `AmountField`.
* **asDateField()** (`DateField`): the value of the field as a `DateField`.
* **asClassificationField()** (`ClassificationField`): the value of the field as a `ClassificationField`.

#### Generated Object Field

By default, non-list objects will be stored in a `GeneratedObject` structure, which are an extension of simple hashmaps. These fields have access to the following:

* **asStringField()** (`StringField`): the value of the field as a `StringField`.
* **asAmountField()** (`AmountField`): the value of the field as an `AmountField`.
* **asDateField()** (`DateField`): the value of the field as a `DateField`.
* **asClassificationField()** (`ClassificationField`): the value of the field as a `ClassificationField`.
* **getAsPolygon()** (`Polygon`): representation of the field as a `Polygon`.
* **getPageId()** (`integer`): retrieves the ID of the page the field was found on. Note: this isn't supported on some APIs.
* **getConfidence()** (`float`): retrieves the confidence score for a field, if it exists.

> Note: the `asXXXXField()` methods mentioned above will raise `MindeeException` if they do not correspond to the field's type.


---

# 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://docs.mindee.com/v1/integration/java-ocr-sdk/java-generated-ocr.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.
