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
Name | Type | Required | Description |
---|---|---|---|
file | Blob | No* | The image file to upload |
url | string | No* | 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
Name | Type | Required | Description |
---|---|---|---|
id | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
ids | string[] | Yes | Array 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.
Property | Type | Description |
---|---|---|
id | string | Unique identifier for the image |
width | number | Width of the image in pixels |
height | number | Height of the image in pixels |