> 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/crop-models/extraction-model-chaining.md).

# Extraction Model Chaining

Selectively extract data from detected crops.

Link a Crop model to one or more [Extraction Models](/extraction-models/extraction-models-overview.md), to automatically extract structured data from documents based on their detected class.

Since Crop models can detect multiple document classes on the same page, several different extractions can be made on a single image file.

Crop models work on multi-page files, with potentially multiple crop items on each page.

Note:  Each crop item is limited to an area on a single page. If you need a single extraction result covering multiple pages, take a look at [Split Models](/split-models/split.md) instead.

## Extraction Set Up

### At Model Creation

When creating your Crop model, you'll be adding document classes in the creation window.

For each document class, you can link one of your [Extraction Models](/extraction-models/extraction-models-overview.md) for chaining. The Extraction Model must exist prior to the Crop Model creation.

Use the search field to filter available extraction models.

### After Model Creation

This works exactly like when creating at model creation.

Simply go to your Crop Model's "Utility Configuration" page and adjust as needed.

You can add new classes, remove classes, and change Extraction Models.

### Selectively Extracting

If a detected class has no linked Extraction Model, no extraction runs for that crop.

This allows selectively extracting some parts while ignoring others.

Let's say your users upload images of their trip documents on their hotel table, typically but not limited to: plane tickets, travel receipts, driver license, and passport.

You need only the passports.

In your Crop configuration, add a `passport` class and an `other`  class, and only link an extraction model to the `passport` class.

All crop items will get classified, but only those linked to an Extraction Model will have extraction results.

{% hint style="info" icon="lightbulb" %}
Add an `other` class in addition to classes of interest to you, unless all potential document types are known in advance.
{% endhint %}

## Token Usage With Chaining

The initial model (Split, Crop, Classification) is provided at no additional cost to you if it triggers additional processing using an Extraction model.

The possible credit consumption scenarios are as follows:

* extraction model not chained ⇒ token usage of initial model
* extraction models chained ⇒ token usage of the extraction model, including any activated [optional features](/extraction-models/optional-features.md).

Token consumption is calculated per page as is standard for our models.

For Crop models specifically, there can be multiple chained extractions on the same file. Since each page may contain multiple documents, the total pages processed can be greater than the total number of pages in the source document.

For example, on a JPEG image where 4 receipts are detected and each receipt is chained to an extraction model, processing the file will consume 4 pages worth of credits.

Detected crops not chained to an extraction model do not consume extraction credits.

Some examples:

* JPEG image file, a single document is detected and chained ⇒ 1 page of Extraction credit consumed.
* JPEG image file, no documents detected ⇒ 1 page of Crop credit consumed.
* PNG image file, 3 document are detected and chained ⇒ 3 page of Extraction credit consumed.
* HEIC image file, 3 documents are detected and chained, a single document is detected but **not** chained ⇒ 3 pages of Extraction credit consumed.
* 75-page PDF file, no documents detected ⇒ 75 pages of Crop credit consumed.
* 23-page PDF file, 37 documents detected and chained ⇒ 37 pages of Extraction credit consumed.

## Access Extraction Results

When an Extraction Model is linked, each detected crop item with that class contains an Extraction Response object.

That object is the same as the response returned by a standalone Extraction request.

Because Crop works at object level, several crop items on the same page can each contain their own extraction result.

Check [Crop Result](/crop-models/sdk-integration/crop-result.md) for details on accessing crop items and their extraction responses.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mindee.com/crop-models/extraction-model-chaining.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
