> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/augmenting-llms-with-smart-data-extraction/setup.md).

# Using Smart Data Extraction to Augment Contextual LLM Queries - Setup for Linux and Windows

Learn how to set up and run examples using the IDP RAG guide. Obtain licenses, install Python modules, and export keys for Apryse SDK and Open AI API. Get started now! The Apryse Server SDK streamline

## Setup

To run the provided examples, you will need to do some initial setup. All commands provided should be run from within the idp\_rag\_guide folder, unless otherwise stated. We'll ## assume you already have Python version >= 3.5 installed (If not, see instructions here). Perform the following setup steps:

## 1. Download Sample Code

[Download the the sample code](https://pdftron.s3.amazonaws.com/downloads/idp_rag_guide.zip) and unpack it. You should see an idp\_rag\_guide folder with the following structure:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
idp_rag_guide/
├── data
│   └── pdf
│       └── travel_expenses.pdf
├── doc_context.py
├── idp_rag_utils
│   ├── bookmark_utils.py
│   ├── document_structure.py
│   └── __init__.py
├── iso32000_rag.py
└── requirements.txt
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 2. Obtain an Apryse SDK license.

Your license should include our Smart Data Extraction offerings. If you don't already have one, you can [request a demo key](https://apryse.com/form/pws-non-tracking). A demo key will be sufficient to run the simpler [Document Context Example](/core/augmenting-llms-with-smart-data-extraction/documentcontextexample.md), but won't be able to run the more complex [Document RAG Example](/core/augmenting-llms-with-smart-data-extraction/iso32000ragexample.md).

Get your Apryse trial key:

{% @apryse-license-key/apryse-license-key platform="SERVER" variant="full" %}

## 3. Obtain an Open AI API Key.

Running the code included in this guide will make requests to Open AI that are not free, so you will need a funded account.

{% tabs %}
{% tab title="Linux" %}

## 4. Install the required Python modules.

We will do so in a virtual environment.

{% code lineNumbers="true" %}

```bash
python3 -m venv idp-venv
source idp-venv/bin/activate
python3 -m pip install -r requirements.txt
```

{% endcode %}

## 5. Export license keys

Export your Apryse SDK license key and Open AI API key as environment variables:

{% code lineNumbers="true" %}

```bash
export OPENAI_API_KEY=<your-api-key>
export APRYSE_SDK_LICENSE_KEY=<your-license-key>
```

{% endcode %}

## 6. Download

Download the Structured Output Module from Apryse. If you don't already have this installed, you can download it as follows:

{% code lineNumbers="true" %}

```bash
mkdir -p apryse_sdk_modules \
    && cd apryse_sdk_modules \
    && wget https://www.pdftron.com/downloads/StructuredOutputModuleLinux.tar.gz -O - | tar -xz \
    && cd ..
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}

## 4. Install

Install the required Python modules. We will do so in a virtual environment.

{% code lineNumbers="true" %}

```sh
python3 -m venv idp-venv
idp-venv/bin/activate
python3 -m pip install -r requirements.txt
```

{% endcode %}

## 5. Export

Export your Apryse SDK license key and Open AI API key as environment variables:

{% code lineNumbers="true" %}

```sh
set OPENAI_API_KEY=<your-api-key>
set APRYSE_SDK_LICENSE_KEY=<your-license-key>
```

{% endcode %}

## 6. Download

Download the Structured Output Module from Apryse. If you don't already have this installed, you can download it as follows:

{% code lineNumbers="true" %}

```sh
New-Item -ItemType Directory -Force -Path apryse_sdk_modules
Set-Location apryse_sdk_modules
Invoke-WebRequest -Uri https://www.pdftron.com/downloads/StructuredOutputModuleWindows.zip -OutFile StructuredOutputModuleWindows.zip
tar -xf StructuredOutputModuleWindows.zip
Remove-Item StructuredOutputModuleWindows.zip
Set-Location ..
```

{% endcode %}
{% endtab %}
{% endtabs %}

## 7. Optional download

If you plan on running the [Document RAG example](/core/augmenting-llms-with-smart-data-extraction/iso32000ragexample.md), you should also download the ISO\_32000-2 PDF standard, which is used in this sample, and is available for free [download from Adobe](https://developer.adobe.com/document-services/docs/assets/5b15559b96303194340b99820d3a70fa/PDF_ISO_32000-2.pdf). Place the downloaded file at the following location: idp\_rag\_guide/data/pdf/PDF\_ISO\_32000-2.pdf

You should now be ready to run the examples.

## Next Steps

[Document Context Example](/core/augmenting-llms-with-smart-data-extraction/documentcontextexample.md)

In this section, we show how to run a simple example that demonstrates how to attach contextual information from a document to your queries.


---

# 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.apryse.com/core/augmenting-llms-with-smart-data-extraction/setup.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.
