Model Training API Documentation

Vision Model Training API
Introduction
Custom Model Training API

The custom model training API provides a straightforward approach for training unique AI models, including vision AI and natural language processing. The API provides developers with a practical and efficient way to generate, handle, and retrieve the dataset necessary for the training process. Once all training data has been processed, the model can be trained and can be run on demand.

The web interface uses the public REST API.



REST API for Developers

Create, train, and run custom models using your preferred programming language. The developer API allows the opportunity to build customized interfaces, and to integrate the custom model capabilities into any project, or to enable end-users to train and run a model within an existing application.

  • The training and inference endpoints are separated.
    • Each endpoint allows up to 90 requests per minute, for a total of 180 requests in any one minute period. Limits can be increased by request.
  • Training data is not available for export.
    • Users are responsible for maintaining a local copy of all training data.
  • Model weights are not available externally.
    • Model can only be run through REST API at this time. Download and conversion of select models are available to eligible organizations for local usage. Request
  • Vision models are capable of running inference at over 144 frames per second.
    • Camera streaming currently only available for private preview. Request

Model Training Endpoints

When creating and managing a model, a dedicated endpoint is used.
For most public model types, the endpoint will be train.astica.ai

When running a model a different endpoint is used.
This is based on the type of model, for example, detect.astica.ai

Please refer to the documentation for the type of model trained for exact endpoints used during the training and inference process.

While running a model using the API, you will specify the the model_version which is produced at the time of model training. Each time the model is trained, a new model version is created. All versions of your model will remain available for evaluation and comparison purposes.


Model Training Web UI

Using the web interface is recommended to help quickly familiarize with model training concepts, revise model training data, or to run experimentation in real-time.

Use a web browser to experience the complete custom model training pipeline. Within just a couple of minutes using a prepared dataset, you can begin to optimize or run inferencee on your custom model.

Using a web camera, or by uploading a file directly, you can receive output in real-time as you modify the training data within the interface. This web interface utilizes the same REST API offered to developers.

Create a Model Online
Custom Model Training API - Create Model
Submit a request to create a new model.
Creating a Model

Create a New Model

This API call allows provides a method to create a new model / dataset.

Endpoint
POST https://train.astica.ai/model/create
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • dataset_title: The title of the dataset (string, required).
  • dataset_type: The type of the dataset (string, required).
  • dataset_purpose: The purpose of the dataset (string, required).
  • dataset_tags: A comma-separated list of keywords or tags associated with the dataset (string, optional).
Request Example
var requestData = {
    tkn: 'api_key_here',
    dataset_title: dataset_title,
    dataset_type: dataset_type,
    dataset_purpose: dataset_purpose,
    dataset_tags: dataset_tags
};
Response Structure
{
    "status": "OK",
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - List Models
Submit a request to view a list of all models and datasets that you have created.
View a list of all models within the account.

List All Datasets

The Dataset View API allows you to retrieve a list of all the datasets you've created so far. This API is useful when you need to view and manage your datasets programmatically.

Endpoint
POST https://train.astica.ai/model/view
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • model_id: The ID of your model (string, required).
Request Example
var requestData = {
    tkn: 'api_key_here'
};
Response Structure
{
    "status": "OK",
    "astica": {
        "request": "dataset",
        "requestType": "list"
    },
    "dataset_list": [
        // Array of dataset objects
    ]
}
Response Object

Each object in the dataset_list array contains the following properties:

  • id: The unique identifier of the dataset (integer).
  • trained: Returns either 0 or 1 to indicate whether the model has been trained. (integer).
  • model_version: The unique reference to the model, generated after training (string).
  • title: The title of the model / dataset (string).
  • numClass: The number of classes added to the model (integer).
  • numSample: The number of samples added to the model (integer).
  • total_size: The total size of the model or dataset in MB (float).
  • date_trained: The Unix timestamp of when the model was last trained (integer).
  • date_created: The Unix timestamp of when the model or dataset was created (integer).
Response Example
{
    "status": "OK",
    "astica": {
        "request": "dataset",
        "requestType": "list"
    },
    "dataset_list": [
        {
            "id": 19241,
            "title": "My first model",
            "numClass": 3,
            "numSample":231,
            "total_size":5.04,
            "date_trained": 1685444210,
            "date_created": 1685422390
        },
        {
            "id": 23854,
            "title": "This is another model",
            "numClass": 11,
            "numSample":1853,
            "total_size":183.3,
            "date_trained": 1685421180,
            "date_created": 1690573749
        }
    ]
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - View Model Data
Insert training data into a model by refencing the corresponding model id .
Upload New Samples

View Model Data

The View Dataset API allows you to view all labeled classes and uploaded sample data for a specific dataset.

Endpoint
POST https://train.astica.ai/model/view
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • model_id: The ID of your model (string, required).
Request Structure
requestData = {
    'tkn': 'api_key_here',
    'model_id': '10484'
}
url = 'https://train.astica.ai/model/view'
Response Structure
{
    "status": "OK",
    "astica": {
        "request": "dataset",
        "requestType": "view"
    },
    "dataset": {
        // Dataset object
    }
}
Response Object

The object sent back to a successful request contains the following properties:

  • id: The unique identifier of the dataset (integer).
  • title: The title of the model dataset (string).
  • numClass: The number of classes added to the model (integer).
  • numSample: The number of samples added to the model (integer).
  • total_size: The total size of the model or dataset in MB (float).
  • date_trained: The Unix timestamp of when the model was last trained (integer).
  • date_created: The Unix timestamp of when the model dataset was created (integer).
  • class_list: An array of labeled class objects, each containing the following properties:
    • id: The unique identifier of the labeled class (integer).
    • title: The title of the labeled class (string).
    • totalSize: The total size of the labeled class in MB (float).
    • date_created: The Unix timestamp of when the labeled class was created (integer).
    • samples: An array of sample objects associated with the labeled class, with the following properties:
      • id: The unique id of this sample (integer).
      • uid: The user provided id of this sample (string).
      • size: The size of the sample image in MB (float).
      • date_created: The Unix timestamp of when the sample was created (integer).
Response Example
{
    "status": "OK",
    "astica": {
        "request": "dataset",
        "requestType": "view"
    },
    "dataset": {
        "id": 3,
        "title": "My first model",
        "numClass": 3,
        "numSample":231,
        "total_size":5.04,
        "date_trained": 1685421180,
        "date_created": 1690573749,
        "class_list": [
            {
                "id": 11,
                "title": "Can",
                "date_created": 1685253130,
                "samples": [
                    {
                        "id": 132726,
                        "uid": "uniqueString_123",
                        "size": 0.253747,
                        "date_created": "1685253132"
                    },
                    ...
                ],
                "totalSize": 8.47
            },
            ...          
        ]
    }
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - Add Training Data
Insert training data into a model by refencing the corresponding model id .
Upload New Samples

Add Training Data

This endpoint allows training data and samples to be added to the provided model_id.

Endpoint
POST https://train.astica.ai/model/upload
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • model_id: The ID of your model (int, required).
  • model_class: The title of the class to add the sample into. Class will be created if it does not exist. (string, required).
  • input: For vision models this can be https url or base64 encoded string of an image. (string, required)
  • uid: A user-provided string corresponding to the image for easier reference (string, optional)
Request Structure
requestData = {
    'tkn': 'api_key_here',
    'model_id': '1495',
    'model_class': 'Dog',
    'input': 'https://www.astica.org/inputs/analyze_3.jpg',
    'uid': 'optional identifier here'
}
url = 'https://train.astica.ai/model/upload'
Response Structure
{
    "status": "OK"
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - Initialize Training
A model can be trained after adding at least two different classes.
Train a Model using REST API

Start Training the Model

When a valid request is made to this endpoint, a new training round will occur. The process will be initiated immediately and the total time required for training will depend on the number of samples and resolution of the data.

In most cases training will be complete within 5 to 10 minutes. For larger vision model training, the duration can average at 100ms per sample. The web interface is capable of providing simulated model output in real-time based on your training data. You can access it at any time, including for models which have been created using the API.

Each time a model has been trained, a new model version will be created. Requests to run the model should always use the latest model version generated after training and it can be viewed within the "View Model" or "List Models" API call.

Endpoint
POST https://train.astica.ai/model/model_train
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • model_id: The ID of the model to be trained (int, required).
Request Structure
requestData = {
    'tkn': 'api_key_here',
    'model_id': '28941'
}
url = 'https://train.astica.ai/model/model_train'
Response Structure
{
    "status": "OK"
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - Run a Model
Run a custom model using the REST API using the model_id and model_version
Running a Custom Model

Generate Model Output

After a model has been trained it can be run on demand using REST API. Note that each model type uses a different endpoint, unique from training related API calls.

Endpoint
POST https://detect.astica.ai/detect
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • model_id: The ID of the model to be removed (int, required).
  • model_version: Corresponds to model revision, generated after training. (string, required).
  • input: For vision models this can be https url or base64 encoded string of an image. (string, required)
Request Structure
requestData = {
    'tkn': 'api_key_here',
    'model_id': '28941',
    'model_version': '28941_20913',
    'input': 'https://www.astica.org/inputs/analyze_3.jpg',
}
url = 'https://detect.astica.ai/detect'
Response Structure
{
    "status": "OK",
    "output": "Dog",
    "confidence": "100"
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - Remove a Sample
Remove training data from a model or dataset by providing a sample_id or sample_uid.
Removing a Sample

Remove Training Data

This request allows the removal of previously uploaded samples and training data. Training data occupied by the sample will be free for immediate reuse.

Endpoint
POST https://train.astica.ai/model/sample_remove
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • sample_id: The ID of your sample to be removed (int, required).
  • sample_uid: Used in place of sample_id: user provided id of this sample (string). (string, optional).
Request Structure
requestData = {
    'tkn': 'api_key_here',
    'sample_id': '41315',
    'sample_uid': ''
}
url = 'https://train.astica.ai/model/sample_remove'
Response Structure
{
    "status": "OK"
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - Remove a Class
Remove an entire class and it's training data from a model or dataset by providing a class_id.
Removing a Class

Remove Training Data

This request allows the removal of previously uploaded samples and training data. Training data occupied by the sample's training data will be free for immediate reuse.

Endpoint
POST https://train.astica.ai/model/class_remove
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • class_id: The ID of the class to be removed (int, required).
Request Structure
requestData = {
    'tkn': 'api_key_here',
    'class_id': '138432',
}
url = 'https://train.astica.ai/model/class_remove'
Response Structure
{
    "status": "OK"
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}
Custom Model Training API - Remove a Model
Remove a model and all of the training data by providing a model_id.
Removing a Model

Remove Training Data

This endpoint can be used to remove an entire modal, including all classes and training data.

Endpoint
POST https://train.astica.ai/model/model_remove
Request Parameters

The following parameters should be included in your request:

  • tkn: Your API key (string, required).
  • model_id: The ID of the model to be removed (int, required).
Request Structure
requestData = {
    'tkn': 'api_key_here',
    'model_id': '28941',
}
url = 'https://train.astica.ai/model/model_remove'
Response Structure
{
    "status": "OK"
}
Error Handling

In case of an error, the API will return an error object with the following properties:

  • status: A string indicating the error, e.g., ERROR.
  • error: A description of the error (string).
Error Response Example
{
    "status": "ERROR",
    "error": "Invalid API key"
}

astica ai Discover More AI

Experiment with different kinds of artificial intelligence. See, hear, and speak with astica.

Return to Dashboard
You can return to this page at any time.
Success Just Now
Copied to clipboard
Success Just Now
Submission has been received.
Success Just Now
Account preferences have been updated.