创建图片
/v1/images/generations根据文本生成图片,或根据文本和一张或多张输入图片生成/编辑图片。
图像生成会在本次请求中直接返回结果,不需要像视频生成一样先提交任务再轮询结果。
你可以直接使用返回的 data[].url 下载图片。如需使用专用下载或删除接口,请先通过 GET /v1/images 获取图片记录 ID。
身份验证
Authorization Bearer
在 Authorization header 中使用 API key 作为 Bearer token。
Request Body
modelstringrequiredModel ID.
promptstringrequiredImage generation prompt.
nintegerNumber of images to generate.
sizestringRequested output image dimensions, such as width-by-height, when the model uses explicit image size values.
aspect_ratiostringRequested output image shape as a width-to-height ratio.
resolutionstringRequested output image resolution or resolution tier.
qualitystringRequested generation quality or fidelity tier.
seedintegerOptional numeric seed for repeatable generation when deterministic seeding is supported.
prompt_extendbooleanPrompt extension flag.
negative_promptstringNegative prompt.
max_reference_imagesintegerReference image limit.
watermarkbooleanControls whether generated images include a watermark when supported.
response_formatstringResponse format.
imagesarrayReference images.
sequential_image_generationstringSequential image generation mode.
sequential_image_generation_optionsobjectSequential image generation configuration.
sequential_image_generation_options.max_imagesintegerMaximum number of images to generate in sequential mode.
optimize_prompt_optionsobjectPrompt optimization configuration.
optimize_prompt_options.modestringPrompt optimization mode, such as standard or fast.
strengthnumberInput image influence strength.
enable_interleavebooleanInterleaved generation flag.
enable_web_searchbooleanWeb search flag.
output_formatstringRequested file format for generated image outputs.
streambooleanStreaming response flag.
metadataobjectApplication metadata.
extra_bodyobjectAdditional request body fields.
provider_optionsobjectUpstream configuration.
Response
createdintegerUnix 时间戳。
modelstring实际服务请求的模型标识。
dataobject[]生成的图片。
data.urlstring下载生成图片的 URL。
data.b64_jsonstring模型返回 Base64 图片时的内容。
data.output_formatstring模型返回时的输出图片格式,例如 jpeg 或 png。
data.sizestring模型返回时的输出图片尺寸,格式为 <width>x<height>。
data.errorobject | null单张图片生成失败时的错误详情。
usageobject本次请求的用量信息。
usage.generated_imagesinteger模型成功生成的图片数量。
usage.input_imagesinteger模型返回时的输入参考图片数量。
usage.output_tokensinteger模型返回时,生成图片消耗的输出 token。
usage.total_tokensinteger模型返回时,本次请求消耗的总 token。
errorobject返回错误 payload 时的请求级错误详情。
error.codestring错误码。
error.messagestring错误信息。