# Training Images ## Add `client.models.trainingImages.add(stringmodelID, TrainingImageAddParamsparams, RequestOptionsoptions?): TrainingImageAddResponse` **post** `/models/{modelId}/training-images` Add a new training image to the given `modelId` ### Parameters - `modelID: string` - `params: TrainingImageAddParams` - `originalAssets?: boolean` Query param: If set to true, returns the original asset without transformation - `assetId?: string` Body param: The asset ID to use as a training image (example: "asset_GTrL3mq4SXWyMxkOHRxlpw"). If provided, "data" and "name" parameters will be ignored. - `assetIds?: Array` Body param: The asset IDs to use as training images (example: ["asset_GTrL3mq4SXWyMxkOHRxlpw", "asset_GTrL3mq4SXWyMxkOHRxlpw"]) Used in batch mode, up to 10 asset IDs are allowed. Cannot be used with "assetId" or "data" and "name" parameters. - `data?: string` Body param: The training image as a data URL (example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=") - `name?: string` Body param: The original file name of the image (example: "my-training-image.jpg") - `preset?: "default" | "style" | "subject"` Body param: The preset to use for training images - `"default"` - `"style"` - `"subject"` ### Returns - `TrainingImageAddResponse` - `trainingImage: TrainingImage` - `id: string` The training image ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") - `automaticCaptioning: string` Automatic captioning of the image - `createdAt: string` The training image upload date as an ISO string (example: "2023-02-03T11:19:41.579Z") - `description: string` Description for the image - `downloadUrl: string` The URL of the image - `name: string` The original file name of the image (example: "my-training-image.jpg") ### Example ```typescript import Scenario from '@scenario-labs/sdk'; const client = new Scenario({ apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted }); const response = await client.models.trainingImages.add('modelId'); console.log(response.trainingImage); ``` #### Response ```json { "trainingImage": { "id": "id", "automaticCaptioning": "automaticCaptioning", "createdAt": "createdAt", "description": "description", "downloadUrl": "downloadUrl", "name": "name" } } ``` ## Replace Pairs `client.models.trainingImages.replacePairs(stringmodelID, TrainingImageReplacePairsParamsparams, RequestOptionsoptions?): TrainingImageReplacePairsResponse` **put** `/models/{modelId}/training-images/pairs` Replace all training image pairs for the given `modelId` ### Parameters - `modelID: string` - `params: TrainingImageReplacePairsParams` - `body: Array` Array of training image pairs - `instruction?: string` The instruction for the image pair, source to target - `sourceId?: string` The source asset ID (must be a training asset) - `targetId?: string` The target asset ID (must be a training asset) ### Returns - `TrainingImageReplacePairsResponse` - `count: number` Number of training image pairs - `pairs: Array` Array of training image pairs - `instruction?: string` The instruction for the image pair, source to target - `sourceId?: string` The source asset ID (must be a training asset) - `targetId?: string` The target asset ID (must be a training asset) ### Example ```typescript import Scenario from '@scenario-labs/sdk'; const client = new Scenario({ apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted }); const response = await client.models.trainingImages.replacePairs('modelId', { body: [{}] }); console.log(response.count); ``` #### Response ```json { "count": 0, "pairs": [ { "instruction": "instruction", "sourceId": "sourceId", "targetId": "targetId" } ] } ``` ## Replace `client.models.trainingImages.replace(stringtrainingImageID, TrainingImageReplaceParamsparams, RequestOptionsoptions?): TrainingImageReplaceResponse` **put** `/models/{modelId}/training-images/{trainingImageId}` Replace the given `trainingImageId` for the given `modelId` ### Parameters - `trainingImageID: string` - `params: TrainingImageReplaceParams` - `modelId: string` Path param: The training image's `modelId` - `originalAssets?: boolean` Query param: If set to true, returns the original asset without transformation - `assetId?: string` Body param: The asset ID to use as a training image (example: "asset_GTrL3mq4SXWyMxkOHRxlpw"). If provided, "data" and "name" parameters will be ignored. - `assetIds?: Array` Body param: The asset IDs to use as training images (example: ["asset_GTrL3mq4SXWyMxkOHRxlpw", "asset_GTrL3mq4SXWyMxkOHRxlpw"]) Used in batch mode, up to 10 asset IDs are allowed. Cannot be used with "assetId" or "data" and "name" parameters. - `data?: string` Body param: The training image as a data URL (example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=") - `name?: string` Body param: The original file name of the image (example: "my-training-image.jpg") - `preset?: "default" | "style" | "subject"` Body param: The preset to use for training images - `"default"` - `"style"` - `"subject"` ### Returns - `TrainingImageReplaceResponse` - `trainingImage: TrainingImage` - `id: string` The training image ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") - `automaticCaptioning: string` Automatic captioning of the image - `createdAt: string` The training image upload date as an ISO string (example: "2023-02-03T11:19:41.579Z") - `description: string` Description for the image - `downloadUrl: string` The URL of the image - `name: string` The original file name of the image (example: "my-training-image.jpg") ### Example ```typescript import Scenario from '@scenario-labs/sdk'; const client = new Scenario({ apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted }); const response = await client.models.trainingImages.replace('trainingImageId', { modelId: 'modelId', }); console.log(response.trainingImage); ``` #### Response ```json { "trainingImage": { "id": "id", "automaticCaptioning": "automaticCaptioning", "createdAt": "createdAt", "description": "description", "downloadUrl": "downloadUrl", "name": "name" } } ``` ## Delete `client.models.trainingImages.delete(stringtrainingImageID, TrainingImageDeleteParamsparams, RequestOptionsoptions?): TrainingImageDeleteResponse` **delete** `/models/{modelId}/training-images/{trainingImageId}` Delete the given `trainingImageId` from the given `modelId` ### Parameters - `trainingImageID: string` - `params: TrainingImageDeleteParams` - `modelId: string` The training image's `modelId` ### Returns - `TrainingImageDeleteResponse = unknown` ### Example ```typescript import Scenario from '@scenario-labs/sdk'; const client = new Scenario({ apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted }); const trainingImage = await client.models.trainingImages.delete('trainingImageId', { modelId: 'modelId', }); console.log(trainingImage); ``` #### Response ```json {} ``` ## Domain Types ### Training Image Add Response - `TrainingImageAddResponse` - `trainingImage: TrainingImage` - `id: string` The training image ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") - `automaticCaptioning: string` Automatic captioning of the image - `createdAt: string` The training image upload date as an ISO string (example: "2023-02-03T11:19:41.579Z") - `description: string` Description for the image - `downloadUrl: string` The URL of the image - `name: string` The original file name of the image (example: "my-training-image.jpg") ### Training Image Replace Pairs Response - `TrainingImageReplacePairsResponse` - `count: number` Number of training image pairs - `pairs: Array` Array of training image pairs - `instruction?: string` The instruction for the image pair, source to target - `sourceId?: string` The source asset ID (must be a training asset) - `targetId?: string` The target asset ID (must be a training asset) ### Training Image Replace Response - `TrainingImageReplaceResponse` - `trainingImage: TrainingImage` - `id: string` The training image ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") - `automaticCaptioning: string` Automatic captioning of the image - `createdAt: string` The training image upload date as an ISO string (example: "2023-02-03T11:19:41.579Z") - `description: string` Description for the image - `downloadUrl: string` The URL of the image - `name: string` The original file name of the image (example: "my-training-image.jpg") ### Training Image Delete Response - `TrainingImageDeleteResponse = unknown`