FluxMedia External API
Media API reference for server-side integrations. Discover models and credit quota first, then create images or videos and poll task status.
Base URL
https://media.flux-code.ccAuthentication
Authorization: Bearer <API_KEY>Confirm the models, account credits, and key quota available to the current API key.
/v1/modelsmodelsList the image and video models actually available to the current API key's bound backend group.
No request body
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" } ]}AuthorizationRequired headerDefault:—Bearer <API_KEY>.objectAlways list.data[].idReal model IDs schedulable by this key. The list can be empty when no reachable member is configured.data[].object / created / owned_byFixed metadata compatible with an OpenAI model object./v1/creditscreditsReturn the current API key's credit limit, usage, remaining quota, and owning account balance.
No request body
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" }}AuthorizationRequired headerDefault:—Bearer <API_KEY>.account.balanceCurrent available credits on the owning account.account.total_earned / total_spent / statusCumulative credits earned, cumulative credits spent, and current account status.api_key.id / name / key_prefix / last_four / is_activeSafe summary and activation state for the current API key; the full key is never returned.api_key.credit_limit / credits_used / credits_remaining / unlimitedThe key limit, used quota, remaining quota, and unlimited flag.api_key.last_used_at / created_atLast-use and creation timestamps. last_used_at is null before the first use.Create or edit images, then query image task status and results.
/v1/images/generationsimage_generationGenerate images from a text prompt using an OpenAI Images generation-compatible request.
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", "size": "1024x1024", "quality": "medium", "response_format": "url", "output_format": "png", "background": "auto" }'{ "created": 1713833628, "data": [ { "url": "https://media.flux-code.cc/api/storage/generations/...", "revised_prompt": "..." } ]}promptRequiredDefault:—Image prompt, up to 32,000 characters.modelRequiredDefault:—Image model ID available to the current API key.sizeOptionalDefault:1024x1024Target image size. Standard enum values: auto, 1248x1248, 1248x832, 832x1248, 1248x704, 704x1248, 1248x944, 944x1248, 1248x528, 2048x2048, 2048x1360, 1360x2048, 2048x1152, 1152x2048, 2048x1536, 1536x2048, 2048x880, 2880x2880, 3520x2352, 2352x3520, 3840x2160, 2160x3840, 3312x2496, 2496x3312, 3840x1648. Omission defaults to 1024x1024; custom WIDTHxHEIGHT values that satisfy the site constraints are also accepted. See the “Image Size Table” below.qualityOptionalDefault:autoauto, low, medium, or high; currently supported only by gpt-image-2. Do not send it for other image models.response_formatOptionalDefault:b64_jsonurl or b64_json; defaults to b64_json.output_formatOptionalDefault:Unset (upstream decides)png, jpeg, or webp.output_compressionOptionalDefault:Unset (upstream decides)Controls the output image compression level from 0 to 100. Higher values apply stronger compression, typically producing smaller files with more quality loss; 0 means no compression and 100 means maximum compression. It only applies when output_format is jpeg or webp, and exact results may vary by upstream provider.backgroundOptionalDefault:Unset (upstream decides)transparent, opaque, or auto; support depends on the model.streamOptionalDefault:falseReturn an event stream when true or when Accept is text/event-stream.createdUnix timestamp in seconds.data[].b64_json / data[].urlBase64 image or image URL selected by response_format.data[].revised_promptThe upstream revised prompt, when available.SSE image_generation.partial_imagePartial image event in streaming mode.SSE image_generation.completedSignals that one image has completed in streaming mode./v1/images/editsimage_editEdit one or more input images from a prompt using an OpenAI Images edit-compatible request.
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 "size=1024x1024" \ -F "quality=medium" \ -F "response_format=url"{ "created": 1713833628, "data": [ { "url": "https://media.flux-code.cc/api/storage/generations/...", "revised_prompt": "..." } ]}promptRequiredDefault:—Edit prompt, up to 32,000 characters.image / image[] / image_*Required for multipartDefault:—Uploaded image files, up to 16 images.imagesRequired for JSONDefault:—Image reference array in a JSON request.maskOptionalDefault:NoneMask image whose transparent area indicates the edit region.modelRequiredDefault:—Image model ID available to the current API key.sizeOptionalDefault:1024x1024Target image size. Standard enum values: auto, 1248x1248, 1248x832, 832x1248, 1248x704, 704x1248, 1248x944, 944x1248, 1248x528, 2048x2048, 2048x1360, 1360x2048, 2048x1152, 1152x2048, 2048x1536, 1536x2048, 2048x880, 2880x2880, 3520x2352, 2352x3520, 3840x2160, 2160x3840, 3312x2496, 2496x3312, 3840x1648. Omission defaults to 1024x1024; custom WIDTHxHEIGHT values that satisfy the site constraints are also accepted. See the “Image Size Table” below.qualityOptionalDefault:autoauto, low, medium, or high; currently supported only by gpt-image-2. Do not send it for other image models.response_formatOptionalDefault:b64_jsonurl or b64_json; defaults to b64_json.output_formatOptionalDefault:Unset (upstream decides)png, jpeg, or webp.output_compressionOptionalDefault:Unset (upstream decides)Controls the output image compression level from 0 to 100. Higher values apply stronger compression, typically producing smaller files with more quality loss; 0 means no compression and 100 means maximum compression. It only applies when output_format is jpeg or webp, and exact results may vary by upstream provider.backgroundOptionalDefault:Unset (upstream decides)transparent, opaque, or auto; support depends on the model.streamOptionalDefault:falseReturn an event stream when true or when Accept is text/event-stream.createdUnix timestamp in seconds.data[].b64_json / data[].urlBase64 image or image URL selected by response_format.data[].revised_promptThe upstream revised prompt, when available.SSE image_edit.partial_imagePartial image event in streaming mode.SSE image_edit.completedSignals that one image edit has completed in streaming mode./v1/images/{task_id}image_generationGet image generation status and results by task ID.
No request body
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/..." } ]}AuthorizationRequired headerDefault:—Bearer <API_KEY>.task_idRequired path parameterDefault:—Image task ID corresponding to {task_id} in the request path.idImage task ID.objectTask object type.statusprocessing, needs_attention, completed, or failed.data[].b64_json / data[].urlImage results returned after completion.created / created_at / completed / completed_atCreation and completion times; completion fields are absent while running.Discover model capabilities, create videos, and query persistent tasks.
/v1/videos/generationsvideoCreate a persistent video task from a text prompt or reference images using the OpenAI-style route.
POST /v1/videos is no longer a video creation endpoint. Use POST /v1/videos/generations or /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 / clientRequestIdRequiredDefault:—A caller-generated idempotency key of up to 128 characters.promptRequiredDefault:—Video prompt, up to 32,000 characters.modelRequiredDefault:—Real video model ID such as seedance2, seedance2-fast, or veo31. Duration, ratio, and resolution must not be encoded in the ID; composite IDs are rejected.seconds / duration / duration_secondsRequiredDefault:—Separate video duration in seconds. seconds accepts a positive integer or decimal integer string; supplied aliases must agree and the normalized value must be supported by the selected model.aspectRatio / aspect_ratioRequiredDefault:—Separate video aspect ratio supported by the selected model.resolutionRequiredDefault:—Separate lowercase output resolution supported by the selected model.quote_token / quoteTokenOptionalDefault:Omit to create with the current server quoteShort-lived opaque quote token from the matching model and resolution billing row of GET /v1/videos/capabilities. A changed quote returns 409 with the latest currentQuote; confirm it and retry with the new token.negative_prompt / negativePromptOptionalDefault:NoneNegative prompt, up to 8,000 characters.generate_audio / generateAudioOptionalDefault:Model defaultWhether to generate audio. Seedance 2.0, including Fast, and Kling 3.0 Omni default to false, while Kling 3.0 defaults to true. Runway Gen-4.5 and Ray 3.14, including HDR, do not support audio, and models without audio support cannot accept true.firstFrame / first_frame, lastFrame / last_frameOptionalDefault:NoneFirst frame and optional last frame as base64 image data URLs. lastFrame requires firstFrame; last-frame support is model-specific.referenceImages / reference_imagesOptionalDefault:Empty arrayOrdered base64 image data URL array. The limit is model-specific; Seedance defaults to 10 and admins may configure it. Reference images and frame inputs are mutually exclusive for every model.callback_url / callbackUrlOptionalDefault:NonePublic https webhook that receives the task object when the task completes or fails.task_id / id / generation_idThe same persistent video task ID.objectAlways video.task.statusInitial task status, usually queued.modelReal video model ID used for this request.duration / duration_seconds, aspectRatio / aspect_ratio, resolutionSeparate video parameters used by this task.billingSnapshot locked at creation. mode=per_second multiplies the unit price by duration; mode=per_item charges unitPrice once and has no creditsPerSecond./v1/videos/capabilitiesvideoList real video models visible to the current API key, their independent generation parameters, image input and audio capabilities, and whether the account pool is configured to reach them.
No request body
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 }}AuthorizationRequired headerDefault:—Bearer <API_KEY>.items[].model / displayNameReal video model ID and display name.items[].durations / aspectRatios / resolutionsAllowed independent duration, aspect ratio, and resolution values for the model.items[].input.framesnone, first-only, or first-and-optional-last, describing frame input support.items[].input.referenceImagesReference-image limit and whether admins can configure that limit; use the current response value.items[].input.framesAndReferencesMutuallyExclusiveIndicates that frame inputs and reference images cannot be sent together.items[].audioAudio generation support and the default used when generate_audio is omitted.items[].billing[]Current effective quote and quoteToken for each output resolution. per_second includes creditsPerSecond; per_item is charged only by unitPrice per item.items[].configuredReachableWhether the trusted account-pool group is configured with an account capable of running this model; this is not real-time capacity.limitsInfrastructure-wide input count and byte limits; per-model limits still come from items[].input./v1/videos/{id}videoGet video generation status and results by task ID.
No request body
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/..."}]}AuthorizationRequired headerDefault:—Bearer <API_KEY>.idRequired path parameterDefault:—Persistent video task ID returned by the create endpoint, corresponding to {id} in the request path. Maximum 128 characters; only tasks owned by the current API key user are queryable.id / task_id / generation_idThe same persistent video task ID.objectAlways video.task.statusqueued, in_progress, completed, or failed.model, duration / duration_seconds, aspectRatio / aspect_ratio, resolutionThe task's real model ID and separate video parameters.inputInput mode and count without the user-supplied image contents.billingImmutable quote and actual consumption. Legacy tasks are marked legacy with unknown unit price and quote; no current price is fabricated.data[].url / video_urlThe same video URL returned after completion.created_at / completed_atISO creation and completion times; completed_at is absent while running.The table maps the site image-size selector's resolution bases and aspect ratios to the standard size enum values.
| Resolution | 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 |
auto lets the backend decide. Standard ratio sizes are rounded to multiples of 16; each edge must be 256–3840px, total pixels 655,360–8,294,400, and the aspect ratio must not exceed 3:1. The 4K square and some 4K ratios are reduced by the total-pixel cap; the table shows the resulting dimensions. Custom WIDTHxHEIGHT values that satisfy these constraints are also accepted.