Felo API PlatformFelo API Platform
返回模型列表

Kling Image 4.0 Long Image API

Kling Image4.0 Long Image 面向电商与网页设计,可将产品图、参考图和文字整合成长幅视觉页面。

Kling Image4.0 Long Image 是 Kling AI 与 Kuaishou 推出的专业设计工具,支持文本输入、产品照片输入、风格参考图输入和主体参考图输入,并生成图像。它可将产品图、关键视觉元素与文字布局整合到一张长幅纵向图中,用于制作产品详情页和品牌网站视觉。

该模型适合电商页面、网页视觉、社交媒体轮播内容、故事板、海报、包装样机,以及在 CGI 制作前开发概念。ecommerce 技能支持1 到3 张产品照片和页面长度选择;webpage 技能支持最多1 张风格参考图和1 张主体参考图。它可在图像中渲染最多2,000 characters 的文字,支持超过70 种商业授权预设字体,以及 English、Simplified Chinese、Traditional Chinese、Japanese、Korean、Spanish 和 Portuguese。Long Image 模式支持1K 和2K 输出,不支持8K;要求最终交付精确细节时,CGI 更合适。

更新时间:

模型 ID

kling-4.0/long-image-generation
输入
文本 / 图像
输出
图像

核心要点

  • 单张长幅纵向设计图
  • 整合产品图与文字布局
  • 支持超过70 种预设字体
  • 支持1K 和2K 输出
  • 适合 ecommerce 与 webpage
  • 支持多语言文字排版

供应商

最优价格
1 个供应商

比较不同供应商的调用价格,点击供应商可查看完整费用和适用条件。

供应商 · 计费明细
可用率

基准测试

  • Image Generation Leaderboard

    排名

    第15
  • Text-to-Image Generation

    排名

    第7
  • UI/UX Design

    排名;Kling Image3.0 Omni 位于前80 名之外

    第4

分数来自模型厂商公布的数据,未独立验证。

快速开始

提交图片任务、轮询状态,再保存图片。以下示例使用 curl 和 Python 3(仅标准库,无需安装依赖)。

POST https://openapi.felo.ai/api/v1/images/generations

1填入 API key

从 Felo API Platform 账户创建 key,并设置为环境变量。

export FELO_API_KEY="YOUR_API_KEY"

2发起第一次请求

可选参数的取值因模型而异,示例不预设这些值;添加前请在 Playground 确认。请求字段与 model、prompt 同级,不包在 input 中。

curl --fail-with-body --max-time 60 "https://openapi.felo.ai/api/v1/images/generations" \
  -H "Authorization: Bearer $FELO_API_KEY" \
  -H "Content-Type: application/json" \
  -o created.json \
  -d '{
  "prompt": "A studio product photo of a ceramic coffee cup on warm linen, soft morning light",
  "model": "kling-4.0/long-image-generation"
}'

3轮询任务

提交后获得 task_id;queued、running 时每 3 秒查询一次,succeeded、failed 或 interrupted 时停止。示例最多等待 30 分钟。保留 created.json 可继续查询同一任务,避免重复提交。

python3 - <<'PY'
import json, os, time
from pathlib import Path
from urllib.parse import quote
from urllib.request import Request, urlopen

task = json.loads(Path("created.json").read_text())
task_id = task["task_id"]
url = "https://openapi.felo.ai/api/v1/images/generations/" + quote(task_id, safe="")
headers = {"Authorization": "Bearer " + os.environ["FELO_API_KEY"]}
deadline = time.monotonic() + 1800

while task["status"] in ("queued", "running"):
    if time.monotonic() >= deadline:
        raise TimeoutError(f"Keep task_id={task_id} to resume polling")
    time.sleep(3)
    with urlopen(Request(url, headers=headers), timeout=60) as response:
        task = json.load(response)
    if task.get("task_id") != task_id or task.get("kind") != "image":
        raise ValueError("Unexpected task response")
    print(task["status"])

if task["status"] != "succeeded":
    raise RuntimeError(task.get("error") or task["status"])
if not task.get("outputs"):
    raise ValueError("Task succeeded without image outputs")
Path("task.json").write_text(json.dumps(task))
print("Saved task.json")
PY

4下载输出

成功后从 task.json 读取 outputs 并保存。结果兼容 HTTPS 地址、URL 对象和 b64_json。签名地址请及时下载;下载图片时无需携带 API Key。

python3 - <<'PY'
import base64, json
from pathlib import Path
from urllib.request import urlopen

task = json.loads(Path("task.json").read_text())
if task.get("status") != "succeeded" or not task.get("outputs"):
    raise ValueError("No completed image outputs")
extensions = {"image/png": ".png", "image/jpeg": ".jpg", "image/webp": ".webp", "image/gif": ".gif", "image/avif": ".avif"}

for index, output in enumerate(task["outputs"], 1):
    item = output if isinstance(output, dict) else {}
    url = output if isinstance(output, str) else item.get("url") or item.get("unsigned_url")
    mime = item.get("media_type") or "image/png"
    if url and url.startswith("https://"):
        with urlopen(url, timeout=60) as response:
            data = response.read()
            mime = response.headers.get_content_type()
    elif url and url.startswith("data:image/") and ";base64," in url:
        header, encoded = url.split(",", 1)
        mime = header[5:].split(";", 1)[0]
        data = base64.b64decode(encoded, validate=True)
    elif item.get("b64_json"):
        data = base64.b64decode(item["b64_json"], validate=True)
    else:
        raise ValueError("Unrecognized image output")
    path = Path(f"image-{index}" + extensions.get(mime, ".bin"))
    path.write_bytes(data)
    print(path)
PY
input_references

编辑图片时,将示例地址替换为你的 HTTPS 图片地址或 base64 图片 data URL。提交一次后,沿用相同的轮询与保存步骤。

curl --fail-with-body --max-time 60 "https://openapi.felo.ai/api/v1/images/generations" \
  -H "Authorization: Bearer $FELO_API_KEY" \
  -H "Content-Type: application/json" \
  -o created.json \
  -d '{
  "prompt": "Keep the product and framing. Replace the background with a sunlit marble countertop.",
  "model": "kling-4.0/long-image-generation",
  "input_references": [
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/product.png"
      }
    }
  ]
}'

支持的参数

  • skill
  • length
  • prompt
  • resolution
  • input_references

想查看完整文档?

API 文档 →

常见问题

什么是 Kling Image 4.0 Long Image?

Kling Image4.0 Long Image 是 Kling AI 与 Kuaishou 推出的专业设计工具,支持文本输入、产品照片输入、风格参考图输入和主体参考图输入,并生成图像。它可将产品图、关键视觉元素与文字布局整合到一张长幅纵向图中,用于制作产品详情页和品牌网站视觉。 该模型适合电商页面、网页视觉、社交媒体轮播内容、故事板、海报、包装样机,以及在 CGI 制作前开发概念。ecommerce 技能支持1 到3 张产品照片和页面长度选择;webpage 技能支持最多1 张风格参考图和1 张主体参考图。它可在图像中渲染最多2,000 characters 的文字,支持超过70 种商业授权预设字体,以及 English、Simplified Chinese、Traditional Chinese、Japanese、Korean、Spanish 和 Portuguese。Long Image 模式支持1K 和2K 输出,不支持8K;要求最终交付精确细节时,CGI 更合适。

如何计算调用费用?

费用取决于你使用的供应商、对应价格和实际用量。长文本输入等情况可能适用不同价格,详见计费明细。

支持哪些输入和输出?

支持文本输入、产品照片输入、风格参考图输入和主体参考图输入,输出为图像。

ecommerce 和 webpage 技能分别支持什么?

ecommerce 技能接受1 到3 张产品照片和页面长度选择。webpage 技能支持最多1 张风格参考图和1 张主体参考图。

它适合哪些任务?

适合制作产品详情页、品牌网站视觉、社交媒体轮播内容、故事板、海报和包装样机,也适合在 CGI 制作前开发概念。

上下文与输出长度是多少?

上下文信息未提供;输出限制为2,000 characters。模型可在图像中渲染最多2,000 characters 的文字。

Long Image 模式支持哪些分辨率?

Long Image 模式支持1K 和2K 输出,不支持8K。

它与同系列模型有什么差别?

Long Image 专注于单张长幅纵向设计图;Kling Image4.0 的常规图像生成支持2K、4K 和8K,而 Kling Image3.0 Omni 在 UI/UX Design 基准中位于前80 名之外。

相关模型