Krea 2 Trainer
集成
模型 id
krea-2-trainer
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.ru/v1/run/krea-2-trainer?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://api.doitong.ru/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/krea-2-trainer?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://api.doitong.ru/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/krea-2-trainer", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
# 1. Connect once (Claude Code; Cursor, VS Code, Claude Desktop: https://doitong.com/zh/developers/docs/mcp)
claude mcp add --transport http doitong-models https://api.doitong.ru/v1/mcp \
--header "Authorization: Bearer $DOITONG_API_KEY"
# 2. Your agent calls the "run" tool with:
{
"model_id": "krea-2-trainer",
"input": {
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}
}
通过 Doitong API 调用 Krea 2 Trainer 模型(krea-2-trainer)。智能体文档:https://doitong.com/zh/developers/models/krea-2-trainer.md
POST https://api.doitong.ru/v1/run/krea-2-trainer?wait=20
Authorization: Bearer $DOITONG_API_KEY
Content-Type: application/json
{
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}
如果响应状态为 "queued" 或 "running",请轮询 GET https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20,直到状态变为 "succeeded";文件位于 outputs[].url。使用相同请求体 POST https://api.doitong.ru/v1/quote/krea-2-trainer,可在运行前返回确切价格。
与示例类似的文件: $0.30 300 API 积分 · ≈ ₽31.64 运行前会测量你的文件 在此页面运行
你的新 API 密钥。 它仅在此时显示,并且已填入下方的代码和 API 密钥字段中。请妥善保密:切勿将其放入在浏览器中运行的代码。
构建请求
控件根据模型架构生成。更改控件时,代码和价格会同步更新。
POST
/run/krea-2-trainer?wait=20
报价 → $0.30
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.ru/v1/run/krea-2-trainer?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://api.doitong.ru/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/krea-2-trainer?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://api.doitong.ru/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/krea-2-trainer", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "run",
"arguments": {
"model_id": "krea-2-trainer",
"input": {
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
},
"wait_seconds": 20
}
}
}
关于 Krea 2 Trainer
在 `images_data_url` 中的图像 .zip 文件上微调 LoRA,可选使用同名 .txt 说明和 `trigger_phrase`。`auto_captioning` 模式包括 Off、Object/Character、Style 和 Custom。`steps` 为 50 到 10000(默认 100),`resolution` 为 768 或 1024。输出 LoRA 权重和配置文件。
参数
名称类型
默认值允许值
描述
images_data_url必填
类型string
训练图像 .zip 的 URL,其中包含 PNG/JPG/JPEG/WebP 文件;如果任何图像既没有字幕文件,`trigger_phrase` 又为空,请求将以 422 失败。当 `trigger_phrase` 提供备用内容时,字幕可选;否则使用匹配的文件名主体:ROOT.EXT 与 ROOT.txt 配对,例如 001.jpg 与 001.txt。
trigger_phrase可选
类型string
默认值
当 `auto_captioning` 为 Off 且任何图像缺少字幕文件时所需的 DreamBooth-style 实例短语。它会为缺少 .txt 文件的图像提供字幕,并作为默认验证提示词的起始文本。
auto_captioning可选
类型enum
默认值Off
OffObject/CharacterStyleCustom
可选的字幕模式:Object/Character、Style 和 Custom 会调用 dataset-captioner 与 google/gemma-4-31B-it,而 Off 保留现有要求:每个图像都必须有匹配主文件名的 .txt 字幕文件,或使用 trigger_phrase 作为后备方案。对于生成的字幕,trigger_phrase 会进入字幕提示词,并根据所选 LoRA 字幕约定在生成的 sidecar 文件中进行规范化。
steps可选
类型integer
默认值100
50 – 10,000
LoRA 训练的步骤数。
learning_rate可选
类型number
默认值0.0005
0.000001 – 0.01
LoRA B 因子的学习率;当 `lora_a_lr_multiplier=1` 时也应用于 A;在 muon 下,它表示按 match_rms_adamw 缩放的等效 AdamW 学习率。对于恒定调度,Krea 建议范围为 3e-4–7e-4。
resolution可选
类型enum
默认值768
7681024
训练分辨率:1024 更注重最大精细度,768 可使训练速度提升约 1.7 倍、减少 VRAM 使用量,同时风格质量几乎相同。图像会缩放至覆盖目标正方形,然后从中心裁剪。
debug_dataset可选
类型boolean
默认值false
数据集下载选项,公开训练实际使用的内容,并在字幕回填或自动字幕生成后打包为归档文件。
必填
输出
GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
"id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
"object": "request",
"model": "krea-2-trainer",
"status": "succeeded",
"created_at": "2026-10-20T12:00:00Z",
"started_at": "2026-10-20T12:00:02Z",
"completed_at": "2026-10-20T12:00:09Z",
"queue_position": null,
"cost": {
"credits": 300,
"usd": "0.30",
"charged": 300,
"refunded": 0
},
"input": {
"images_data_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
},
"output": {
"lora_file": {
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
"content_type": "image/jpeg",
"file_name": "0-output.jpeg",
"file_size": 1843200
},
"config_file": {
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
"content_type": "image/jpeg",
"file_name": "0-output.jpeg",
"file_size": 1843200
},
"prompt_enhancement_system_prompt": "string",
"debug_dataset": {
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
"content_type": "image/jpeg",
"file_name": "0-output.jpeg",
"file_size": 1843200
}
},
"outputs": [
{
"type": "file",
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
"content_type": "image/jpeg",
"file_size": 1843200,
"stored": true
}
],
"error": null,
"metrics": {
"inference_seconds": 6.8
},
"urls": {
"self": "https://api.doitong.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
"cancel": "https://api.doitong.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
}
}
你的文件,由你选择每个 outputs[].url 都是存储中的副本:可永久保存(按 GB-月付费),也可免费保存 7 天,由账户设置或 ?storage= 决定。
每个模型的结构相同图像、视频和音频均包含 type、url、content_type、width、height 和 duration。output 是模型自身的结果对象。
输出字段
- lora_file
- object {url, content_type, file_name, file_size}训练得到的 Krea-2 LoRA 权重的 safetensors 格式下载 URL。
- config_file
- object {url, content_type, file_name, file_size}包含训练/LoRA 配置的 JSON 文件链接。
- prompt_enhancement_system_prompt
- string | null启用 `auto_captioning` 时返回的系统提示词,用于帮助编写或优化推理提示词,并遵循与自动生成字幕的训练数据相同的字幕约定。
- debug_dataset
- object {url, content_type, file_name, file_size} | null启用 `debug_dataset` 时提供的训练数据下载:包含准备好的数据集及其自动生成字幕的归档文件。
其他 Krea 2 变体
更多模型:训练
对于 AI 代理:此页面的 Markdown 版本位于 https://doitong.com/zh/developers/models/krea-2-trainer.md. 所有模型和指南: https://doitong.com/developers/llms.txt