Files
aiartstudio/shared/types/openai.ts
T
2026-04-26 00:39:28 +08:00

116 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export type BaseOptions = {
/** OpenAI API Key */
apiKey: string;
/** 模型名称 */
model: string;
/** 自定义 baseURL */
baseURL?: string;
};
/**
* 图片生成请求体。
*/
export interface IImageGenerateRequest {
/** 图片提示词 */
prompt?: string;
}
/**
* 图片生成成功后返回给前端的数据。
*/
export interface IImageGenerateData {
/** NewAPI 上游返回的图片访问地址,前端当前优先展示这个地址 */
imageUrl: string;
/** Lsky 图床归档后的图片访问地址,归档失败时为空 */
hostedImageUrl?: string | null;
/** 上游返回的修订提示词,可能为空 */
revisedPrompt?: string;
}
/**
* 生图任务状态。
*/
export type ImageGenerationStatus =
| "QUEUED"
| "RUNNING"
| "SUCCEEDED"
| "FAILED";
/**
* 生图历史列表项。
*/
export interface IImageHistoryItem {
/** 生图记录 IDBigInt 会以字符串返回 */
id: string;
/** NewAPI 用户 ID */
userId: number;
/** 用户输入的生图提示词 */
prompt: string;
/** 生图状态 */
status: ImageGenerationStatus;
/** 生图模型 */
model: string;
/** 图片尺寸 */
size: string;
/** 生图开始时间,ISO 字符串 */
startedAt: string;
/** 生图结束时间,ISO 字符串,未结束时为 null */
endedAt: string | null;
/** 生图耗时,单位毫秒 */
durationMs: number | null;
/** NewAPI 上游返回的图片访问地址 */
imageUrl: string | null;
/** Lsky 图床归档后的图片访问地址 */
hostedImageUrl: string | null;
/** 上游返回的修订提示词,可能为空 */
revisedPrompt: string | null;
/** 失败原因或图床归档提示 */
errorMessage: string | null;
/** 记录创建时间,ISO 字符串 */
createdAt: string;
}
/**
* 生图历史详情。
*/
export interface IImageHistoryDetail extends IImageHistoryItem {
/** 图片 MIME 类型,可能为空 */
imageMimeType: string | null;
/** 完整上游生图接口返回结果 */
upstreamResponse: unknown;
/** 完整 Lsky 图床上传接口返回结果 */
hostedResponse: unknown;
}
/**
* 生图历史分页响应。
*/
export interface IImageHistoryListData {
/** 当前页码 */
page: number;
/** 每页数量 */
pageSize: number;
/** 当前用户未删除记录总数 */
total: number;
/** 当前页历史记录 */
items: IImageHistoryItem[];
}
/**
* 全局生图统计响应。
*/
export interface IImageGenerationStatsData {
/** 总生图请求数,包含成功和失败 */
totalRequests: number;
/** 成功生图请求数 */
successRequests: number;
/** 失败生图请求数 */
failedRequests: number;
/** 排队中请求数,预留异步任务使用 */
queuedRequests: number;
/** 进行中请求数 */
runningRequests: number;
/** 成功生成图片总数 */
totalImages: number;
}