# AnnoLab SDK

AnnoLab has a python SDK to improve the experience of performing certain AnnoLab actions. We highly recommend using this SDK for things like uploading files, as it greatly speeds uploads and simplifies the experience.

[Pypi link](https://pypi.org/project/annolab/)

### Installing via pip

```
pip install annolab
```

### Using the sdk

To get started, ensure you have an annolab account at <https://app.annolab.ai/signup> and have created an API Key. Instructions for creating an API Key may be found at <https://docs.annolab.ai/>.

1. Create an instance of the SDK passing your api\_key.

```python
from annolab import Annolab
lab = AnnoLab(api_key='YOUR_API_KEY')
```

### Using the sdk to upload pdf source

For pdf uploads to work, the user associated with your api key must have permissions to edit sources on your project. Permissions can be modified by admins on the appropriate project details page found under <https://app.annolab.ai/projects>

Obtain the project

```python
project = lab.find_project('My Project')
```

Upload from a local file system to a specific directory in your project. OCR the pdf using annolab OCR

```python
project.create_pdf_source(
    file='/path/to/file', 
    name='custom_name.pdf', 
    directory='Uploads',
    ocr=True,
    ocrProvider='textract_plus', # textract_plus is the same as "Annolab" OCR
)
```

### Using the sdk to upload pdf source and trigger an AI workflow

For pdf uploads invoking workflows to work, the user associated with your api key must have permissions to edit sources on your project and must have the ability to "run" machine learning models on your project.

Obtain the project

```python
project = lab.find_project('My Project')
```

Upload from a local file system to a specific directory in your project. Use the OCR provider and suite of ML models specified by a workflow

```python
project.create_pdf_source(
    file='/path/to/file', 
    name='custom_name.pdf', 
    directory='Uploads',
    workflow='aircraft_title', 
)
```


---

# Agent Instructions: 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:

```
GET https://docs.annolab.ai/master/annolab-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
