Skip to content
SuperToken 文档

参数、尺寸与错误

公共参数

参数支持范围
n / output.count省略或 1
quality / output.quality省略或 auto
output_format / output.format省略或 png
response_format同步支持 urlb64_json;异步始终为 URL
aspect_ratio / output.aspect_ratio1:12:33:23:44:34:55:49:1616:921:9
resolution / output.resolution5120.5K1K2K4K0.5K 会规范化为 512
mask / input.mask不支持

明确提交 backgroundoutput_compressioninput_fidelitystylemoderationpartial_imagesstreamwatermark 或旧 extra_fields 会被拒绝。

模型支持的 resolution
gemini-3.1-flash-image512 / 0.5K / 1K / 2K / 4K
gemini-3-pro-image-count1K / 2K / 4K

未提交尺寸控制时默认使用 1:1/1K,避免静默提高生成成本。

标准尺寸映射

sizeGemini aspectRatioGemini imageSize
1024x10241:11K
1024x15362:31K
1536x10243:21K
2048x20481:12K
2048x30722:32K
3072x20483:22K

其他标准尺寸会返回 unsupported_image_sizesize 是兼容映射,不是精确像素承诺;例如 2048x3072 会请求 2:3/2K,部分 Adobe/We-AI 渠道可能实际返回 1696x2528。实际宽高始终以响应或资源元数据为准。

冲突按字段判断:

  • size 不能与公开 aspect_ratioresolution 或任何 provider imageConfig 同时使用。
  • aspect_ratio 只与 provider imageConfig.aspectRatio 冲突。
  • resolution 只与 provider imageConfig.imageSize 冲突。
  • 公开字段可以与不控制同一字段的 provider 配置合并,例如公开 aspect_ratio 与 provider imageSize

provider_options.google

aspect_ratioresolution 已是公开参数。provider_options.google 用于采样、thinking、安全策略等 Gemini 高级参数;旧 imageConfig 继续兼容 Adobe/We-AI 渠道。JSON 请求使用对象,multipart 请求使用 JSON 字符串:

json
{
  "provider_options": {
    "google": {
      "generationConfig": {
        "temperature": 0.8,
        "topP": 0.95,
        "topK": 40,
        "seed": 7,
        "imageConfig": {
          "aspectRatio": "16:9",
          "imageSize": "2K"
        },
        "thinkingConfig": {
          "thinkingBudget": 256,
          "thinkingLevel": "HIGH",
          "includeThoughts": true
        }
      },
      "safetySettings": [
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "threshold": "BLOCK_ONLY_HIGH"
        }
      ]
    }
  }
}

以下 snake_case 别名同样被接受,并在服务端统一为官方 camelCase:

camelCasesnake_case
generationConfiggeneration_config
safetySettingssafety_settings
topPtop_p
topKtop_k
imageConfigimage_config
aspectRatioaspect_ratio
imageSizeimage_size
thinkingConfigthinking_config
thinkingBudgetthinking_budget
thinkingLevelthinking_level
includeThoughtsinclude_thoughts

同一字段同时提交 camelCase 与 snake_case 会返回 duplicate_parameter

禁止覆盖

provider_options 不能覆盖:

  • modelcontents、endpoint 或鉴权;
  • toolssystemInstruction
  • responseModalitiescandidateCount

这些字段由统一任务协议和服务端凭证租约控制。

Usage

json
{
  "prompt_tokens": 25,
  "completion_tokens": 1680,
  "total_tokens": 1705,
  "input_tokens": 25,
  "output_tokens": 1680,
  "cached_tokens": 0,
  "image_tokens": 0,
  "audio_tokens": 0,
  "prompt_tokens_details": {
    "image_tokens": 0,
    "cached_tokens": 0
  },
  "completion_tokens_details": {
    "reasoning_tokens": 0
  }
}

输入图片 Token 只计入输入明细;输出图片和思考 Token 计入 completion。同步响应、异步查询、消费日志和 Webhook 使用同一份归一化 usage。

错误码

错误码原因
unsupported_image_count请求输出数量不是 1
unsupported_maskGemini 编辑提交了 Mask
unsupported_qualityquality 不是 auto
unsupported_output_format输出格式不是 PNG
unsupported_image_sizesize 不在严格映射表内
unsupported_aspect_ratioaspect_ratio 不在支持列表
unsupported_image_resolutionresolution 不受支持,或当前模型不支持该档位
duplicate_parameter别名重复,或多个字段控制同一比例/分辨率
invalid_provider_options命名空间、字段或值不在白名单
executor_not_configuredGemini Images 执行器尚未配置
upstream_errorGemini 上游请求失败
missing_image_result上游响应中没有图片
unexpected_image_count上游意外返回多张图片
"524"内部图片服务暂时不可用,可以有限重试

"524" 是统一图片任务协议的字符串业务错误码,不是 HTTP 524。任务查询仍返回任务对象,并以 status: "failed" 表示终态;公开响应和 Webhook 不会包含内部渠道、子分组、余额、供应商错误码或上游 Request ID。

仅当 error.retryabletrue 时建议自动重试。终态失败后应使用新的 Idempotency-Key 创建新任务;复用原 Key 只会返回原失败任务。

下一步

SuperToken - 让全球顶级 AI 模型触手可达