FluxMedia External API
面向服务端集成的媒体 API 参考。先查询当前密钥可见模型与积分额度,再调用图片或视频生成接口并轮询任务状态。
Base URL
https://media.flux-code.cc鉴权
Authorization: Bearer <API_KEY>确认当前密钥可用的模型范围、账户积分与独立额度。
/v1/modelsmodels列出当前 API 密钥绑定分组实际可用的图片与视频模型。
无请求体
curl https://media.flux-code.cc/v1/models \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY"{ "object": "list", "data": [ { "id": "gpt-image-2", "object": "model", "created": 0, "owned_by": "gpt2image" }, { "id": "seedance2", "object": "model", "created": 0, "owned_by": "gpt2image" } ]}Authorization必填 header默认值:—Bearer <API_KEY>。object固定为 list。data[].id当前密钥可调度的真实模型 ID;未配置可达成员时列表可能为空。data[].object / created / owned_by兼容 OpenAI model object 的固定元数据。/v1/creditscredits查询当前 API 密钥的积分限额、已用额度、剩余额度和所属账户余额。
无请求体
curl https://media.flux-code.cc/v1/credits \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY"{ "object": "credit_balance", "account": { "balance": 15702.45, "total_earned": 20000, "total_spent": 4297.55, "status": "active" }, "api_key": { "id": "key_...", "name": "Production", "key_prefix": "fm_live_", "last_four": "a1b2", "is_active": true, "credit_limit": 1000, "credits_used": 12.7, "credits_remaining": 987.3, "unlimited": false, "last_used_at": "2026-08-03T01:02:03.000Z", "created_at": "2026-08-01T01:02:03.000Z" }}Authorization必填 header默认值:—Bearer <API_KEY>。account.balanceAPI 密钥所属账户的当前可用积分余额。account.total_earned / total_spent / status账户累计获得、累计消耗和当前状态。api_key.id / name / key_prefix / last_four / is_active当前 API 密钥的安全摘要和启用状态,不返回完整密钥。api_key.credit_limit / credits_used / credits_remaining / unlimited当前密钥的额度、已用额度、剩余额度和不限额标记。api_key.last_used_at / created_at最近使用时间和创建时间;从未使用时 last_used_at 为 null。创建、编辑图片,并查询图片任务状态与结果。
/v1/images/generationsimage_generation根据文本提示词生成图片,兼容 OpenAI Images generation 请求形态。
application/json
curl https://media.flux-code.cc/v1/images/generations \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2", "prompt": "A quiet reading room in the morning sun", "aspectRatio": "1:1", "resolution": "1k", "quality": "medium", "response_format": "url", "output_format": "png", "background": "auto" }'{ "created": 1713833628, "data": [ { "url": "https://media.flux-code.cc/api/storage/generations/...", "revised_prompt": "..." } ]}prompt必填默认值:—图片提示词,最多 32000 字符。model必填默认值:—图片模型 ID;可用模型以当前 API 密钥可见范围为准。aspectRatio / aspect_ratio可选默认值:未指定(上游决定)图片宽高比,例如 1:1、16:9。两种命名任选其一。resolution可选默认值:未指定(上游决定)图片分辨率档位,具体可用值取决于所选模型和供应商尺寸配置。quality可选默认值:autoauto、low、medium 或 high;当前仅 gpt-image-2 可用,其他图片模型不要传此参数。response_format可选默认值:b64_jsonurl 或 b64_json;默认返回 b64_json。output_format可选默认值:未指定(上游决定)png、jpeg 或 webp。output_compression可选默认值:未指定(上游决定)控制输出图片的压缩级别,取值 0 到 100:数值越大,压缩力度越大,通常文件越小、画质损失越明显;0 表示不压缩,100 表示最大压缩。仅在 output_format 为 jpeg 或 webp 时生效,不同上游的实际压缩结果可能略有差异。background可选默认值:未指定(上游决定)transparent、opaque 或 auto;透明能力取决于模型。stream可选默认值:false设为 true 或请求 Accept: text/event-stream 时返回事件流。createdUnix 秒时间戳。data[].b64_json / data[].url按 response_format 返回 base64 图片或图片 URL。data[].revised_prompt上游返回的改写提示词;没有改写时可能缺省。SSE image_generation.partial_image流式模式下返回的局部图片事件。SSE image_generation.completed流式模式下表示单张图片已完成。/v1/images/editsimage_edit根据提示词编辑一张或多张输入图片,兼容 OpenAI Images edit 请求形态。
multipart/form-data 或 application/json
curl https://media.flux-code.cc/v1/images/edits \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY" \ -F "model=gpt-image-2" \ -F "prompt=Replace the sky with a clear sunset" \ -F "image=@./input.png" \ -F "aspectRatio=1:1" \ -F "resolution=1k" \ -F "quality=medium" \ -F "response_format=url"{ "created": 1713833628, "data": [ { "url": "https://media.flux-code.cc/api/storage/generations/...", "revised_prompt": "..." } ]}prompt必填默认值:—编辑提示词,最多 32000 字符。image / image[] / image_*multipart 必填默认值:—上传图片文件,最多 16 张。imagesJSON 必填默认值:—JSON 请求中的图片引用数组。mask可选默认值:无遮罩图片;透明区域表示需要编辑的范围。model必填默认值:—图片模型 ID;可用模型以当前 API 密钥可见范围为准。aspectRatio / aspect_ratio可选默认值:未指定(上游决定)图片宽高比,例如 1:1、16:9。两种命名任选其一。resolution可选默认值:未指定(上游决定)图片分辨率档位,具体可用值取决于所选模型和供应商尺寸配置。quality可选默认值:autoauto、low、medium 或 high;当前仅 gpt-image-2 可用,其他图片模型不要传此参数。response_format可选默认值:b64_jsonurl 或 b64_json;默认返回 b64_json。output_format可选默认值:未指定(上游决定)png、jpeg 或 webp。output_compression可选默认值:未指定(上游决定)控制输出图片的压缩级别,取值 0 到 100:数值越大,压缩力度越大,通常文件越小、画质损失越明显;0 表示不压缩,100 表示最大压缩。仅在 output_format 为 jpeg 或 webp 时生效,不同上游的实际压缩结果可能略有差异。background可选默认值:未指定(上游决定)transparent、opaque 或 auto;透明能力取决于模型。stream可选默认值:false设为 true 或请求 Accept: text/event-stream 时返回事件流。createdUnix 秒时间戳。data[].b64_json / data[].url按 response_format 返回 base64 图片或图片 URL。data[].revised_prompt上游返回的改写提示词;没有改写时可能缺省。SSE image_edit.partial_image流式模式下返回的局部图片事件。SSE image_edit.completed流式模式下表示单张图片编辑已完成。/v1/images/{task_id}image_generation按任务 ID 查询图片生成状态和结果。
无请求体
curl https://media.flux-code.cc/v1/images/task_... \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY"{ "id": "task_...", "object": "image", "status": "completed", "created": 1713833628, "created_at": "2026-05-28T00:00:00.000Z", "completed": 1713833700, "completed_at": "2026-05-28T00:01:12.000Z", "data": [ { "url": "https://media.flux-code.cc/api/storage/generations/..." } ]}Authorization必填 header默认值:—Bearer <API_KEY>。task_id必填路径参数默认值:—图片任务 ID,与请求路径中的 {task_id} 对应。id图片任务 ID。object任务对象类型。statusprocessing、needs_attention、completed 或 failed。data[].b64_json / data[].url任务完成后返回的图片结果。created / created_at / completed / completed_at任务创建与完成时间;未完成时不返回完成时间。发现模型能力,创建视频并查询持久化任务。
/v1/videos/generationsvideo按 FluxMedia 视频协议根据文本提示词或参考图创建持久视频任务。
POST /v1/videos 已不再提供视频创建,请使用 POST /v1/videos/generations 或 /api/v1/videos/generations。
application/json
curl https://media.flux-code.cc/v1/videos/generations \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "client_request_id": "video-request-001", "model": "seedance2", "seconds": 8, "aspect_ratio": "16:9", "resolution": "1080p", "prompt": "A hero walking through a neon city", "negative_prompt": "low resolution, blur, watermark", "quote_token": "opaque-current-quote-token", "generate_audio": true, "reference_images": ["data:image/png;base64,..."], "reference_videos": ["https://media.example/reference.mp4"], "reference_audios": ["https://media.example/reference.mp3"] }'{ "object": "video.task", "id": "video_0123456789abcdef0123456789abcdef01234567", "task_id": "video_0123456789abcdef0123456789abcdef01234567", "generation_id": "video_0123456789abcdef0123456789abcdef01234567", "status": "queued", "model": "seedance2", "duration": 8, "duration_seconds": 8, "aspectRatio": "16:9", "aspect_ratio": "16:9", "resolution": "1080p", "billing": { "kind": "snapshot", "mode": "per_second", "unit": "second", "unitPrice": 3, "creditsPerSecond": 3, "durationSeconds": 8, "quotedCredits": 24, "actualCredits": 0 }, "generateAudio": true, "generate_audio": true}client_request_id / clientRequestId必填默认值:—调用方生成的幂等请求 ID,最长 128 个字符。prompt必填默认值:—视频提示词,最多 32000 字符。model必填默认值:—真实视频模型 ID,例如 seedance2、seedance2-fast 或 veo31。不得拼接时长、比例或分辨率;复合 ID 会被拒绝。seconds / duration / duration_seconds必填默认值:—独立视频时长(秒)。seconds 兼容正整数或正整数字符串;三个别名并存时必须一致,且归一化值必须受所选模型支持。aspectRatio / aspect_ratio必填默认值:—独立视频宽高比,必须属于所选模型能力。resolution必填默认值:—独立小写输出分辨率,必须属于所选模型能力。quote_token / quoteToken可选默认值:省略时由服务端按当前报价创建来自 GET /v1/videos/capabilities 对应模型和分辨率 billing 行的短期不透明报价令牌;报价已变化时返回 409 与最新 currentQuote,确认后以新令牌重试。negative_prompt / negativePrompt可选默认值:无负向提示词,最多 8000 字符。generate_audio / generateAudio可选默认值:模型默认值是否生成声音。Seedance 2.0(含 Fast)与 Kling 3.0 Omni 默认关闭,Kling 3.0 默认开启;Runway Gen-4.5 与 Ray 3.14(含 HDR)不支持声音,不支持音频的模型不能传 true。firstFrame / first_frame、lastFrame / last_frame可选默认值:无首帧与可选尾帧的 base64 image data URL。尾帧必须与首帧同时提供;是否支持尾帧由模型能力决定。referenceImages / reference_images可选默认值:空数组有序参考图 base64 data URL 数组;数量上限由模型能力决定,Seedance 默认 10 且管理员可配置。参考图与首尾帧对所有模型互斥。referenceVideos / reference_videos可选默认值:空数组HTTPS mp4/mov 参考视频直链,最多 3 个;单文件不超过 200 MB,单条 4-10 秒,合计不超过 15 秒。仅路由到已声明支持参考视频的账号。referenceAudios / reference_audios可选默认值:空数组HTTPS mp3/wav 参考音频直链,最多 1 个;不超过 15 MB 且不超过 15 秒。仅路由到已声明支持参考音频的账号。callback_url / callbackUrl可选默认值:无任务完成或失败时接收任务对象的公网 https webhook 地址。task_id / id / generation_id同一个持久视频任务 ID。object固定为 video.task。status任务初始状态,通常为 queued。model本次使用的真实视频模型 ID。duration / duration_seconds、aspectRatio / aspect_ratio、resolution本次任务使用的独立视频参数。billing创建时锁定的账单快照。mode=per_second 时单价乘时长;mode=per_item 时每条只收 unitPrice,且没有 creditsPerSecond。/v1/videos/capabilitiesvideo查询当前 API 密钥可见的真实视频模型、独立生成参数、输入图和声音能力,以及账号池是否已配置可达。
无请求体
curl https://media.flux-code.cc/v1/videos/capabilities \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY"{ "items": [ { "model": "seedance2", "displayName": "Seedance 2.0", "durations": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], "aspectRatios": ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9"], "resolutions": ["1080p", "720p", "480p"], "input": { "frames": "first-and-optional-last", "referenceImages": { "maxCount": 10, "configurable": true }, "framesAndReferencesMutuallyExclusive": true }, "audio": { "supported": true, "defaultEnabled": false }, "billing": [ { "kind": "current_quote", "resolution": "1080p", "mode": "per_second", "unit": "second", "unitPrice": 3, "creditsPerSecond": 3, "quoteToken": "opaque-current-quote-token" } ], "configuredReachable": true } ], "limits": { "maxMediaInputCount": 256, "maxMediaInputBytes": 536870912 }}Authorization必填 header默认值:—Bearer <API_KEY>。items[].model / displayName真实视频模型 ID 与展示名称。items[].durations / aspectRatios / resolutions该模型允许的独立时长、宽高比和分辨率集合。items[].input.framesnone、first-only 或 first-and-optional-last,表示帧输入能力。items[].input.referenceImages参考图数量上限及该上限是否允许管理员配置;应使用响应中的当前值。items[].input.framesAndReferencesMutuallyExclusive固定指示首尾帧与参考图不能同时传入。items[].audio声音生成支持情况与未传 generate_audio 时的默认值。items[].billing[]每个输出分辨率的当前有效报价和 quoteToken。per_second 含 creditsPerSecond;per_item 只按 unitPrice/条计费。items[].configuredReachable当前可信账号池分组是否配置了可执行该模型的账号;不代表实时容量。limits整次媒体输入的基础设施数量与字节上限;单模型限制仍以 items[].input 为准。/v1/videos/{id}video按任务 ID 查询视频生成状态和结果。
无请求体
curl https://media.flux-code.cc/v1/videos/video_0123456789abcdef0123456789abcdef01234567 \ -H "Authorization: Bearer $FLUXMEDIA_API_KEY"{ "object": "video.task", "id": "video_0123456789abcdef0123456789abcdef01234567", "task_id": "video_0123456789abcdef0123456789abcdef01234567", "generation_id": "video_0123456789abcdef0123456789abcdef01234567", "status": "completed", "model": "seedance2", "duration": 8, "duration_seconds": 8, "aspectRatio": "16:9", "aspect_ratio": "16:9", "resolution": "1080p", "generateAudio": true, "generate_audio": true, "input": { "mode": "references", "count": 1 }, "billing": { "kind": "snapshot", "mode": "per_item", "unit": "item", "unitPrice": 3, "durationSeconds": 8, "quotedCredits": 3, "actualCredits": 3 }, "created_at": "2026-05-28T00:00:00.000Z", "completed_at": "2026-05-28T00:01:40.000Z", "video_url": "https://media.flux-code.cc/api/storage/generations/...", "data": [{"url": "https://media.flux-code.cc/api/storage/generations/..."}]}Authorization必填 header默认值:—Bearer <API_KEY>。id必填路径参数默认值:—创建接口返回的持久视频任务 ID,与请求路径中的 {id} 对应。最长 128 字符,仅可查询当前 API 密钥所属用户的任务。id / task_id / generation_id同一个持久视频任务 ID。object固定为 video.task。statusqueued、in_progress、completed 或 failed。model、duration / duration_seconds、aspectRatio / aspect_ratio、resolution任务的真实模型 ID 与独立视频参数。input输入模式与输入数量,不包含用户输入图内容。billing不可变报价与实际消费。旧任务标记为 legacy,单价和原报价为未知,不会伪造为当前价格。data[].url / video_url任务完成后返回的同一视频 URL。created_at / completed_atISO 创建与完成时间;未完成时不返回 completed_at。尺寸配置集按分辨率和宽高比维护到上游尺寸的映射;图片接口不再接受 size 参数。
| 分辨率 | 1:1 | 3:2 | 2:3 | 16:9 | 9:16 | 4:3 | 3:4 | 21:9 |
|---|---|---|---|---|---|---|---|---|
| 1K | 1248x1248 | 1248x832 | 832x1248 | 1248x704 | 704x1248 | 1248x944 | 944x1248 | 1248x528 |
| 2K | 2048x2048 | 2048x1360 | 1360x2048 | 2048x1152 | 1152x2048 | 2048x1536 | 1536x2048 | 2048x880 |
| 4K | 2880x2880 | 3520x2352 | 2352x3520 | 3840x2160 | 2160x3840 | 3312x2496 | 2496x3312 | 3840x1648 |
表中像素仅作为比例与分辨率组合的目标参考。客户端应传 aspectRatio(或 aspect_ratio)和 resolution;不接受 auto、WIDTHxHEIGHT 或 size 参数。供应商选择尺寸配置后,平台才会在内部映射为其上游 size。