// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class TrainingImages extends APIResource { /** * Delete the given `trainingImageId` from the given `modelId` */ delete( trainingImageID: string, params: TrainingImageDeleteParams, options?: RequestOptions, ): APIPromise { const { modelId, projectId } = params; return this._client.delete(path`/models/${modelId}/training-images/${trainingImageID}`, { query: { projectId }, ...options, }); } /** * Add a new training image to the given `modelId` */ add( modelID: string, params: TrainingImageAddParams, options?: RequestOptions, ): APIPromise { const { originalAssets, projectId, ...body } = params; return this._client.post(path`/models/${modelID}/training-images`, { query: { originalAssets, projectId }, body, ...options, }); } /** * Replace the given `trainingImageId` for the given `modelId` */ replace( trainingImageID: string, params: TrainingImageReplaceParams, options?: RequestOptions, ): APIPromise { const { modelId, originalAssets, projectId, ...body } = params; return this._client.put(path`/models/${modelId}/training-images/${trainingImageID}`, { query: { originalAssets, projectId }, body, ...options, }); } /** * Replace all training image pairs for the given `modelId` */ replacePairs( modelID: string, params: TrainingImageReplacePairsParams, options?: RequestOptions, ): APIPromise { const { body, projectId } = params; return this._client.put(path`/models/${modelID}/training-images/pairs`, { query: { projectId }, body: body, ...options, }); } } export type TrainingImageDeleteResponse = unknown; export interface TrainingImageAddResponse { trainingImage: TrainingImageAddResponse.TrainingImage; } export namespace TrainingImageAddResponse { export interface TrainingImage { /** * The training image ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; /** * Automatic captioning of the image */ automaticCaptioning: string; /** * The training image upload date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ createdAt: string; /** * Description for the image */ description: string; /** * The URL of the image */ downloadUrl: string; /** * The original file name of the image (example: "my-training-image.jpg") */ name: string; } } export interface TrainingImageReplaceResponse { trainingImage: TrainingImageReplaceResponse.TrainingImage; } export namespace TrainingImageReplaceResponse { export interface TrainingImage { /** * The training image ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; /** * Automatic captioning of the image */ automaticCaptioning: string; /** * The training image upload date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ createdAt: string; /** * Description for the image */ description: string; /** * The URL of the image */ downloadUrl: string; /** * The original file name of the image (example: "my-training-image.jpg") */ name: string; } } export interface TrainingImageReplacePairsResponse { /** * Number of training image pairs */ count: number; /** * Array of training image pairs */ pairs: Array; } export namespace TrainingImageReplacePairsResponse { export interface Pair { /** * The instruction for the image pair, source to target */ instruction?: string; /** * The source asset ID (must be a training asset) */ sourceId?: string; /** * The target asset ID (must be a training asset) */ targetId?: string; } } export interface TrainingImageDeleteParams { /** * Path param: The training image's `modelId` */ modelId: string; /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; } export interface TrainingImageAddParams { /** * Query param: If set to true, returns the original asset without transformation */ originalAssets?: boolean; /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; /** * Body param: The asset ID to use as a training image (example: * "asset_GTrL3mq4SXWyMxkOHRxlpw"). If provided, "data" and "name" parameters will * be ignored. */ assetId?: string; /** * 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. */ assetIds?: Array; /** * Body param: The training image as a data URL (example: * "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=") */ data?: string; /** * Body param: The original file name of the image (example: * "my-training-image.jpg") */ name?: string; /** * Body param: The preset to use for training images */ preset?: 'default' | 'style' | 'subject'; } export interface TrainingImageReplaceParams { /** * Path param: The training image's `modelId` */ modelId: string; /** * Query param: If set to true, returns the original asset without transformation */ originalAssets?: boolean; /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; /** * Body param: The asset ID to use as a training image (example: * "asset_GTrL3mq4SXWyMxkOHRxlpw"). If provided, "data" and "name" parameters will * be ignored. */ assetId?: string; /** * 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. */ assetIds?: Array; /** * Body param: The training image as a data URL (example: * "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=") */ data?: string; /** * Body param: The original file name of the image (example: * "my-training-image.jpg") */ name?: string; /** * Body param: The preset to use for training images */ preset?: 'default' | 'style' | 'subject'; } export interface TrainingImageReplacePairsParams { /** * Body param: Array of training image pairs */ body: Array; /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; } export namespace TrainingImageReplacePairsParams { export interface Body { /** * The instruction for the image pair, source to target */ instruction?: string; /** * The source asset ID (must be a training asset) */ sourceId?: string; /** * The target asset ID (must be a training asset) */ targetId?: string; } } export declare namespace TrainingImages { export { type TrainingImageDeleteResponse as TrainingImageDeleteResponse, type TrainingImageAddResponse as TrainingImageAddResponse, type TrainingImageReplaceResponse as TrainingImageReplaceResponse, type TrainingImageReplacePairsResponse as TrainingImageReplacePairsResponse, type TrainingImageDeleteParams as TrainingImageDeleteParams, type TrainingImageAddParams as TrainingImageAddParams, type TrainingImageReplaceParams as TrainingImageReplaceParams, type TrainingImageReplacePairsParams as TrainingImageReplacePairsParams, }; }