> 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/raw-text-ocr-models/sdk-integration/ocr-quick-start.md).

# OCR Quick Start

## Install the Client Library

Install the Mindee Client Library for your language or framework of choice

{% tabs %}
{% tab title="Python" %}
Requires Python ≥ 3.9. Python ≥ 3.11 is recommended.

Simply install the [PyPi package](https://pypi.org/project/mindee/) using `pip`:

```sh
pip install -U mindee~=5.1
```

{% endtab %}

{% tab title="Node.js" %}
Requires Node.js ≥ 20.1. Node.js ≥ 22 is recommended.

Simply install the [NPM package](https://www.npmjs.com/package/mindee):

```sh
npm install mindee@^5.5.0
```

{% endtab %}

{% tab title="PHP" %}
Requires PHP ≥ 8.1. PHP ≥ 8.3 is recommended.

Simply install the [Packagist package](https://packagist.org/packages/mindee/mindee) using [composer](https://getcomposer.org/):

```sh
php composer.phar require "mindee/mindee:>=3.0"
```

{% endtab %}

{% tab title="Ruby" %}
Requires Ruby ≥ 3.2.

Simply install the [gem](https://rubygems.org/gems/mindee) using:

```shell
gem install mindee -v '~> 5.2'
```

{% endtab %}

{% tab title="Java" %}
Requires Java ≥ 11. Java ≥ 17 is recommended.

Group ID: `com.mindee.sdk`\
Artifact ID: `mindee-api-java`\
Version: `5.2.0` or greater

There are various installation methods, Maven, Gradle, etc:

[Installation Details](https://central.sonatype.com/artifact/com.mindee.sdk/mindee-api-java)
{% endtab %}

{% tab title=".NET" %}
.NET ≥ 8.0 is recommended.

Simply install the [NuGet package](https://www.nuget.org/packages/Mindee) using `dotnet add`:

```sh
dotnet add package Mindee --version 4.4
```

{% endtab %}
{% endtabs %}

Don't see support for your favorite language or framework? [Make a feature request!](https://feedback.mindee.com/?b=682f69c9e2404756e7e68d1c)

## Send a File and Poll

Use the client library to send the file to your OCR Model and return the result.

{% tabs %}
{% tab title="Python" %}
Requires Python ≥ 3.9. Python ≥ 3.11 is recommended.\
Requires the [Mindee Python SDK](https://pypi.org/project/mindee/) version **4.35.1** or greater.

{% code lineNumbers="true" %}

```python
from mindee import PathInput
from mindee.v2 import (
    Client,
    OCRParameters,
    OCRResponse,
)

input_path = "/path/to/the/file.ext"
api_key = "MY_API_KEY"
model_id = "MY_MODEL_ID"

# Init a new client
mindee_client = Client(api_key)

# Set Raw OCR parameters
model_params = OCRParameters(
    # ID of the model, required.
    model_id=model_id,
)

# Load a file from disk
input_source = PathInput(input_path)

# Send for processing using polling
response = mindee_client.enqueue_and_get_result(
    OCRResponse,
    input_source,
    model_params,
)

# Print a brief summary of the parsed data
print(response.inference)

# Access the OCR result
pages: list = response.inference.result.pages
```

{% endcode %}

Also take a look at the [OCR Result](https://docs.mindee.com/ocr-models/sdk-integration/ocr-result) documentation.
{% endtab %}

{% tab title="Node.js" %}
Requires Node.js ≥ 20.1. Node.js ≥ 22 is recommended.\
Requires the [Mindee Node.js SDK](https://www.npmjs.com/package/mindee/) version **5.5.0** or greater.

{% code lineNumbers="true" %}

```javascript
import * as mindee from "mindee";
// If you're on CommonJS:
// const mindee = require("mindee");

const apiKey = "MY_API_KEY";
const filePath = "/path/to/the/file.ext";
const modelId = "MY_MODEL_ID";

// Init a new client
const mindeeClient = new mindee.Client(
  { apiKey: apiKey }
);

// Set Raw OCR parameters
const modelParams = {
  modelId: modelId,
};

// Load a file from disk
const inputSource = new mindee.PathInput({ inputPath: filePath });

// Send for processing
const response = await mindeeClient.enqueueAndGetResult(
  mindee.product.Ocr,
  inputSource,
  modelParams,
);

// print a string summary
console.log(response.inference.toString());

// Access the result OCR pages
const pages = response.inference.result.pages;
```

{% endcode %}

Also take a look at the [OCR Result](https://docs.mindee.com/ocr-models/sdk-integration/ocr-result) documentation.
{% endtab %}

{% tab title="PHP" %}
Requires PHP ≥ 8.1. PHP ≥ 8.3 is recommended.\
Requires the [Mindee PHP SDK](https://packagist.org/packages/mindee/mindee) version **3.0.0** or greater.

{% code lineNumbers="true" %}

```php
<?php

use Mindee\Input\PathInput;
use Mindee\V2\Client;
use Mindee\V2\Product\Ocr\Params\OcrParameters;
use Mindee\V2\Product\Ocr\OcrResponse;

$apiKey = "MY_API_KEY";
$modelId = "MY_MODEL_ID";
$filePath = "/path/to/the/file.ext";

// Init a new client
$mindeeClient = new Client($apiKey);

// Set Raw OCR parameters
$modelParams = new OcrParameters(
    // ID of the model, required.
    $modelId,
);

// Load a file from disk
$inputSource = new PathInput($filePath);

// Send for processing using polling
$response = $mindeeClient->enqueueAndGetResult(
    OcrResponse::class,
    $inputSource,
    $modelParams
);

// Print a summary of the response
echo strval($response->inference);

// Access the ocr results
$pages = $response->inference->result->pages;
```

{% endcode %}

Also take a look at the [OCR Result](https://docs.mindee.com/ocr-models/sdk-integration/ocr-result) documentation.
{% endtab %}

{% tab title="Ruby" %}
Requires Ruby ≥ 3.2.\
Requires the [Mindee Ruby SDK](https://rubygems.org/gems/mindee) version **5.2.1** or greater.

{% code lineNumbers="true" %}

```ruby
require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
model_id = 'MY_MODEL_ID'

# Init a new client
mindee_client = Mindee::V2::Client.new(api_key: api_key)

# Set Raw OCR parameters
model_params = {
    # ID of the model, required.
    model_id: model_id,
}

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_result(
    Mindee::V2::Product::OCR::OCR,
    input_source,
    model_params
)

# Access the result OCR pages
puts response.inference.result.pages
```

{% endcode %}

Also take a look at the [OCR Result](https://docs.mindee.com/ocr-models/sdk-integration/ocr-result) documentation.
{% endtab %}

{% tab title="Java" %}
Requires Java ≥ 11. Java ≥ 17 is recommended.\
Requires the [Mindee Java SDK](https://central.sonatype.com/artifact/com.mindee.sdk/mindee-api-java) version **5.2.0** or greater.

{% code lineNumbers="true" %}

```java
import com.mindee.input.LocalInputSource;
import com.mindee.v2.MindeeClient;
import com.mindee.v2.product.ocr.OcrResponse;
import com.mindee.v2.product.ocr.params.OcrParameters;
import java.io.IOException;

public class SimpleMindeeClientV2 {

  public static void main(String[] args)
      throws IOException, InterruptedException
  {
    String apiKey = "MY_API_KEY";
    String filePath = "/path/to/the/file.ext";
    String modelId = "MY_MODEL_ID";

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

    // Set Raw OCR parameters
    var modelParams = OcrParameters
        // ID of the model, required.
        .builder(modelId)
        .build();

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

    // Send for processing using polling
    OcrResponse response = mindeeClient.enqueueAndGetResult(
        OcrResponse.class,
        inputSource,
        modelParams
    );

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

    // Access the result OCR pages
    var pages = response.getInference().getResult().getPages();
  }
}
```

{% endcode %}

Also take a look at the [OCR Result](https://docs.mindee.com/ocr-models/sdk-integration/ocr-result) documentation.
{% endtab %}

{% tab title=".NET" %}
.NET ≥ 8.0 is recommended.\
Requires the [Mindee .NET SDK](https://www.nuget.org/packages/Mindee) version **4.3.0** or greater.

{% code lineNumbers="true" %}

```csharp
using Mindee;
using Mindee.Input;
using Mindee.V2;
using Mindee.V2.Product.Ocr;
using Mindee.V2.Product.Ocr.Params;

string filePath = "/path/to/the/file.ext";
string apiKey = "MY_API_KEY";
string modelId = "MY_MODEL_ID";

// Construct a new client
Client mindeeClient = new Client(apiKey);

// Set Raw OCR parameters
var modelParams = new OcrParameters(
    modelId: modelId
);

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

// Upload the file
var response = await mindeeClient.EnqueueAndGetResultAsync<OcrResponse>(
    inputSource, modelParams);

// Print a summary of the response
System.Console.WriteLine(response.Inference.ToString());

// Access the OCR result pages
var ocrPages = response.Inference.Result.Pages;
```

{% endcode %}

Also take a look at the [OCR Result](https://docs.mindee.com/ocr-models/sdk-integration/ocr-result) documentation.
{% endtab %}
{% endtabs %}


---

# 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/raw-text-ocr-models/sdk-integration/ocr-quick-start.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.
