(dataset)
- createDataset - Create a Dataset
- deleteDatasetById - Delete a Single Dataset by ID
- getDatasetById - Get a Single Dataset by ID
- uploadDatasetImage - Upload dataset image
- uploadDatasetImageFromGen - Upload a Single Generated Image to a Dataset
This endpoint creates a new dataset
import { Leonardo } from "@leonardo-ai/sdk";
const leonardo = new Leonardo({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await leonardo.dataset.createDataset({
name: "<value>",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { LeonardoCore } from "@leonardo-ai/sdk/core.js";
import { datasetCreateDataset } from "@leonardo-ai/sdk/funcs/datasetCreateDataset.js";
// Use `LeonardoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const leonardo = new LeonardoCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await datasetCreateDataset(leonardo, {
name: "<value>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CreateDatasetRequestBody | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateDatasetResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
This endpoint deletes the specific dataset
import { Leonardo } from "@leonardo-ai/sdk";
const leonardo = new Leonardo({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await leonardo.dataset.deleteDatasetById("<id>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { LeonardoCore } from "@leonardo-ai/sdk/core.js";
import { datasetDeleteDatasetById } from "@leonardo-ai/sdk/funcs/datasetDeleteDatasetById.js";
// Use `LeonardoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const leonardo = new LeonardoCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await datasetDeleteDatasetById(leonardo, "<id>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The ID of the dataset to delete. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.DeleteDatasetByIdResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
This endpoint gets the specific dataset
import { Leonardo } from "@leonardo-ai/sdk";
const leonardo = new Leonardo({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await leonardo.dataset.getDatasetById("<id>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { LeonardoCore } from "@leonardo-ai/sdk/core.js";
import { datasetGetDatasetById } from "@leonardo-ai/sdk/funcs/datasetGetDatasetById.js";
// Use `LeonardoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const leonardo = new LeonardoCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await datasetGetDatasetById(leonardo, "<id>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The ID of the dataset to return. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetDatasetByIdResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
This endpoint returns presigned details to upload a dataset image to S3
import { Leonardo } from "@leonardo-ai/sdk";
const leonardo = new Leonardo({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await leonardo.dataset.uploadDatasetImage({
extension: "mpg4",
}, "<value>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { LeonardoCore } from "@leonardo-ai/sdk/core.js";
import { datasetUploadDatasetImage } from "@leonardo-ai/sdk/funcs/datasetUploadDatasetImage.js";
// Use `LeonardoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const leonardo = new LeonardoCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await datasetUploadDatasetImage(leonardo, {
extension: "mpg4",
}, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
requestBody |
operations.UploadDatasetImageRequestBody | ✔️ | Query parameters provided in the request body as a JSON object |
datasetId |
string | ✔️ | _"datasetId" is required |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.UploadDatasetImageResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
This endpoint will upload a previously generated image to the dataset
import { Leonardo } from "@leonardo-ai/sdk";
const leonardo = new Leonardo({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await leonardo.dataset.uploadDatasetImageFromGen({
generatedImageId: "<value>",
}, "<value>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { LeonardoCore } from "@leonardo-ai/sdk/core.js";
import { datasetUploadDatasetImageFromGen } from "@leonardo-ai/sdk/funcs/datasetUploadDatasetImageFromGen.js";
// Use `LeonardoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const leonardo = new LeonardoCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await datasetUploadDatasetImageFromGen(leonardo, {
generatedImageId: "<value>",
}, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
requestBody |
operations.UploadDatasetImageFromGenRequestBody | ✔️ | Query parameters to be provided in the request body as a JSON object |
datasetId |
string | ✔️ | The ID of the dataset to upload the image to. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.UploadDatasetImageFromGenResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |