Recraft V4.1 Flash API
recraft/v4.1-flash/text-to-imageRecraft V4.1 Flash API 调用 Recraft 快速、低成本的 V4.1 模型,适合大批量文生图:编辑插画、社媒图片和概念草稿,输出 1K,支持 5 种画幅、最多 10 个 RGB 颜色的调色板以及背景色。Recraft V4.1 Flash API 每张图固定 1.4 积分($0.007)。
获取 API Key预计费用: 1.4 credits · $0.0070
每张固定 1.4 积分,提交时扣除,任务失败全额退还。
REST API
快速开始
以下流程提交一个合法的 Recraft V4.1 Flash Text to Image 请求,取得 task_id,并在异步任务结束后读取结果文件 URL。
连接 Vidgo API
创建 API Key,仅保存在服务端,并通过 Authorization: Bearer VIDGO_API_KEY 发送。
- 端点
- POST
https://api.vidgo.ai/api/generate/submit - 认证
- Authorization: Bearer VIDGO_API_KEY
提交一个任务
向统一提交端点发送当前模型 ID 与 input 对象。input 只能包含本端点参数表列出的字段,其他字段会返回 400。
curl --request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "recraft/v4.1-flash/text-to-image",
"input": {
"prompt": "Flat editorial illustration for a community newsletter: a grandmother in Oaxaca teaching her two grandchildren to grind roasted cacao beans on a stone metate in a sunlit courtyard. Strings of papel picado overhead, a clay pot of hot chocolate steaming on a small brazier, a hen pecking near the blue doorway. Clean geometric shapes, warm limited palette, subtle paper grain.",
"size": "4:3"
}
}'等待结果
读取 data.task_id,仅在 not_started 或 running 时继续轮询;finished 与 failed 都必须停止。
查询状态
GET https://api.vidgo.ai/api/generate/status/{task_id}建议每 2–5 秒查询一次,并对 429/5xx 退避。也可在顶层提供 callback_url,在任务进入终态时接收回调。
not_startedrunningfinishedfailed{
"code": 200,
"data": {
"task_id": "task-example",
"status": "not_started",
"created_time": "2026-11-03T08:00:00"
}
}{
"code": 200,
"data": {
"task_id": "task-example",
"status": "finished",
"created_time": "2026-11-03T08:00:00",
"progress": 100,
"files": [
{
"file_url": "https://example.com/result.webp",
"file_type": "image"
}
]
}
}完整可运行轮询示例
展开后可查看同一 payload 的端到端脚本,包含业务 code、缺失 task_id、失败状态、异常状态和网络错误处理。
set -euo pipefail
: "${VIDGO_API_KEY:?Set VIDGO_API_KEY in your environment}"
REQUEST_BODY=$(cat <<'JSON'
{
"model": "recraft/v4.1-flash/text-to-image",
"input": {
"prompt": "Flat editorial illustration for a community newsletter: a grandmother in Oaxaca teaching her two grandchildren to grind roasted cacao beans on a stone metate in a sunlit courtyard. Strings of papel picado overhead, a clay pot of hot chocolate steaming on a small brazier, a hen pecking near the blue doorway. Clean geometric shapes, warm limited palette, subtle paper grain.",
"size": "4:3"
}
}
JSON
)
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
--request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data "$REQUEST_BODY")
TASK_ID=$(printf '%s' "$SUBMIT_RESPONSE" | jq -r '.data.task_id // .task_id // empty')
if [ -z "$TASK_ID" ]; then
printf 'Submit response did not include task_id:
%s
' "$SUBMIT_RESPONSE" >&2
exit 1
fi
while true; do
STATUS_RESPONSE=$(curl --silent --show-error --fail-with-body \
--url "https://api.vidgo.ai/api/generate/status/$TASK_ID" \
--header "Authorization: Bearer $VIDGO_API_KEY")
STATUS=$(printf '%s' "$STATUS_RESPONSE" | jq -r '.data.status // .status // empty')
case "$STATUS" in
finished)
printf '%s' "$STATUS_RESPONSE" | jq -r '(.data.files // .files // [])[]?.file_url'
break
;;
failed)
printf '%s' "$STATUS_RESPONSE" | jq -r '.data.error_message // .error_message // "Generation failed"' >&2
exit 1
;;
not_started|running)
sleep 2
;;
*)
printf 'Unexpected task status: %s
' "$STATUS" >&2
exit 1
;;
esac
done请求参数
下表仅列出 input 对象内的公开字段。顶层 model 与可选 callback_url 请参考快速开始示例。
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| input.prompt | string | 是 | – | 非空文本,最多 10,000 个字符。需要出现在图中的文字请放进英文双引号。 |
| input.size | string | 否 | 1:1 | 图片画幅:1:1、4:3、3:4、16:9 或 9:16。 |
| input.colors | object[] | 否 | – | 偏好的调色板:最多 10 个对象的数组,每个对象包含 0–255 的整数 r、g、b。 |
| input.background_color | object | 否 | – | 背景色,一个包含 0–255 整数 r、g、b 的对象。 |
响应字段
提交响应返回任务标识;状态响应在任务结束时提供结果文件或失败信息。
| 字段 | 类型 | 说明 |
|---|---|---|
| code | integer | 业务返回码,0 或 200 表示成功。 |
| message | string | 可选的人类可读响应信息。 |
| data.task_id | string | 提交成功后用于查询状态的唯一任务 ID。 |
| data.status | string | not_started、running、finished 或 failed。 |
| data.created_time | string | 任务创建时间。 |
| data.progress | integer | 状态响应中的 0–100 进度值。 |
| data.files[] | array | finished 时按返回顺序排列的生成文件。 |
| data.files[].file_url | string | 生成文件(.webp)的直接 URL。 |
| data.files[].file_type | string | 结果文件类型为 image。 |
| data.error_message | string | null | failed 状态的可读失败原因。 |
任务生命周期
只有前两个状态可继续轮询;finished 与 failed 均为终态。
not_started已接收并排队,等待执行。
running正在生成,可以继续轮询。
finished成功终态,验证 files 并读取文件 URL。
failed失败终态,读取 error_message 并停止;预扣积分会全部退还。
轮询与错误处理
- 认证使用有效的 VIDGO_API_KEY,将密钥保存在服务端,并通过 Bearer 认证发送请求。
- 参数校验400 表示模型 ID、字段、枚举、长度、数量或尺寸不符合本端点契约,包括传入其他端点的字段。
- 轮询间隔从 2–5 秒开始;对 429 和 5xx 使用指数退避,并设置总超时。
- 终态finished 后读取 files 中的文件 URL;failed 后读取 error_message。两种状态均结束轮询。
- 回调在顶层提供公开 callback_url;服务会在 finished 或 failed 后 POST 任务对象。
- 网络错误区分请求超时、网络失败和任务失败;仅在安全时重试同一查询。
模型规格
| 规格 | 取值 | 说明 |
|---|---|---|
| 模型 | recraft/v4.1-flash/text-to-image | Recraft V4.1 Flash Text to Image |
| 输入 | prompt | 最多 10,000 个字符的文本,可选 colors 与 background_color |
| 输出 | 每次请求 1 张 1K 位图 | 图片 URL 位于 files[0].file_url |
| size | 1:1 / 4:3 / 3:4 / 16:9 / 9:16 | 默认 1:1 |
| colors | 最多 10 个 RGB 对象 | r、g、b 为 0–255 的整数 |
| 价格 | 1.4 积分($0.007) | 每张固定 |
Recraft V4.1 Flash API 常见问题
Recraft V4.1 Flash API 是什么?
Recraft V4.1 Flash API 让开发者调用 Recraft V4.1 Flash,这是 Recraft V4.1 系列中快速、低成本、质量接近 Recraft V4.1 的模型。每次请求返回一张 1K 位图,可选 5 种画幅,并支持 RGB 调色板和背景色。你可以通过 API 调用,也可以在上方体验区直接试用。
Recraft V4.1 Flash API 多少钱?
每张固定 1.4 积分($0.007),是 Recraft V4.1(7 积分)的五分之一、Recraft V4.1 Pro(42 积分)的三十分之一。任务失败全额退还。
Recraft V4.1 Flash 与 Recraft V4.1 有什么区别?
Recraft 介绍 Flash 是快速、低成本、质量接近 V4.1 的模型,专为大批量生成和快速迭代打造;Recraft V4.1 是主力、表现力最强的模型。两者字段相同,在 Recraft V4.1 Flash API 上写好的提示词可直接用于 V4.1。
Recraft V4.1 Flash API 能生成 SVG 吗?
Flash 输出 1K 位图。需要 SVG 请使用 Recraft V4.1 文生矢量(16 积分)或 Recraft V4.1 Pro 文生矢量(60 积分)。
Recraft V4.1 Flash API 能使用品牌色吗?
可以。在 colors 中传入最多 10 个颜色对象,r、g、b 为 0–255 的整数,并可另设 background_color。



