> For the complete documentation index, see [llms.txt](https://docs.datasaur.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasaur.ai/api/run-ml-assisted-labeling.md).

# Run ML-Assisted Labeling

You can label a project using existing model that is provided by the app or your own model. Currently, this API only support the custom API, i.e. your own model. Also, this mutation is asynchronous so the response only returns the job information.

* Mutation: [autoLabelTokenBasedProject](https://docs.datasaur.ai/#mutation-autoLabelTokenBasedProject)
* Input: [AutoLabelTokenBasedProjectInput](https://docs.datasaur.ai/#definition-AutoLabelTokenBasedProjectInput)
* Response: [Job](https://docs.datasaur.ai/#definition-Job)

### **Example Request via cURL**

```javascript
curl --location --request POST 'https://app.datasaur.ai/graphql' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data-raw '{"operationName":"AutoLabelTokenBasedProjectMutation","variables":{"input":{"labelerEmail":"demo@datasaur.ai","options":{"numberOfFilesPerRequest":0,"serviceProvider":"CUSTOM"},"projectId":"HvdyIL2iwZn","targetAPI":{"endpoint":"https://custom-model.api.com/predict","secretKey":"secret"}}},"query":"mutation AutoLabelTokenBasedProjectMutation($input: AutoLabelTokenBasedProjectInput!) {  result: autoLabelTokenBasedProject(input: $input) {    id  status  progress  }}"}'
```

Below is the more readable version of request body from cURL command above.

```javascript
{
    "operationName": "AutoLabelTokenBasedProject",
    "variables": {
        "input": {
            "labelerEmail": "demo@datasaur.ai",
            "options": {
                "numberOfFilesPerRequest": 0,
                "serviceProvider": "CUSTOM"
            },
            "projectId": "HvdyIL2iwZn",
            "targetAPI": {
                "endpoint": "https://custom-model.api.com/predict",
                "secretKey": "secret"
            }
        }
    },
    "query": "mutation AutoLabelTokenBasedProjectMutation($input: AutoLabelTokenBasedProjectInput!) {  result: autoLabelTokenBasedProject(input: $input) {    id  status  progress  }}"
}
```

* **operationName**: you can fill any alphanumeric string in as the operationName. `AutoLabelTokenBasedProjectMutation` is fine as a default. Refer [this page](https://graphql.org/learn/queries/#operation-name) to organize operationName properly.
* **variables**
  * **input:** see the explanation of each variables [here](https://docs.datasaur.ai/exporttextprojectinput.doc). See the additional information for [AutoLabelProjectOptionsInput](https://docs.datasaur.ai/#definition-AutoLabelProjectOptionsInput) below.
    * Again, currently we only support CUSTOM `serviceProvider`
    * If the `numberOfFilesPerRequest` is 0, then it will request all lines in a document. If it's more than 0, the backend will batch the request based on how many lines for each request.
* **query:** Copy it from cURL example.

### Example Response

Here is the response when you execute the cURL command above.

```javascript
{
    "data": {
        "result": {
            "id": "AutoLabelQueue:dcbf6ed3-3841-46c1-8f6a-2affb53ac637",
            "status": "IN_PROGRESS",
            "progress": 50
        }
    },
    "extensions": {}
}
```

This doesn't mean the process is finished. To make sure the job is finished or to get any other information, please see [this page](/api/get-data/check-job.md).


---

# 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.datasaur.ai/api/run-ml-assisted-labeling.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.
