> For the complete documentation index, see [llms.txt](https://ubiai.gitbook.io/ubiai-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ubiai.gitbook.io/ubiai-documentation/api.md).

# 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="/files/5Y8b6vhocqVeahAzpZNH" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Y2UbPjNyd6n62pGb4VwS" 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="/files/5GAGhilb1IcnP5eCxsRE" 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="/files/tiHmRfHv7heFX6SEcgtF" 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="/files/EPe3WI4RqJIIRqBKTz81" alt=""><figcaption></figcaption></figure>


---

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

```
GET https://ubiai.gitbook.io/ubiai-documentation/api.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.
