(Optional) Specifies the server region for image upload. Set to true to use servers in China, false to use non-China servers. Choose based on your geographical location for optimal upload speeds.
Output image aspect ratio. You Applicable in both text-to-image generation and image editing modes.
For text-to-image generation , the output image will follow the specified aspect ratio.
For image editing , if aspectRatio is provided, the edited image will follow that ratio. If not provided, the image will retain its original aspect ratio.
200: Success - Request has been processed successfully
401: Unauthorized - Authentication credentials are missing or invalid
402: Insufficient Credits - Account does not have enough credits to perform the operation
404: Not Found - The requested resource or endpoint does not exist
422: Validation Error - The request parameters failed validation checks
429: Rate Limited - Request limit has been exceeded for this resource
455: Service Unavailable - System is currently undergoing maintenance
500: Server Error - An unexpected error occurred while processing the request
Server Error - The security tolerance level is out of range and should be 0-2 or 0-6
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Mint Starter Kit","colors":{"primary":"#16A34A","light":"#07C983","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/fluxapiai/dIoY4SstoF1lO_Fs/favicon.ico?fit=max\u0026auto=format\u0026n=dIoY4SstoF1lO_Fs\u0026q=85\u0026s=2966aad0e2aaac07727e76c722775581","dark":"https://mintcdn.com/fluxapiai/dIoY4SstoF1lO_Fs/favicon.ico?fit=max\u0026auto=format\u0026n=dIoY4SstoF1lO_Fs\u0026q=85\u0026s=2966aad0e2aaac07727e76c722775581"},"favicon":"/favicon.ico","navbar":{"links":[{"label":"Support","href":"mailto:support@fluxapi.ai"}],"primary":{"type":"button","label":"Dashboard","href":"https://fluxapi.ai/dashboard"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"]},"navigation":{"global":{"anchors":[{"anchor":"Home","icon":"house","href":"https://fluxapi.ai/"}]},"languages":[{"language":"en","href":""},{"language":"cn","href":"cn"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"fluxapiai","hasAudioNarration":false,"actualSubdomain":"fluxapiai","customDomains":["docs.fluxapi.ai"],"gitSource":{"type":"github","owner":"fluxapiai","repo":"docs.fluxapi.ai","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6a21e79f572b750f6b6fc53a","collectionId":"f698a459-5e8b-4575-99a7-c43d4c56097b","schemaVersion":"v2"},"entitlements":{},"buildId":"6a21e79f572b750f6b6fc53a:success","clientVersion":"0.0.4045","searchFilterCounts":[{"language":"cn","tag":"Flux Kontext API","count":3},{"language":"en","tag":"Flux Kontext API","count":3},{"language":"cn","tag":"快速开始","count":2},{"language":"en","tag":"Getting started","count":2},{"language":"cn","tag":"通用API","count":1},{"language":"en","tag":"Common API","count":1}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"flux-kontext-api/generate-or-edit-image","slug":"/flux-kontext-api/generate-or-edit-image","pageMetadata":{"title":"Generate or Edit Image","description":"Create a new image generation or editing task using the Flux Kontext AI model.","openapi":"flux-kontext-api/flux-kontext-api.json post /api/v1/flux/kontext/generate","href":"/flux-kontext-api/generate-or-edit-image"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Create a new image generation or editing task using the Flux Kontext AI model.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,ol:`ol`,p:`p`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Heading}=_components;if(!Heading)_missingMdxReference(`Heading`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`3`,id:`usage-modes`,children:`Usage Modes`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Text-to-Image Generation`})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Provide `,_jsx(_components.code,{children:`prompt`}),` and `,_jsx(_components.code,{children:`aspectRatio`})]}),`\n`,_jsx(_components.li,{children:`Model will generate a new image based on the text description`}),`\n`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Image Editing`})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Provide `,_jsx(_components.code,{children:`prompt`}),` and `,_jsx(_components.code,{children:`inputImage`})]}),`\n`,_jsxs(_components.li,{children:[`You can optionally provide an `,_jsx(_components.code,{children:`aspectRatio`}),`.`,`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`If supplied, the output will be cropped or padded to match this ratio.`}),`\n`,_jsx(_components.li,{children:`If omitted, the original image’s ratio will be preserved.`}),`\n`]}),`\n`]}),`\n`,_jsx(_components.li,{children:`Model will edit the input image according to the prompt`}),`\n`]}),`\n`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`important-notes`,children:`Important Notes`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Generated images will expire after 14 days`}),`\n`,_jsx(_components.li,{children:`Prompts only support English`}),`\n`,_jsxs(_components.li,{children:[`Choose the appropriate model based on your needs:`,`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`flux-kontext-pro: Standard model for most use cases`}),`\n`,_jsx(_components.li,{children:`flux-kontext-max: Enhanced model for complex scenes`}),`\n`]}),`\n`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Generate or Edit Image","description":"Create a new image generation or editing task using the Flux Kontext AI model.","openapi":"flux-kontext-api/flux-kontext-api.json post /api/v1/flux/kontext/generate","href":"/flux-kontext-api/generate-or-edit-image"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Usage Modes","slug":"usage-modes","depth":3,"children":[]},{"title":"Important Notes","slug":"important-notes","depth":3,"children":[]}],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"summary":"Generate or Edit Image","description":"Create a new image generation or editing task using the Flux Kontext AI model.","operationId":"generate-or-edit-image","requestBody":"8c73f057-7189-4abd-91f9-72cb7fa43644","responses":{"200":"ccc04b1a-5b77-4ba8-b08b-4683c8f7451b","500":"94da65cd-739d-43cc-b936-c9a66e17da1f"},"callbacks":{"onImageGenerated":{"{$request.body#/callBackUrl}":{"post":{"summary":"Image Generation Callback","description":"When the image generation task is completed, the system will send the result to your provided callback URL via POST request","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer","description":"Status code\n\n- **200**: Success - Image generation completed successfully\n- **400**: Failed - Your prompt was flagged by Website as violating content policies.\n- **500**: Failed - Internal Error, Please try again later.\n- **501**: Failed - Image generation task failed","enum":[200,400,500,501]},"msg":{"type":"string","description":"Status message","example":"BFL image generated successfully."},"data":{"type":"object","properties":{"taskId":{"type":"string","description":"Task ID","example":"task12345"},"info":{"type":"object","properties":{"originImageUrl":{"type":"string","description":"Original image URL (valid for 10 minutes)","example":"https://example.com/original.jpg"},"resultImageUrl":{"type":"string","description":"Generated image URL on our server","example":"https://example.com/result.jpg"}}}}}}},"example":{"code":200,"msg":"BFL image generated successfully.","data":{"taskId":"task12345","info":{"originImageUrl":"https://example.com/original.jpg","resultImageUrl":"https://example.com/result.jpg"}}}}}},"responses":{"200":{"description":"Callback received successfully"}}}}}},"method":"post","type":"path","servers":["649e6260-2e9d-40dd-85dc-80dfea4ab660"],"security":["9e8b7930-d0ff-411a-a7ff-8db3e94a8e39"],"path":"/api/v1/flux/kontext/generate","baseUrlOptions":["https://api.fluxapi.ai"],"title":"Generate or Edit Image","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"prompt":{"type":"string","description":"Text prompt describing the desired image or edit. Required for both generation and editing modes.\n\n- Should be detailed and specific\n- For image editing, describe the desired changes\n- For image generation, describe the complete scene\n- IMPORTANT: Only English language is supported","example":"A serene mountain landscape at sunset with a lake reflecting the orange sky","isRequired":true,"uniqueKey":"prompt","typeLabel":"string"},"enableTranslation":{"type":"boolean","description":"Whether to enable automatic translation feature.\n\n- Since prompt only supports English, when this parameter is true, the system will automatically translate non-English prompts to English\n- If your prompt is already in English, you can set this to false\n- Default value: true","example":true,"uniqueKey":"enableTranslation","typeLabel":"boolean"},"uploadCn":{"type":"boolean","description":"(Optional) Specifies the server region for image upload. Set to true to use servers in China, false to use non-China servers. Choose based on your geographical location for optimal upload speeds.","example":false,"uniqueKey":"uploadCn","typeLabel":"boolean"},"inputImage":{"type":"string","format":"uri","description":"URL of the input image for editing mode. Required when editing an existing image.\n\n- Must be a valid image URL\n- Image must be accessible to the API server","example":"https://example.com/input-image.jpg","uniqueKey":"inputImage","typeLabel":"string\u003curi>"},"aspectRatio":{"type":"string","description":"Output image aspect ratio. You Applicable in both text-to-image generation and image editing modes.\n\nFor **text-to-image generation** , the output image will follow the specified aspect ratio.\n\nFor **image editing** , if aspectRatio is provided, the edited image will follow that ratio. If not provided, the image will retain its original aspect ratio.\n\nSupported Aspect Ratios:\n\n| Ratio | Format Type | Common Use Cases |\n|-------|-------------|-----------------|\n| 21:9 | Ultra-wide | Cinematic displays, panoramic views |\n| 16:9 | Widescreen | HD video, desktop wallpapers |\n| 4:3 | Standard | Traditional displays, presentations |\n| 1:1 | Square | Social media posts, profile pictures |\n| 3:4 | Portrait | Magazine layouts, portrait photos |\n| 9:16 | Mobile Portrait | Smartphone wallpapers, stories |\n\n> Note: Default ratio is \"16:9\" if not specified.","enum":["21:9","16:9","4:3","1:1","3:4","9:16"],"default":"16:9","uniqueKey":"aspectRatio","typeLabel":"enum\u003cstring>"},"outputFormat":{"type":"string","description":"Output image format.","enum":["jpeg","png"],"default":"jpeg","uniqueKey":"outputFormat","typeLabel":"enum\u003cstring>"},"promptUpsampling":{"type":"boolean","description":"- If true, performs upsampling on the prompt\n- May increase processing time","default":false,"uniqueKey":"promptUpsampling","typeLabel":"boolean"},"model":{"type":"string","description":"Model version to use for generation.\n\nAvailable Options:\n\n| Model | Description |\n|--------------|-------------|\n| flux-kontext-pro | Standard model with balanced performance |\n| flux-kontext-max | Enhanced model with advanced capabilities |\n\n> Note: Choose flux-kontext-max for more demanding tasks that require higher quality and detail","enum":["flux-kontext-pro","flux-kontext-max"],"default":"flux-kontext-pro","uniqueKey":"model","typeLabel":"enum\u003cstring>"},"callBackUrl":{"type":"string","format":"uri","description":"The URL to receive image generation or editing task completion updates. Optional but recommended for production use.\n\n- System will POST task status and results to this URL when image generation or editing completes\n- Callback includes generated image URLs and task information for both text-to-image and image editing operations\n- Your callback endpoint should accept POST requests with JSON payload containing image results\n- For detailed callback format and implementation guide, see [Image Generation/Editing Callbacks](./generate-or-edit-image-callbacks)\n- Alternatively, use the Get Image Details endpoint to poll task status","example":"https://your-callback-url.com/callback","uniqueKey":"callBackUrl","typeLabel":"string\u003curi>"},"safetyTolerance":{"type":"integer","description":"**For Image Generation Mode:**\nModeration level for inputs and outputs. Value ranges from 0 (most strict) to 6 (more permissive).\n\n**For Image Editing Mode:**\nModeration level for inputs and outputs. Value ranges from 0 (most strict) to 2 (balanced).\n\nDefault: 2","enum":[0,1,2,3,4,5,6],"default":2,"example":2,"uniqueKey":"safetyTolerance","typeLabel":"enum\u003cinteger>"},"watermark":{"type":"string","description":"Watermark identifier to add to the generated image.\n\n- Optional\n- If provided, a watermark will be added to the output image","example":"your-watermark-id","uniqueKey":"watermark","typeLabel":"string"}},"required":["prompt"],"example":{"prompt":"A serene mountain landscape at sunset with a lake reflecting the orange sky","enableTranslation":true,"aspectRatio":"16:9","outputFormat":"jpeg","promptUpsampling":false,"model":"flux-kontext-pro"},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"prompt":"A serene mountain landscape at sunset with a lake reflecting the orange sky","enableTranslation":true,"aspectRatio":"16:9","outputFormat":"jpeg","promptUpsampling":false,"model":"flux-kontext-pro"}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"ccc04b1a-5b77-4ba8-b08b-4683c8f7451b":{"description":"Request successful","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer","enum":[200,401,402,404,422,429,455,500,501,505],"description":"Response status code\n\n- **200**: Success - Request has been processed successfully\n- **401**: Unauthorized - Authentication credentials are missing or invalid\n- **402**: Insufficient Credits - Account does not have enough credits to perform the operation\n- **404**: Not Found - The requested resource or endpoint does not exist\n- **422**: Validation Error - The request parameters failed validation checks\n- **429**: Rate Limited - Request limit has been exceeded for this resource\n- **455**: Service Unavailable - System is currently undergoing maintenance\n- **500**: Server Error - An unexpected error occurred while processing the request\nServer Error - The security tolerance level is out of range and should be 0-2 or 0-6\n- **501**: Generation Failed - Image generation task failed\n- **505**: Feature Disabled - The requested feature is currently disabled","uniqueKey":"code","typeLabel":"enum\u003cinteger>"},"msg":{"type":"string","description":"Error message when code != 200","example":"success","uniqueKey":"msg","typeLabel":"string"},"data":{"type":"object","properties":{"taskId":{"type":"string","description":"Task ID, can be used with Get Image Details endpoint to query task status","example":"task12345","uniqueKey":"data.taskId","typeLabel":"string"}},"uniqueKey":"data","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"code":200,"msg":"success","data":{"taskId":"task12345"}},"examples":{"Example":{"title":"Example","value":{"code":200,"msg":"success","data":{"taskId":"task12345"}}}},"exampleType":"examples"}},"exampleType":"examples"},"94da65cd-739d-43cc-b936-c9a66e17da1f":{"description":"Server Error","content":{"_mintlify/placeholder":{"schema":{"type":"object","description":""}}}}},"security":{"9e8b7930-d0ff-411a-a7ff-8db3e94a8e39":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"All APIs require authentication via Bearer Token.\n\nGet API Key:\n1. Visit [API Key Management Page](https://fluxapi.ai/api-key) to get your API Key\n\nUsage:\nAdd to request header:\nAuthorization: Bearer YOUR_API_KEY\n\nNote:\n- Keep your API Key secure and do not share it with others\n- If you suspect your API Key has been compromised, reset it immediately in the management page","scopes":[]}}},"servers":{"649e6260-2e9d-40dd-85dc-80dfea4ab660":{"url":"https://api.fluxapi.ai","description":"API Server"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"All APIs require authentication via Bearer Token.\n\nGet API Key:\n1. Visit [API Key Management Page](https://fluxapi.ai/api-key) to get your API Key\n\nUsage:\nAdd to request header:\nAuthorization: Bearer YOUR_API_KEY\n\nNote:\n- Keep your API Key secure and do not share it with others\n- If you suspect your API Key has been compromised, reset it immediately in the management page","scopes":[]},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"All APIs require authentication via Bearer Token.\n\nGet API Key:\n1. Visit [API Key Management Page](https://fluxapi.ai/api-key) to get your API Key\n\nUsage:\nAdd to request header:\nAuthorization: Bearer YOUR_API_KEY\n\nNote:\n- Keep your API Key secure and do not share it with others\n- If you suspect your API Key has been compromised, reset it immediately in the management page","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"BearerAuth","name":"Authorization"}],"title":"BearerAuth"}]},"originalFileLocation":"flux-kontext-api/flux-kontext-api.json"},"subdomain":"fluxapiai","siteName":"Mint Starter Kit","title":"Generate or Edit Image - Mint Starter Kit","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"en":{"href":"/flux-kontext-api/generate-or-edit-image","matchLevel":0},"cn":{"href":"/cn/flux-kontext-api/generate-or-edit-image","matchLevel":1}}},"originalFileLocation":"flux-kontext-api/generate-or-edit-image.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Create a new image generation or editing task using the Flux Kontext AI model.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Mint Starter Kit\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Generate or Edit Image - Mint Starter Kit\">\u003cmeta data-mint-head property=\"og:description\" content=\"Create a new image generation or editing task using the Flux Kontext AI model.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Mint Starter Kit\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://fluxapiai.mintlify.app/_mintlify/api/og/v2?division=Flux+Kontext+API\u0026amp;title=Generate+or+Edit+Image\u0026amp;description=Create+a+new+image+generation+or+editing+task+using+the+Flux+Kontext+AI+model.\u0026amp;theme=6d32844bfbdd661128f2a7f8\u0026amp;signature=31345ec5b609701160e74be7ca175711bfa240673e34a6d37367fdd5c9cfc436\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Generate or Edit Image - Mint Starter Kit\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Create a new image generation or editing task using the Flux Kontext AI model.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://fluxapiai.mintlify.app/_mintlify/api/og/v2?division=Flux+Kontext+API\u0026amp;title=Generate+or+Edit+Image\u0026amp;description=Create+a+new+image+generation+or+editing+task+using+the+Flux+Kontext+AI+model.\u0026amp;theme=6d32844bfbdd661128f2a7f8\u0026amp;signature=31345ec5b609701160e74be7ca175711bfa240673e34a6d37367fdd5c9cfc436\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/fluxapiai/RmHvyw60KHwHoeee/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Mint Starter Kit\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#16A34A\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/flux-kontext-api/generate-or-edit-image.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"zh\" href=\"https://docs.fluxapi.ai/cn/flux-kontext-api/generate-or-edit-image\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.fluxapi.ai/#organization\",\"name\":\"Mint Starter Kit\",\"url\":\"https://docs.fluxapi.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/fluxapiai/dIoY4SstoF1lO_Fs/favicon.ico?fit=max\u0026auto=format\u0026n=dIoY4SstoF1lO_Fs\u0026q=85\u0026s=2966aad0e2aaac07727e76c722775581\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.fluxapi.ai#website\",\"name\":\"Mint Starter Kit\",\"url\":\"https://docs.fluxapi.ai\",\"publisher\":{\"@id\":\"https://docs.fluxapi.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image#webpage\",\"url\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image\",\"name\":\"Generate or Edit Image\",\"description\":\"Create a new image generation or editing task using the Flux Kontext AI model.\",\"isPartOf\":{\"@id\":\"https://docs.fluxapi.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Mint Starter Kit\",\"item\":\"https://docs.fluxapi.ai\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Generate or Edit Image\",\"item\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image#apireference\",\"headline\":\"Generate or Edit Image\",\"name\":\"Generate or Edit Image\",\"description\":\"Create a new image generation or editing task using the Flux Kontext AI model.\",\"url\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image\",\"mainEntityOfPage\":{\"@id\":\"https://docs.fluxapi.ai/flux-kontext-api/generate-or-edit-image#webpage\"},\"publisher\":{\"@id\":\"https://docs.fluxapi.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.fluxapi.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Mint Starter Kit\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Mint Starter Kit","nav":{"global":{"anchors":[{"anchor":"Home","icon":"house","href":"https://fluxapi.ai/"}]},"languages":[{"language":"en","pages":[{"group":"Getting started","pages":[{"title":"Welcome to FluxAPI AI","href":""},{"title":"Flux Kontext API Quickstart","description":"Get started with the Flux Kontext API in minutes. Learn how to generate images from text and edit existing images using AI.","icon":"rocket","href":"/quickstart"}]},{"group":"Flux Kontext API","pages":[{"title":"Generate or Edit Image","openapi":"flux-kontext-api/flux-kontext-api.json post /api/v1/flux/kontext/generate","href":"/flux-kontext-api/generate-or-edit-image"},{"title":"Image Generation or Editing Callbacks","description":"When the image generation task is completed, the system will send the result to your provided callback URL via POST request","href":"/flux-kontext-api/generate-or-edit-image-callbacks"},{"title":"Get Image Details","openapi":"flux-kontext-api/flux-kontext-api.json get /api/v1/flux/kontext/record-info","href":"/flux-kontext-api/get-image-details"}]},{"group":"Common API","pages":[{"openapi":"common-api/common-api.json get /api/v1/chat/credit","title":"Get Remaining Credits","href":"/common-api/get-account-credits"}]}]},{"language":"cn","pages":[{"title":"cn","href":"/cn/flux-kontext-api/generate-or-edit-image"}]}]},"basePath":"","title":"Generate or Edit Image - Mint Starter Kit","buildId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","deploymentId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-DCDCdBVX.js","utils-ME8dDnLe.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-0e84ACsd.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-wgRBj-ia.js","snippetPresets-C11Sgb-o.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","ApiExamples-C0lapOpP.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-ZeRQV8fF.js","shallow-BupWh095.js","getApiPlaygroundDisplay-BnYQO2Ss.js","CodeSnippet-RKKOc8c_.js","CodeSnippets-Drf_m8wS.js","Page-Bevw23-4.js","getPastedJson-u6QiPzNZ.js","icon-Bb-CBSxO.js","MethodPill-F7l5AI7V.js","DuplicateIcon-IiAXkdSg.js","createIcon-FliI8EBc.js","DynamicMarkdown-B62XqCSI.js","SectionHeading-Dj31pT03.js","axios-vUo_bRtp.js","Markdown-BOgQCTwD.js","clsx-BIWXJmsZ.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-DKZWslLH.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-UDqbR6xh.js"]}