---
title: "GET /ai/module/all"
method: GET
path: "/ai/module/all"
tags: ["/ai/module/"]
---

# GET /ai/module/all

`GET /ai/module/all`

description: "Access Token is incorrect.",
    type: ApiError,
  })

    status: HttpStatus.PAYMENT_REQUIRED,
    description: "An active subscription required to access this endpoint.",
    type: ApiError,
  })

    description: "A conflict error occured.",
    type: ApiError,
  })

    description: "The training request has been successfully sent.",
    type: AiModuleDto,
  })

    description: "A validation error occured.",
    type: ApiError,
  })
  async trainModule(


  ): Promise<AiModuleDto> {
    const user: User = req.user;

    if (!aiTrainingRequest)
      throw new HttpException("Incorrect body.", HttpStatus.BAD_REQUEST);

    if (
      !GenerationModelAccessRightsData[aiTrainingRequest.model].canTrainModules
    )
      throw new HttpException(
        "Specified model does not support module training.",
        HttpStatus.BAD_REQUEST,
      );
if (!user.hasSubscription())
      throw new HttpException(
        "Incorrect subscription.",
        HttpStatus.PAYMENT_REQUIRED,
      );
if (aiTrainingRequest.steps < 50)
      throw new HttpException(
        "Training steps amount is too low.",
        HttpStatus.CONFLICT,
      );

    if (
      user.availableModuleTrainingSteps + user.purchasedModuleTrainingSteps <
      aiTrainingRequest.steps
    )
      throw new HttpException(
        "You have an insufficent amount of available training steps.",
        HttpStatus.CONFLICT,
      );

    if (process.env.NODE_ENV === "production") {
      const modules = (
        await this.aiModuleService.getAllUserModules(user)
      ).filter((item) => item.status == "pending" || item.status == "training");

      if (modules.length >= MAX_SIMULTANEOUS_TRAINING_MODULES)
        throw new HttpException(
          "You have reached the limit of concurrently training modules.",
          HttpStatus.CONFLICT,
        );
    }

    return await this.aiModuleService.trainModule(user, aiTrainingRequest);
  }

## Response `200`

- AiModuleDto[]
  - `data` string, required — Base64-encoded data if ready or it's a training request, error text if error
  - `lr` number, required — Learning rate
  - `steps` number, required — Training steps
  - `model` string, required — Used text generation model for module training
  - `lastUpdatedAt` number, required — UNIX timestamp
  - `status` 'pending' | 'training' | 'ready' | 'error', required
  - `lossHistory` number[], required — Recorded loss values
  - `id` string, required
  - `name` string, required
  - `description` string, required

## Other responses

- `401` — Access Token is incorrect.
- `500` — An unknown error occured.

---

[API](https://skmtc.net/novelai/apis/novelai-primary-api.md) · [All operations](https://skmtc.net/novelai/apis/novelai-primary-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/novelai/novelai-primary-api/revisions/327b3674db26/schema)
