Training
API reference for enhanced model training methods.
client.models.train.trigger(modelID, params)
Section titled “client.models.train.trigger(modelID, params)”Trigger model training. Returns enhanced response with response.job.wait(). See Jobs for the full .wait() reference.
Signature
client.models.train.trigger( modelID: string, params: TrainTriggerParams, options?: RequestOptions,): APIPromise<WithJob<TrainTriggerResponse>>Parameters
| Name | Type | Description |
|---|---|---|
modelID |
string |
The model ID to train. |
params.parameters? |
TrainTriggerParams.Parameters |
Training hyperparameters (body), for example maxTrainSteps. |
params.dryRun? |
'true' | 'api' |
Estimates the creative units cost (269 response) instead of training. 'api' estimates at the API tier. The response then carries only the cost estimate (creativeUnitsCost) and no job, so don’t call .wait() on it. |
params.originalAssets? |
boolean |
If true, returns the original assets without transformation. |
params.projectId? |
string |
Project that owns the resource. |
params.trainingImagesCount? |
number |
Simulated number of training images, for dryRun. Ignored if the model already has training images. |
Returns
APIPromise<WithJob<TrainTriggerResponse>> — The response contains:
| Property | Type | Description |
|---|---|---|
job |
Job |
The training job, with .wait() method. Absent with dryRun. |
model |
TrainTriggerResponse.Model |
The model data. Absent with dryRun. |
creativeUnitsCost? |
number |
Creative units cost of the request (the estimate when dryRun is set). |
TrainTriggerParams and TrainTriggerResponse are not exported from the package root. Import them from @scenario-labs/sdk/resources/models/train if you need to name them.
Example
import Scenario from '@scenario-labs/sdk';
const client = new Scenario({ apiKey: '...', apiSecret: '...' });
const response = await client.models.train.trigger('model_my-custom-model', { parameters: { maxTrainSteps: 1000 },});
console.log(response.job.jobId); // 'job_...'console.log(response.job.status); // 'in-progress'
const completed = await response.job.wait({ intervalMs: 15_000, // poll every 15 seconds timeoutMs: 900_000, // wait up to 15 minutes});
console.log(completed.status); // 'success'