AI
This AI object provides methods that allow users to send prompts/requests to various AI models. The AI object is accessible via the ai
variable.
Example use of ai.images
async function generateImage() {
const url = await ai.images.generate(ctx.args.prompt);
return url;
}
generateImage().catch(console.log);
Example use of ai.vision
async function extractInfoFromImage() {
let text = await ai.vision.describe(ctx.args.prompt + ". Return ONLY the required info, no description, no additional notes", ctx.args.url);
if (text.startsWith("```csv")) {
text = text.substring(6);
} else if (text.startsWith("```")) {
text = text.substring(3);
}
if (text.endsWith("```")) {
text = text.substring(0, text.length - 3);
}
return text;
}
extractInfoFromImage().catch(console.log);
⚠️
This is available only to ENTERPRISE
and PARTNERSHIP
users
Properties
images.generate(prompt: string)
This method generates an image using the supplied prompt and returns the download URL of the image.
vision.describe(prompt: string, url: string)
This method is used to extract description/information from an image located at the supplied URL.