Skip to main content

Images

Description

Images module provides functionality to upload, retrieve, and manage images in the system.

Methods

create

Creates/uploads a new image. Accepts either a file object or a URL to an image.

Props

NameTypeRequiredDescription
fileBlobNo*The image file to upload
urlstringNo*URL of the image to upload

*Either file or url must be provided, but not both.

Returns

Promise<Image> - The created image object

Example

const image = await client.images.create({ file: blob });
// or
const image = await client.images.create({ url: 'https://example.com/image.png' });

get

Retrieves information about a specific image by its ID.

Props

NameTypeRequiredDescription
idstringYesThe ID of the image to retrieve

Returns

Promise<Image | undefined> - The image object if found, undefined otherwise

Example

const image = await client.images.get({ id: '123' });

getUrls

Retrieves URLs for multiple images by their IDs.

Props

NameTypeRequiredDescription
idsstring[]YesArray of image IDs to get URLs for

Returns

Promise<{ [imageId: string]: string }> - An object mapping image IDs to their URLs

Example

const urls = await client.images.getUrls({ ids: ['123', '456'] });
console.log(urls['123']); // 'https://example.com/image1.png'

Types

Image

Represents an image object in the system.

PropertyTypeDescription
idstringUnique identifier for the image
widthnumberWidth of the image in pixels
heightnumberHeight of the image in pixels