ai-utils.js
Version:
Build AI applications, chatbots, and agents with JavaScript and TypeScript.
24 lines (23 loc) • 1.04 kB
TypeScript
import { FunctionOptions } from "../FunctionOptions.js";
import { CallMetadata } from "../executeCall.js";
import { ImageGenerationModel, ImageGenerationModelSettings } from "./ImageGenerationModel.js";
/**
* Generates a base64-encoded image using a prompt.
* The prompt format depends on the model.
* For example, OpenAI image models expect a string prompt,
* and Stability AI models expect an array of text prompts with optional weights.
*
* @example
* const { image } = await generateImage(
* new StabilityImageGenerationModel(...),
* [
* { text: "the wicked witch of the west" },
* { text: "style of early 19th century painting", weight: 0.5 },
* ]
* );
*/
export declare function generateImage<PROMPT, RESPONSE, SETTINGS extends ImageGenerationModelSettings>(model: ImageGenerationModel<PROMPT, RESPONSE, SETTINGS>, prompt: PROMPT, options?: FunctionOptions<SETTINGS>): Promise<{
image: string;
response: RESPONSE;
metadata: CallMetadata<ImageGenerationModel<PROMPT, RESPONSE, SETTINGS>>;
}>;