Skip to content

Latest commit

 

History

History
386 lines (268 loc) · 29.6 KB

README.md

File metadata and controls

386 lines (268 loc) · 29.6 KB

Dataset

(dataset)

Overview

Available Operations

createDataset

This endpoint creates a new dataset

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.CreateDatasetResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

deleteDatasetById

This endpoint deletes the specific dataset

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.DeleteDatasetByIdResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

getDatasetById

This endpoint gets the specific dataset

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.GetDatasetByIdResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

uploadDatasetImage

This endpoint returns presigned details to upload a dataset image to S3

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.UploadDatasetImageResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

uploadDatasetImageFromGen

This endpoint will upload a previously generated image to the dataset

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.UploadDatasetImageFromGenResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*