Routescope APIRoutescope API
模型接口API文档图像模型

Imagen

Imagen Fast、Standard、Ultra 图像生成聚合说明

Imagen 使用 Gemini Native predict 协议,路径为 /v1beta/models/{model}:predict。本页说明 Fast、Standard 和 Ultra 模型的选择方式与参数差异。

接口路径

方法路径用途
POST/v1beta/models/{model}:predictImagen 图像生成
POST
/v1beta/models/{model}:predict
curl -X POST "https://api.routescope.ai/v1beta/models/gpt-4o-mini:predict" \  -H "Content-Type: application/json" \  -d '{}'
{}

Authorization

BearerAuth

AuthorizationBearer <token>

模型 relay 接口鉴权。请求头:Authorization: Bearer

In: header

Path Parameters

model*string

Gemini 模型名。

Request Body

application/json

[key: string]?any

Response Body

application/json

模型选择表

模型 ID速度/质量取向适用场景
imagen-4.0-fast-generate-001优先速度低延迟草图、概念验证和批量创意。
imagen-4.0-generate-001标准质量高质量写实图像、插画、产品视觉和通用创意资产。
imagen-4.0-ultra-generate-001最高质量品牌主视觉、精细产品图和对画面质量要求高的场景。

通用参数

字段类型必选默认值说明
instancesarray预测输入数组,Imagen 通常只需要一个实例。
instances[].promptstring英文提示词,官方建议最大 480 tokens。
parameters.sampleCountinteger4生成图片数量,范围 14。Ultra 建议控制为 12
parameters.aspectRatiostring1:1画幅比例,支持 1:13:44:39:1616:9
parameters.personGenerationstringallow_adult人物生成策略,支持 dont_allowallow_adultallow_all;部分地区不允许 allow_all

模型差异参数

字段适用模型默认值/范围差异说明
parameters.imageSizeFast默认 1K,可用性以渠道为准Fast 版本可用性以渠道为准。
parameters.imageSizeStandard / Ultra默认 1K,支持 1K、2KStandard 和 Ultra 支持 1K、2K。

示例代码

curl "https://api.routescope.ai/v1beta/models/imagen-4.0-generate-001:predict" \
  -H "Authorization: Bearer $ROUTESCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "instances": [
      { "prompt": "A premium SaaS API gateway product poster, dark background, crisp typography" }
    ],
    "parameters": {
      "sampleCount": 1,
      "aspectRatio": "16:9",
      "imageSize": "2K",
      "personGeneration": "dont_allow"
    }
  }'

响应结构

Imagen 响应为 predictions 数组,图片以 bytesBase64EncodedmimeType 返回。不要改写成 Gemini candidates 或 OpenAI data 响应。

业务提示

  • 计费倍率按后台模型倍率与渠道倍率配置执行。
  • Fast 版本优先速度,复杂文字和高保真海报建议使用 Standard 或 Ultra。
  • Imagen 4 输出包含 SynthID 水印。
  • 批量生成时控制 sampleCount,避免单次请求过大导致超时。

最后更新于