Skip to content
Get started
TypeScript

Models

API reference for enhanced model methods.

The models resource is enhanced so that retrieve() returns a response where response.model has a .run() method. All other original methods (create, update, list, delete, copy, deleteImages, download, getBulk, transfer, updateTags, and the description, examples, presets, promptGuide, scores and trainingImages sub-resources) are inherited unchanged. train is enhanced: see Training.


Get a model by ID. Returns an enhanced response where response.model has .run().

Signature

client.models.retrieve(
modelID: string,
query?: ModelRetrieveParams | null,
options?: RequestOptions,
): APIPromise<EnhancedModelRetrieveResponse>

Parameters

Name Type Description
modelID string The model ID to retrieve.
query? ModelRetrieveParams | null Optional query parameters.

Returns

APIPromise<EnhancedModelRetrieveResponse> — the standard retrieve response with model enhanced:

Property Type Description
model ModelRetrieveResponse.Model & ModelEntity All original model fields plus .run().

EnhancedModelRetrieveResponse and ModelEntity are not exported from the package root. Import them from @scenario-labs/sdk/lib/models if you need to name them.

Example

import Scenario from '@scenario-labs/sdk';
const client = new Scenario({ apiKey: '...', apiSecret: '...' });
const { model } = await client.models.retrieve('model_...');
console.log(model.id); // original field
console.log(model.name); // original field

Available on response.model after calling client.models.retrieve(). Generates with this model. Shortcut for client.generate.runModel(model.id, params) — no need to repeat the model ID. Returns an enhanced response where response.job has .wait(). See Jobs for the full .wait() reference.

Signature

response.model.run(
params: GenerateRunModelParams,
options?: RequestOptions,
): APIPromise<WithJob<GenerateRunModelResponse>>

Parameters

Name Type Description
params.body unknown Model-specific inputs (prompt, images, etc.). The accepted inputs come from GET /models/{modelId}.
params.dryRun? 'true' | 'api' Estimates the creative units cost (269 response) instead of running. '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.ipDetection? boolean Runs an IP-detection preflight (Enterprise plan only). The detection fee is charged even with dryRun.
params.projectId? string Project that owns the resource.

If the model was retrieved with a projectId (the typed projectId param or options.query.projectId on retrieve(), or the client’s projectId), .run() reuses that project, and response.job.wait() polls in it too. An explicit non-empty projectId on this call, in params or options.query, wins over the captured project. An empty or unset one does not.

Returns

APIPromise<WithJob<GenerateRunModelResponse>> — a generate response where response.job has .wait().

Example

import Scenario from '@scenario-labs/sdk';
const client = new Scenario({ apiKey: '...', apiSecret: '...' });
const { model } = await client.models.retrieve('model_...');
const response = await model.run({
body: { prompt: 'a medieval shield with dragon emblem' },
});
const completed = await response.job.wait();
console.log(completed.status); // 'success'
console.log(completed.metadata?.assetIds);