@h-lumos/llm-sdk
Version:
122 lines (120 loc) • 4.47 kB
TypeScript
import { default as OpenAI } from 'openai';
import { RequestOptions } from 'openai/core';
import { APIResource } from '../../resource';
export declare class Images extends APIResource {
/**
* Creates an image given a prompt.
*/
generate(params: ImageGenerateParams, options?: RequestOptions): Promise<OpenAI.ImagesResponse>;
protected waitTask(taskId: string, options?: RequestOptions): Promise<ImageTask.Image[]>;
}
declare namespace ImageTask {
type Image = {
url: string;
};
type FailedError = {
code: string;
message: string;
};
type Status = 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'UNKNOWN';
type Metrics = {
TOTAL: number;
SUCCEEDED: number;
FAILED: number;
};
}
export type ImageModel = Images.ImageModel;
export type ImageGenerateParams = Images.ImageGenerateParams;
export declare namespace Images {
type ImageModel = (string & NonNullable<unknown>) | 'wanx-v1' | 'stable-diffusion-v1.5' | 'stable-diffusion-xl';
interface ImageGenerateParams {
/**
* The model to use for image generation.
*
* @defaultValue wanx-v1
*/
model?: ImageModel | null;
/**
* A prompt is the text input that guides the AI in generating visual content.
* It defines the textual description or concept for the image you wish to generate.
* Think of it as the creative vision you want the AI to bring to life.
* Crafting clear and creative prompts is crucial for achieving the desired results with Imagine's API.
* For example, A serene forest with a river under the moonlight, can be a prompt.
*/
prompt: string;
/**
* The negative_prompt parameter empowers you to provide additional
* guidance to the AI by specifying what you don't want in the image.
* It helps refine the creative direction, ensuring that the generated
* content aligns with your intentions.
*/
negative_prompt?: string | null;
/**
* The size of the generated images.
*
* @defaultValue 1024*1024
*/
size?: (string & NonNullable<unknown>) | '1024*1024' | null;
/**
* The style of the generated images.
*
* - \<photography\> 摄影
* - \<portrait\> 人像写真
* - \<3d cartoon\> 3D卡通
* - \<anime\> 动画
* - \<oil painting\> 油画
* - \<watercolor\>水彩
* - \<sketch\> 素描
* - \<chinese painting\> 中国画
* - \<flat illustration\> 扁平插画
* - \<auto\> 默认
*
* 仅 wanx-v1 模型支持
*
* @defaultValue <auto>
*/
style?: '<photography>' | '<portrait>' | '<3d cartoon>' | '<anime>' | '<oil painting>' | '<watercolor>' | '<sketch>' | '<chinese painting>' | '<flat illustration>' | '<auto>' | null;
/**
* The number of images to generate. Must be between 1 and 4.
*
* @defaultValue 1
*/
n?: number | null;
/**
* The steps parameter defines the number of operations or iterations that the
* generator will perform during image creation. It can impact the complexity
* and detail of the generated image.
*
* Range: 30-50
*
* 仅 StableDiffusion 模型支持
*
* @defaultValue 40
*/
steps?: number | null;
/**
* The cfg parameter acts as a creative control knob.
* You can adjust it to fine-tune the level of artistic innovation in the image.
* Lower values encourage faithful execution of the prompt,
* while higher values introduce more creative and imaginative variations.
*
* Range: 1 - 15
*
* @defaultValue 10
*/
cfg?: number | null;
/**
* The seed parameter serves as the initial value for the random number generator.
* By setting a specific seed value, you can ensure that the AI generates the same
* image or outcome each time you use that exact seed.
*
* range: 1-Infinity
*/
seed?: number | null;
/**
* The format in which the generated images are returned.
*/
response_format?: 'url' | null;
}
}
export {};