Optional
endpoint: stringReadonly
clientReadonly
endpointPrivate
completeCreates and uploads asset, then returns the Asset.
Will select the most efficient transfer_api_type if left undefined.
OctoAIValidationError if no token was found when creating the Client class.
This is used with CreateAssetRequest. The data
field requires
data from the matching asset_type. This includes FileData,
CheckpointData, LoraData, VAEData,
and TextualInversionData.
Creating an asset from a local file:
import { Client, LoraData } from "@octoai/client";
const client = new Client(process.env.OCTOAI_TOKEN);
const loraData = {
asset_type: "lora",
data_type: "fp16",
engine: "image/stable-diffusion-v1-5",
file_format: "safetensors",
trigger_words: ["origami paper"],
} as LoraData;
const createdAsset = await client.asset.create({
file: "./test_assets/origami-paper.safetensors",
asset_type: "lora",
description: "origami paper lora",
data: loraData,
name: "origami-paper",
is_public: false,
});
Creating an asset via URL upload:
import { Client, LoraData } from "@octoai/client";
const client = new Client(process.env.OCTOAI_TOKEN);
const loraData = {
asset_type: "lora",
data_type: "fp16",
engine: "image/stable-diffusion-xl-v1-0",
file_format: "safetensors",
trigger_words: ["my trigger word"],
} as LoraData;
const createdAsset = await client.asset.create({
url: "<ASSET_DOWNLOAD_URL>",
asset_type: "lora",
description: "My SDXL LoRA",
data: loraData,
name: "my-sdxl-lora",
is_public: false,
});
Private
createDelete an asset.
ID of asset to be deleted. Should start with asset
.
OctoAIValidationError if no token was found when creating the Client class or if id is invalid.
Get a single asset.
GetAssetRequest - includes either the name or the id of the requested asset.
OctoAIValidationError - if no token was found when creating
the Client class, if neither an id
nor name
is provided, if both
are provided, or if the name or id provided is invalid.
Private
getList assets based on the search parameters provided. Array of assets can be
accessed in response's data
field.
ListAssetsRequest - parameters to use to filter assets in response.
This method is used with the ListAssetsRequest class to query
the assets and return. If there are more assets, the ListAssetsResponse
will return true
for has_more as well as the total
number of assets.
You can search by name
, data_type
such as "fp16", set a limit
, or
start the next request at a certain offset
for larger requests.
An example of how to request octoai public assets is below:
const client = new Client(process.env.OCTOAI_TOKEN);
const octoAssets = await client.asset.list({
is_public: true,
owner: "octoai",
engine: "image/stable-diffusion-v1-5",
asset_type: "lora",
});
OctoAIValidationError if there isn't a token set in the client.
Private
uploadPrivate
Private
uploadPrivate
Private
validateWaits for an Asset to be ready to use. Useful when uploading assets via URL.
The Asset to poll.
Optional
options: WaitForOptionsAdditional options for changing the poll interval and timeout durations.
A ready Asset.
OctoAIValidationError Thrown if the asset has an upload error or if the asset is rejected for safety.
OctoAITimeoutError Thrown if the asset isn't ready by the specified timeout. Doesn't necessarily indicate a failure.
Generated using TypeDoc
The AssetLibrary class. Generally accessed through the client through
client.asset
, but can be instantiated directly if a different endpoint is desired.