FrameFlow API 文档

用你自己的程序调用本站的对话、生图、生视频模型。接口地址:https://yimiagent.cn/v1(对话接口与 OpenAI 兼容)

快速开始

  1. 登录创作台,左侧菜单「API 接入」→ 创建 API Key(只显示一次,请立即保存)。
  2. 提交生成任务,拿到任务 id。
  3. 每隔几秒查询一次任务,状态变成 succeeded 后,从 outputs 里下载结果。
curl https://yimiagent.cn/v1/images/generations \
  -H "Authorization: Bearer $FRAMEFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"Nano-Banana-2","prompt":"一只橘猫坐在窗台上,午后阳光,胶片质感","aspect_ratio":"1:1"}'

认证

每个请求在请求头里带上 API Key:

Authorization: Bearer ffk_xxxxxxxxxxxxxxxx

创建 Key 时可以限定它能调用哪些模型(整类,或逐个模型);不限定就是全部模型。GET /v1/models 只列出这个 Key 能用的模型。

也可以用 X-API-Key: ffk_xxx。API Key 相当于你的账号密码,只能放在服务器端,不要写进网页或 App 前端代码。泄露后请立即在「API 接入」删除并新建。

计费

限流

限制默认值超出时
每个 Key 每分钟请求数(所有接口合计)60 次HTTP 429 rate_limited,按响应头 Retry-After(秒)等待后重试
每个 Key 同时进行中的任务数5 个HTTP 429 concurrency_limit,等已有任务完成后再提交
每个 Key 每日积分上限不限(可自设)HTTP 429 daily_limit_exceeded

每个响应都带 X-RateLimit-Limit、X-RateLimit-Remaining。需要更高额度请联系运营。查询任务也计入每分钟请求数,建议每 5–10 秒查询一次。

模型与价格

实时价格,随成本自动调整。登录创作台后在「API 接入 · 模型市场」也能看到。

正在加载…

接口

POST/v1/chat/completions

对话,与 OpenAI Chat Completions 格式兼容,可直接用 OpenAI SDK(base_url 设为接口地址)。

参数类型说明
modelstring,必填对话模型 id,见模型列表 type: "chat"
messagesarray,必填[{role, content}],role 为 system / user / assistant;content 为文字,或数组 [{type:"text",text}, {type:"image_url",image_url:{url}}](识图模型,图片为 https 链接或 base64)
max_tokensint最多输出多少 token,默认 4096,最大 16000。余额需够「输入 + max_tokens 全用满」的预估金额
streambooltrue 时用 SSE 返回(先发保活注释,完成后一次性返回全文和用量),适合长回答
// 响应
{ "id": "chatcmpl-…", "object": "chat.completion", "model": "…",
  "choices": [ { "index": 0, "message": { "role": "assistant", "content": "…" }, "finish_reason": "stop" } ],
  "usage": { "prompt_tokens": 35, "completion_tokens": 120, "total_tokens": 155, "credits": 1 } }

usage.credits 是本次实际扣的积分。多轮对话会合并为一次请求发送。

GET/v1/models

当前可用的模型,type 为 chat / image / video。生图生视频的 prices 列出各分辨率的价格(视频按所列时长),对话的 price 是每百万 token 价格。

{
  "object": "list",
  "data": [
    { "id": "doubao-…", "type": "chat", "name": "…", "description": "…", "vision": true,
      "price": { "unit": "per_million_tokens", "input_credits": 88, "output_credits": 880, "input_cny": 0.88, "output_cny": 8.8 } },
    { "id": "gpt-image-2.5", "type": "image", "name": "GPT Image 2.5", "description": "…", "resolutions": ["1K", "2K"],
      "prices": [ { "resolution": "1K", "credits": 8, "cny": 0.08 } ] },
    { "id": "seedance-2.0", "type": "video", "name": "Seedance 2.0", "resolutions": ["480p", "720p"],
      "durations": { "min": 4, "max": 15 }, "prices": [ { "resolution": "480p", "duration": 5, "credits": 260, "cny": 2.6 } ] }
  ]
}

文档里的价格、余额等数字仅为示例。模型会随可用情况上下架,请以这个接口的实时结果为准。

GET/v1/models/{模型ID}

单个模型的信息:调用接口 endpoint、价格、可用输入 inputs(如视频模型是否必须首帧、是否支持尾帧、最多几张参考图;对话模型是否支持图片)。模型 ID 里带 / 的直接拼在路径里即可。创作台「API 接入 · 模型市场」每个模型的「调用方式」页有这个模型可直接复制的完整代码。

GET /v1/models/seedance-2.0
{ "object": "model", "id": "seedance-2.0", "type": "video", "name": "Seedance 2.0", "endpoint": "/v1/videos/generations",
  "resolutions": ["480p", "720p", "1080p"], "durations": { "min": 4, "max": 15 },
  "inputs": { "first_frame": "optional", "last_frame": false, "max_reference_images": 5, "reference_with_first_frame": false, "generate_audio": true },
  "prices": [ { "resolution": "480p", "duration": 5, "credits": 120, "cny": 1.2 } ] }

POST/v1/quote

提交前查价格,不扣费。参数与生成接口相同,另加 type(image 或 video)。

// 请求
{ "type": "video", "model": "seedance-2.0", "prompt": "海边日落", "duration": 5, "resolution": "720p" }
// 响应
{ "type": "video", "model": "seedance-2.0", "model_name": "Seedance 2.0", "credits": 412, "balance": 5000 }

POST/v1/images/generations

参数类型说明
promptstring,必填提示词,最多 4000 字
modelstring,必填模型 id,见模型列表 type: "image"
aspect_ratiostring画面比例,如 1:1(默认)、9:16、16:9、3:4、4:3
resolutionstring分辨率,取值见模型列表的 resolutions,不填用模型默认
image_urlsstring[]参考图(https 公网链接,PNG / JPG / WebP,每张 ≤ 10MB,最多 5 张)

请求头可加 Idempotency-Key: 你的唯一编号:网络超时后用同一个编号重试,不会重复下单、重复扣费(返回第一次创建的任务)。

// 响应(任务已创建,结果需查询)
{ "id": "6c1f…", "object": "task", "type": "image", "model": "gpt-image-2.5", "model_name": "GPT Image 2.5",
  "status": "queued", "credits": 8, "created_at": "2026-10-21T08:00:00.000Z", "outputs": [], "error": null }

POST/v1/videos/generations

参数类型说明
promptstring,必填画面和动作描述,最多 4000 字
modelstring,必填模型 id,见模型列表 type: "video"
durationint时长(秒),默认 5,范围见模型的 durations
resolutionstring分辨率,取值见模型的 resolutions
aspect_ratiostring画面比例,默认 9:16;有首帧图时按首帧图比例
first_frame_urlstring首帧图(https 链接):图生视频
last_frame_urlstring尾帧图(部分模型支持)
image_urlsstring[]参考图(部分模型支持,最多 5 张)
generate_audiobool是否同时生成声音,默认 true(模型支持时)

视频一般需要 1–5 分钟。

GET/v1/tasks/{id}

{
  "id": "6c1f…", "object": "task", "type": "video", "model": "seedance-2.0", "model_name": "Seedance 2.0",
  "status": "succeeded", "credits": 412,
  "created_at": "2026-10-21T08:00:00.000Z", "finished_at": "2026-10-21T08:02:31.000Z",
  "outputs": [
    { "type": "video", "url": "https://yimiagent.cn/m/outputs/…mp4?e=…&s=…",
      "expires_at": "2026-10-28T08:02:40.000Z", "poster_url": "https://yimiagent.cn/m/outputs/…jpg?…" }
  ],
  "error": null
}
结果链接 7 天内有效,请及时下载保存到你自己的存储。过期后重新查询任务会拿到新的链接(结果文件仍在保留期内时)。

任务只用你指定的模型生成,不会自动换成其他模型;生成失败时 status 为 failed,积分自动全额退回,可换用其他模型重新提交。credits 是实际净花费(已扣除退回)。

GET/v1/tasks?limit=20

这个 Key 提交过的任务,最新的在前,limit 最大 100。

GET/v1/balance

{ "credits": 4588, "credit_value_cny": 0.01,
  "api_key": { "name": "我的小程序", "key": "ffk_AbCd…wxyz", "today_credits": 412, "daily_limit": 2000,
               "rate_limit_per_minute": 60, "max_concurrent_tasks": 5 } }

GET/v1/usage?days=7

这个 Key 最近几天每天的花费(积分,已扣除失败退回),days 最大 90。

{ "days": 7, "total_credits": 1236, "data": [ { "date": "2026-10-21", "credits": 412, "tasks": 3 } ] }

任务状态

status含义
queued排队中
running生成中(stage 字段有进度说明)
succeeded完成,结果在 outputs
failed失败,原因在 error.message,积分已自动退回

错误码

出错时返回非 2xx 状态码和:

{ "error": { "code": "insufficient_credits", "message": "积分不足:本次需要 412 积分,当前余额 100 积分,请先充值再生成", "request_id": "req_…" } }
HTTPcode说明
400invalid_request / invalid_json参数不对,看 message
400model_not_found模型不存在或暂时下架,请改用其他模型
400model_required没有指定 model(对外 API 不提供自动匹配)
400invalid_image_url / image_download_failed / invalid_image / image_too_large参考图链接打不开、格式或大小不符
401missing_api_key / invalid_api_key没带 Key 或 Key 无效、已删除
402insufficient_credits积分不足,请充值
403api_key_disabled / account_disabled / api_disabledKey 或账号被停用,请联系运营
403model_not_allowed这个 API Key 没有被允许调用该模型(在「API Keys」修改 Key 的可用模型)
404task_not_found / not_found任务不存在(只能查自己 Key 提交的任务)/ 接口不存在
413request_too_large请求体超过 200KB(图片请传链接)
429rate_limited / concurrency_limit / daily_limit_exceeded / too_many_invalid_keys见 限流
503model_unavailable / service_busy当前没有可用模型或服务繁忙,稍后重试(已扣积分会自动退回)

代码示例

Python

import os, time, requests

BASE = "https://yimiagent.cn/v1"
H = {"Authorization": "Bearer " + os.environ["FRAMEFLOW_API_KEY"]}

task = requests.post(f"{BASE}/videos/generations", headers=H, json={
    "model": "seedance-2.0",
    "prompt": "镜头缓缓推进,女孩回头微笑,樱花飘落",
    "first_frame_url": "https://example.com/girl.jpg",
    "duration": 5,
}, timeout=60).json()
if "error" in task:
    raise SystemExit(task["error"])

while task["status"] in ("queued", "running"):
    time.sleep(8)
    task = requests.get(f"{BASE}/tasks/{task['id']}", headers=H, timeout=30).json()

if task["status"] == "succeeded":
    for i, o in enumerate(task["outputs"]):
        open(f"result_{i}.mp4", "wb").write(requests.get(o["url"], timeout=120).content)
    print("花费", task["credits"], "积分")
else:
    print("失败:", task["error"]["message"])

Node.js

const BASE = "https://yimiagent.cn/v1";
const H = { Authorization: `Bearer ${process.env.FRAMEFLOW_API_KEY}`, "Content-Type": "application/json" };

let task = await fetch(`${BASE}/images/generations`, {
  method: "POST", headers: { ...H, "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify({ model: "Nano-Banana-2", prompt: "极简风格的咖啡店海报", aspect_ratio: "3:4" }),
}).then((r) => r.json());

while (["queued", "running"].includes(task.status)) {
  await new Promise((r) => setTimeout(r, 5000));
  task = await fetch(`${BASE}/tasks/${task.id}`, { headers: H }).then((r) => r.json());
}
console.log(task.status, task.outputs?.map((o) => o.url));

内容审核:提示词或参考图不符合模型方的内容规范时会失败(积分退回)。API 生成的任务也会出现在创作台「任务历史」里。