跳转到主要内容

概述

Krea 允许企业启用零数据保留(Zero Data Retention)。目前公共 API 支持 Krea 2 Medium、Krea 2 Large 和 Krea 2 Medium Turbo。请联系 sales@krea.ai ↗ 以在你的工作区中启用此功能。启用支持后,按如下方式发起请求:
curl -X POST https://api.krea.ai/generate/image/krea/krea-2/medium \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Api-Zero-Data-Retention: 1" \
  -d '{
    "prompt": "a serene mountain landscape at sunset",
    "aspect_ratio": "1:1",
    "resolution": "1K"
  }'
所提供的任何 URL(例如风格参考图像)都必须是 base64 编码的 data URI。使用外部 URL 将会返回 422Zero data retention requires external asset inputs to be data URIs.
STYLE_REF_DATA_URI="data:image/png;base64,$(base64 < ./style-reference.png | tr -d '\n')"

curl -X POST https://api.krea.ai/generate/image/krea/krea-2/medium \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Api-Zero-Data-Retention: 1" \
  -d '{
    "prompt": "a serene mountain landscape at sunset",
    "aspect_ratio": "1:1",
    "resolution": "1K",
    "image_style_references": [
      {
        "url": "'"$STYLE_REF_DATA_URI"'",
        "strength": 0.6
      }
    ]
  }'