# API

UBIAI supports fully programmatic file upload, auto-labeling, model training and inference. The API feature is only available for Team, Team Pro and Enterprise packages.

1. **Upload Files with API**

In order to automate the upload process, UBIAI offers fully programmatic file upload with the auto-annotation option. Below are the file formats that can be uploaded by API:



* JSON, TSV
* PDF, HTML, DOCX, CSV, ZIP and TXT
* Native PDF (OCR), PNG/JPG (OCR)

In order to upload the files with API, simply go to the API tab in the annotation interface and select "Upload files with API". If you would like to pre-annotate your files, check the "Auto annotate while uploading" box and select the method of pre-annotation as hown below:

<figure><img src="https://3073024999-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0hqV0hLtifjaqlfkGT7n%2Fuploads%2FOPr0az6zxYjpHT5MmVYO%2Fupload_file.png?alt=media&#x26;token=c8600cf5-6b82-4b88-b66d-f0728d80853b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3073024999-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0hqV0hLtifjaqlfkGT7n%2Fuploads%2FxRSRCbQwIzh4EUrD3IE9%2Fupload_file2.png?alt=media&#x26;token=1ce8a5c8-a808-40cc-98bd-20996abb05bb" alt=""><figcaption></figcaption></figure>

2. **Export Annotation with API:**

In addition to file upload, you can export your annotation programmatically using our API feature.

In the API tab, select "Export files with API" and select the export type as shown below, the python code will be updated accordingly. Then simply copy/paste the code and run the script in your application:

<figure><img src="https://3073024999-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0hqV0hLtifjaqlfkGT7n%2Fuploads%2FOqqZhbOsB4zlyi7RbKJM%2Fexport_file.png?alt=media&#x26;token=98d92d20-1edb-4071-b509-3446585667aa" alt=""><figcaption></figcaption></figure>

3. **Model Training with API:**

Programmatic model training for NER and relation extraction can be easily done with our API.

* Go to the models menu
* Create a new model (NER or relation extraction)
* Select the training data
* Go to the "Train model with API" and copy/paste the generated code in your application
* Run the script to launch the training (you can input the hyperparameters of your choice)

<figure><img src="https://3073024999-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0hqV0hLtifjaqlfkGT7n%2Fuploads%2FBXfuj80gaQbAyGEpqUaA%2FML_API.png?alt=media&#x26;token=42e55ed2-64cc-470d-85b2-6e5db40260ea" alt=""><figcaption></figcaption></figure>

4. **Inference API:**

After training the model, you can directly start running predictions on your texts using our API:

* Go to the Analysis menu and select the API tab.
* Select your trained custom model
* Copy/paste the generated code in your application and launch the script (make sure to input your texts in the "inputs" list)

<figure><img src="https://3073024999-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0hqV0hLtifjaqlfkGT7n%2Fuploads%2Fl6rgeIp9QCywMC3cvIkE%2Finference.png?alt=media&#x26;token=5350d82a-f756-48ac-884a-5a428fd30fb1" alt=""><figcaption></figcaption></figure>

