文生图公开 API

使用 API 密钥调用文生图接口。密钥需在管理后台申请。 非英语提示词会自动翻译成英文后再生成。分辨率会映射到 512×512、512×768、768×512 或 768×768;步数参数会被忽略。 生成依赖已打开的桥接页,图片链接约 24 小时后过期,请同时保存返回的 base64。
接口地址

POST https://img.tidaloath.kdns.fr/v1/generate

鉴权(任选其一):

管理后台:https://img.tidaloath.kdns.fr/admin

请求体

字段说明
prompt必填。提示词,支持中文(会自动翻译)。
width可选,默认 1024,会就近映射。
height可选,默认 1024,会就近映射。
steps可选,会被忽略。

成功响应

{
  "ok": true,
  "url": "https://img.tidaloath.kdns.fr/v1/images/<id>",
  "base64": "...",
  "mime": "image/jpeg",
  "width": 768,
  "height": 768,
  "steps_ignored": true,
  "prompt": "一只橘色的猫",
  "translated_prompt": "an orange cat"
}

常见错误

curl 示例

curl -sS -X POST https://img.tidaloath.kdns.fr/v1/generate \
  -H "Authorization: Bearer 你的API密钥" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"一只橘色的猫","width":768,"height":768,"steps":20}' \
  --max-time 200

Python 示例

部分防护会拦截默认的 Python-urllib 标识。请像下面这样设置 User-Agent(使用 requests 库时一般不必改)。curl 可直接调用。

import json, base64, urllib.request

req = urllib.request.Request(
    "https://img.tidaloath.kdns.fr/v1/generate",
    data=json.dumps({
        "prompt": "一只橘色的猫",
        "width": 768,
        "height": 768,
        "steps": 20,
    }).encode(),
    headers={
        "Authorization": "Bearer 你的API密钥",
        "Content-Type": "application/json",
        "User-Agent": "PictureCreatorAPI/1.0",
    },
    method="POST",
)
with urllib.request.urlopen(req, timeout=200) as r:
    data = json.loads(r.read().decode())

print("url:", data.get("url"))
if data.get("base64"):
    with open("out.jpg", "wb") as f:
        f.write(base64.b64decode(data["base64"]))