Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.
FLUX.2 is now our recommended model for image generation. It offers superior quality, multi-reference support, and output up to 4MP. Get started with FLUX.2 →
FLUX.1 Kontext [pro] is a previous-generation model that creates images from text prompts, with capabilities for character consistency and editing.
Want to try first? Test Kontext in our playground before integrating the API.
Prompts for the images above:• Abstract cat artwork: “Abstract expressionist painting Pop Art and cubism early 20 century, straight lines and solids, cute cat face without body, warm colors, green, intricate details, hologram floating in space, a vibrant digital illustration, black background, flat color, 2D, strong lines.”• Robot and truck: “A cute round rusted robot repairing a classic pickup truck, colorful, futuristic, vibrant glow, van gogh style”• Furry elephant: “A small furry elephant pet looks out from a cat house”• Face paint portrait: “A close-up of a face adorned with intricate black and blue patterns. The left side of the face is predominantly yellow, with symbols and doodles, while the right side is dark, featuring mechanical elements. The eye on the left is a striking shade of yellow, contrasting sharply with the surrounding patterns. The face is partially covered by a hooded garment, realistic style”
Prompts for the images above:• Rainy car scene: “Close-up of a vintage car hood under heavy rain, droplets cascading down the deep cherry-red paint, windshield blurred with streaks of water, glowing headlights diffused through mist, reflections of crimson neon signage spelling “FLUX” dancing across the wet chrome grille, steam rising from the engine, ambient red light enveloping the scene, moody composition, shallow depth of field, monochromatic red palette, cinematic lighting with glossy textures.”• Burning temple warrior: “A lone warrior, clad in bloodstained samurai armor, stands motionless before a massive pagoda engulfed in flames. Embers and ash swirl around him like ghosts of fallen enemies. The once-sacred temple is collapsing, its ornate carvings crumbling into the blaze as distant screams echo through the smoke-filled air. A tattered banner flutters beside him, the last symbol of a forgotten oath. The scene is both devastating and mesmerizing, with deep reds, burning oranges, and cold blue shadows creating a stark contrast. Cinematic composition, ultra-detailed textures, dynamic lighting, atmospheric fog, embers in the wind, dark fantasy realism, intense contrast.”• Foggy gas station: “Remote gas station swallowed by crimson fog, green glow from overhead lights staining the asphalt, new tiny smart car idling with taillights cutting through the mist, vending machine humming beside cracked fuel pumps, oily puddles reflecting distorted neon, shadows stretching unnaturally long, skeletal trees barely visible in the background, wide-angle cinematic shot, deep green monochromatic palette with faint charcoal accents, backlighting and heavy atmosphere, surreal and ominous mood.”• Detective game character: “Retro game style, man in old school suit, upper body, true detective, detailed character, night sky, crimson moon silhouette, american muscle car parked on dark street in background, complex background in style of Bill Sienkiewicz and Dave McKean and Carne Griffiths, extremely detailed, mysterious, grim, provocative, thrilling, dynamic, action-packed, fallout style, vintage, game theme, masterpiece, high contrast, stark. vivid colors, 16-bit, pixelated, textured, distressed”
# Install `curl` and `jq`, then run:# Ensure BFL_API_KEY is set# export BFL_API_KEY="your_api_key_here"request=$(curl -X POST \ 'https://api.bfl.ai/v1/flux-kontext-pro' \ -H 'accept: application/json' \ -H "x-key: ${BFL_API_KEY}" \ -H 'Content-Type: application/json' \ -d '{ "prompt": "A small furry elephant pet looks out from a cat house", "aspect_ratio": "1:1"}')request_id=$(echo $request | jq -r .id)polling_url=$(echo $request | jq -r .polling_url)
# Install `requests` (e.g. `pip install requests`) and `Pillow` (e.g. `pip install Pillow`), then run:import osimport requestsimport timerequest = requests.post( 'https://api.bfl.ai/v1/flux-kontext-pro', headers={ 'accept': 'application/json', 'x-key': os.environ.get("BFL_API_KEY"), 'Content-Type': 'application/json', }, json={ 'prompt': 'A small furry elephant pet looks out from a cat house', },).json()print(request)request_id = request["id"]polling_url = request["polling_url"] # Use this URL for polling
A successful response will be a JSON object containing the request’s id. This ID is used to retrieve the generated image.
FLUX.1 Kontext creates 1024x1024 images by default. Use aspect_ratio to adjust the dimensions while keeping the same total pixels.
Supported Range: Aspect ratios can range from 3:7 (portrait) to 7:3 (landscape).
Default Behavior: If aspect_ratio is not specified, the model defaults to 1:1 (1024x1024).
Parameter
Type
Default
Description
Required
prompt
string
Text description of the desired image.
Yes
aspect_ratio
string / null
"1:1"
Desired aspect ratio (e.g., “16:9”). All outputs are ~1MP total. Supports ratios from 3:7 to 7:3.
No
seed
integer / null
null
Seed for reproducibility. If null or omitted, a random seed is used. Accepts any integer.
No
prompt_upsampling
boolean
false
If true, performs upsampling on the prompt
No
safety_tolerance
integer
2
Moderation level for inputs and outputs. Value ranges from 0 (most strict) to 6 (more permissive).
No
output_format
string
"jpeg"
Desired format of the output image. Can be “jpeg” or “png”.
No
webhook_url
string / null
null
URL for asynchronous completion notification. Must be a valid HTTP/HTTPS URL.
No
webhook_secret
string / null
null
Secret for webhook signature verification, sent in the X-Webhook-Secret header.
No
Was this page helpful?
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"Black Forest Labs","colors":{"primary":"#486A58","light":"#F6F1E7","dark":"#13251D"},"logo":{"light":"https://mintcdn.com/bfl/OQ5B17YmedKOM4zs/logo/logo_light.png?fit=max\u0026auto=format\u0026n=OQ5B17YmedKOM4zs\u0026q=85\u0026s=a11f73fac1ef9254cffa5eb412269198","dark":"https://mintcdn.com/bfl/OQ5B17YmedKOM4zs/logo/logo_dark.png?fit=max\u0026auto=format\u0026n=OQ5B17YmedKOM4zs\u0026q=85\u0026s=d933d5452b84db18fc87cd6321e33d08"},"favicon":"https://mintcdn.com/bfl/OQ5B17YmedKOM4zs/favicon.ico?fit=max\u0026auto=format\u0026n=OQ5B17YmedKOM4zs\u0026q=85\u0026s=d0fe6b872ae546a0581d176dfb8726ce","api":{"openapi":["https://api.bfl.ai/openapi.json","https://api.bfl.ai/v1/licenses/docs/openapi.json"]},"background":{"color":{"light":"#f3f1e6","dark":"#07130e"}},"navbar":{"links":[{"href":"https://help.bfl.ai","label":"Help Center"},{"href":"https://status.bfl.ai","label":"API Status"},{"href":"https://bfl.ai/pricing","label":"API Pricing"}],"primary":{"type":"button","label":"Get API Key","href":"https://dashboard.bfl.ai/"}},"footer":{"socials":{"x":"https://x.com/bfl_ai","github":"https://github.com/black-forest-labs","linkedin":"https://www.linkedin.com/company/bflai"},"links":[{"header":"Legal","items":[{"label":"Impressum","href":"https://bfl.ai/legal/imprint"},{"label":"Developer Terms of Service","href":"https://bfl.ai/legal/developer-terms-of-service"},{"label":"Flux API Service Terms","href":"https://bfl.ai/legal/flux-api-service-terms"},{"label":"Terms of Use","href":"https://bfl.ai/legal/terms-of-use"},{"label":"Responsible AI Development Policy","href":"https://bfl.ai/legal/responsible-ai-development-policy"},{"label":"Usage Policy","href":"https://bfl.ai/legal/usage-policy"},{"label":"Intellectual Property Policy","href":"https://bfl.ai/legal/intellectual-property-policy"},{"label":"Privacy Policy","href":"https://bfl.ai/legal/privacy-policy"}]},{"header":"Company","items":[{"label":"Careers","href":"https://bfl.ai/careers"},{"label":"Help Center","href":"https://help.bfl.ai/"},{"label":"Contact","href":"https://bfl.ai/contact"}]}]},"fonts":{"family":"Instrument Sans"},"integrations":{"posthog":{"apiKey":"phc_S5D9NAXVC6BGl2PWlhihIW6IcKFYloe6zvUZW9SU1Bu","apiHost":"https://eu.i.posthog.com"}},"banner":{"content":"Introducing FLUX 3 Image Klein, open weights • [Learn more](/flux_3/flux3_image_klein)","dismissible":true},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"thumbnails":{"background":"https://cdn.sanity.io/images/2gpum2i6/production/7a2a3a2a8d594db99b03a24b413a3f59da2f7e9e-2401x1284.jpg"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"bfl","hasAudioNarration":false,"actualSubdomain":"bfl","customDomains":["docs.bfl.ml","docs.bfl.ai"],"gitSource":{"type":"github","owner":"black-forest-labs","repo":"dokumentation","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ada4ccbb24e0f7b8738efdb","collectionId":"eb7ffcdc-c65e-4964-82dd-ae0795bc7569","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ada4ccbb24e0f7b8738efdb"},"feedback":{"thumbs":true,"agentFeedback":false},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6ada4ccbb24e0f7b8738efdb","clientVersion":"0.0.3965","searchFilterCounts":[{"language":"default","tag":"Documentation","count":135},{"language":"default","tag":"Prompting Guide","count":54},{"language":"default","tag":"API Reference","count":31},{"language":"default","tag":"Use Cases with FLUX","count":21},{"language":"default","tag":"FLUX Tools","count":13},{"language":"default","tag":"Legacy Models","count":13},{"language":"default","tag":"FLUX 3","count":13},{"language":"default","tag":"Editing Use Cases","count":11},{"language":"default","tag":"Text-to-Image Use Cases","count":9},{"language":"default","tag":"Image Generation with FLUX","count":7}],"searchSettings":{"showContentSnippets":true}},"assistantConfig":{},"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":"editor-v7-file-tree","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":"pause-universal-search-reconcile","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":"per-site-search-delta","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":"editor-private-page-search","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":"editor-nav-generations","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":"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":"editor-agent-model-picker","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":"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}],"isAtlas":false,"googleFontsInlined":true},"customCss":[{"filePath":"style.css","href":"/_mintlify/custom/bfl/28e9cddcb212eb2a/style.css"}],"page":{"pagePath":"kontext/kontext_text_to_image","slug":"/kontext/kontext_text_to_image","pageMetadata":{"title":"Image Generation","sidebarTitle":"Image Generation","description":"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.","href":"/kontext/kontext_text_to_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: \"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.\"\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={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Columns,Frame,Heading,Info,OptimizedImage,Table,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Columns)_missingMdxReference(`Columns`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Info,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`FLUX.2 is now our recommended model for image generation.`}),` It offers superior quality, multi-reference support, and output up to 4MP. `,_jsx(_components.a,{href:`/flux_2/flux2_text_to_image`,children:`Get started with FLUX.2 →`})]})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`FLUX.1 Kontext [pro]`}),` is a previous-generation model that creates images from text prompts, with capabilities for character consistency and editing.`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Want to try first?`}),` Test Kontext in our `,_jsx(_components.a,{href:`https://playground.bfl.ai`,children:`playground`}),` before integrating the API.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`quick-examples`,children:`Quick Examples`}),`\n`,_jsxs(Columns,{cols:4,children:[_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/a25299ba8dd5d386cfbf9cf9f3a3f2c519fd3b92-1024x1024.jpg`})}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/f4879d430a114e9a28f62e42192365976bd9d545-1024x1024.jpg`})}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/4fc50f2d7b8abbdbdb5bdcf979309e3e6df1d31e-1024x1024.jpg`})}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/cf8197b308cbd564f5fd43eedf52fce612b49806-1024x1024.jpg`})})]}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Prompts for the images above:`})}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Abstract cat artwork:`}),` “Abstract expressionist painting Pop Art and cubism early 20 century, straight lines and solids, cute cat face without body, warm colors, green, intricate details, hologram floating in space, a vibrant digital illustration, black background, flat color, 2D, strong lines.”`]}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Robot and truck:`}),` “A cute round rusted robot repairing a classic pickup truck, colorful, futuristic, vibrant glow, van gogh style”`]}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Furry elephant:`}),` “A small furry elephant pet looks out from a cat house”`]}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Face paint portrait:`}),` “A close-up of a face adorned with intricate black and blue patterns. The left side of the face is predominantly yellow, with symbols and doodles, while the right side is dark, featuring mechanical elements. The eye on the left is a striking shade of yellow, contrasting sharply with the surrounding patterns. The face is partially covered by a hooded garment, realistic style”`]}),`\n`,_jsxs(Columns,{cols:4,children:[_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/3bce31811d0a95960f2a30ca8c548af9463b78c8-1024x1024.jpg`})}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/fe5135de7fa5a666ddb38f234dd55fe285435719-1024x1024.jpg`})}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/930a9437a1b85af8721e9107daefa76e40b82365-1024x1024.jpg`})}),_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://cdn.sanity.io/images/gsvmb6gz/production/821bc59e839e362bc02a10a6662dc52e4da71da5-1024x1024.jpg`})})]}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Prompts for the images above:`})}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Rainy car scene:`}),` “Close-up of a vintage car hood under heavy rain, droplets cascading down the deep cherry-red paint, windshield blurred with streaks of water, glowing headlights diffused through mist, reflections of crimson neon signage spelling “FLUX” dancing across the wet chrome grille, steam rising from the engine, ambient red light enveloping the scene, moody composition, shallow depth of field, monochromatic red palette, cinematic lighting with glossy textures.”`]}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Burning temple warrior:`}),` “A lone warrior, clad in bloodstained samurai armor, stands motionless before a massive pagoda engulfed in flames. Embers and ash swirl around him like ghosts of fallen enemies. The once-sacred temple is collapsing, its ornate carvings crumbling into the blaze as distant screams echo through the smoke-filled air. A tattered banner flutters beside him, the last symbol of a forgotten oath. The scene is both devastating and mesmerizing, with deep reds, burning oranges, and cold blue shadows creating a stark contrast. Cinematic composition, ultra-detailed textures, dynamic lighting, atmospheric fog, embers in the wind, dark fantasy realism, intense contrast.”`]}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Foggy gas station:`}),` “Remote gas station swallowed by crimson fog, green glow from overhead lights staining the asphalt, new tiny smart car idling with taillights cutting through the mist, vending machine humming beside cracked fuel pumps, oily puddles reflecting distorted neon, shadows stretching unnaturally long, skeletal trees barely visible in the background, wide-angle cinematic shot, deep green monochromatic palette with faint charcoal accents, backlighting and heavy atmosphere, surreal and ominous mood.”`]}),`\n`,_jsxs(_components.p,{children:[`• `,_jsx(_components.strong,{children:`Detective game character:`}),` “Retro game style, man in old school suit, upper body, true detective, detailed character, night sky, crimson moon silhouette, american muscle car parked on dark street in background, complex background in style of Bill Sienkiewicz and Dave McKean and Carne Griffiths, extremely detailed, mysterious, grim, provocative, thrilling, dynamic, action-packed, fallout style, vintage, game theme, masterpiece, high contrast, stark. vivid colors, 16-bit, pixelated, textured, distressed”`]}),`\n`,_jsx(Heading,{level:`2`,id:`using-flux-1-kontext-api-for-text-to-image-generation`,children:`Using FLUX.1 Kontext API for Text-to-Image Generation`}),`\n`,_jsx(Heading,{level:`3`,id:`create-a-request`,children:`Create a Request`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`create_request.sh`,numberOfLines:`16`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`16`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\"# Install `curl` and `jq`, then run:\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Ensure BFL_API_KEY is set`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# export BFL_API_KEY=\"your_api_key_here\"`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`request`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://api.bfl.ai/v1/flux-kontext-pro'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'accept: application/json'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"x-key: ${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BFL_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Content-Type: application/json'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"prompt\": \"A small furry elephant pet looks out from a cat house\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"aspect_ratio\": \"1:1\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`request_id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`echo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $request`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` .id`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`polling_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`echo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $request`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` .polling_url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`create_request.py`,numberOfLines:`20`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`20`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\"# Install `requests` (e.g. `pip install requests`) and `Pillow` (e.g. `pip install Pillow`), then run:\"})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` time`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`request `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests.post(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://api.bfl.ai/v1/flux-kontext-pro'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` headers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'accept'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'x-key'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: os.environ.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"BFL_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` json`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'prompt'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'A small furry elephant pet looks out from a cat house'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`).json()`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(request)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`request_id `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` request[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`polling_url `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` request[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"polling_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Use this URL for polling`})]}),`\n`]})})})]}),`\n`,_jsxs(_components.p,{children:[`A successful response will be a JSON object containing the request’s `,_jsx(_components.code,{children:`id`}),`. This ID is used to retrieve the generated image.`]}),`\n`,_jsx(Heading,{level:`3`,id:`poll-for-result`,children:`Poll for Result`}),`\n`,_jsxs(_components.p,{children:[`After submitting a request, you need to poll using the returned `,_jsx(_components.code,{children:`polling_url`}),` to retrieve the output when ready.`]}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`poll_result.sh`,numberOfLines:`18`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`while`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`do`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` sleep`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0.5`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -s`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'GET'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`polling_url`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'accept: application/json'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"x-key: ${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BFL_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` status`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`echo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` .status`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` echo`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Status: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$status`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [ `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$status`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Ready\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]; `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`then`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` echo`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Result: $(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`echo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` .result.sample)\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` elif`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [ `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$status`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`||`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [ `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$status`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Failed\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]; `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`then`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` echo`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Generation failed: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$result`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` fi`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`done`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`poll_result.py`,numberOfLines:`21`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`21`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\"# This assumes that the `polling_url` variable is set.\"})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` time`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`while`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` time.sleep(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests.get(`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` polling_url,`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` headers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'accept'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'x-key'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: os.environ.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"BFL_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ).json()`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'status'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Ready'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Image ready: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'result'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`][`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'sample'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` elif`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'status'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Error'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Failed'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Generation failed: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`]})})})]}),`\n`,_jsxs(_components.p,{children:[`A successful response will be a JSON object containing the result, and `,_jsx(_components.code,{children:`result['sample']`}),` is a signed URL for retrieval.`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Our signed URLs are only valid for 10 minutes. Please retrieve your result within this timeframe.`})}),`\n`,_jsx(Heading,{level:`3`,id:`flux-1-kontext-text-to-image-parameters`,children:`FLUX.1 Kontext Text-to-Image Parameters`}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`FLUX.1 Kontext creates 1024x1024 images by default. Use `,_jsx(_components.code,{children:`aspect_ratio`}),` to adjust the dimensions while keeping the same total pixels.`]})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Supported Range`}),`: Aspect ratios can range from 3:7 (portrait) to 7:3 (landscape).`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Default Behavior`}),`: If `,_jsx(_components.code,{children:`aspect_ratio`}),` is not specified, the model defaults to 1:1 (1024x1024).`]}),`\n`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Default`}),_jsx(_components.th,{children:`Description`}),_jsx(_components.th,{children:`Required`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`prompt`})}),_jsx(_components.td,{children:`string`}),_jsx(_components.td,{}),_jsx(_components.td,{children:`Text description of the desired image.`}),_jsx(_components.td,{children:_jsx(_components.strong,{children:`Yes`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`aspect_ratio`})}),_jsx(_components.td,{children:`string / null`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`\"1:1\"`})}),_jsx(_components.td,{children:`Desired aspect ratio (e.g., “16:9”). All outputs are ~1MP total. Supports ratios from 3:7 to 7:3.`}),_jsx(_components.td,{children:`No`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`seed`})}),_jsx(_components.td,{children:`integer / null`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`null`})}),_jsxs(_components.td,{children:[`Seed for reproducibility. If `,_jsx(_components.code,{children:`null`}),` or omitted, a random seed is used. Accepts any integer.`]}),_jsx(_components.td,{children:`No`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`prompt_upsampling`})}),_jsx(_components.td,{children:`boolean`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`false`})}),_jsx(_components.td,{children:`If true, performs upsampling on the prompt`}),_jsx(_components.td,{children:`No`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`safety_tolerance`})}),_jsx(_components.td,{children:`integer`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`2`})}),_jsx(_components.td,{children:`Moderation level for inputs and outputs. Value ranges from 0 (most strict) to 6 (more permissive).`}),_jsx(_components.td,{children:`No`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`output_format`})}),_jsx(_components.td,{children:`string`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`\"jpeg\"`})}),_jsx(_components.td,{children:`Desired format of the output image. Can be “jpeg” or “png”.`}),_jsx(_components.td,{children:`No`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`webhook_url`})}),_jsx(_components.td,{children:`string / null`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`null`})}),_jsx(_components.td,{children:`URL for asynchronous completion notification. Must be a valid HTTP/HTTPS URL.`}),_jsx(_components.td,{children:`No`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`webhook_secret`})}),_jsx(_components.td,{children:`string / null`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`null`})}),_jsxs(_components.td,{children:[`Secret for webhook signature verification, sent in the `,_jsx(_components.code,{children:`X-Webhook-Secret`}),` header.`]}),_jsx(_components.td,{children:`No`})]})]})]})]})}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":"Image Generation","sidebarTitle":"Image Generation","description":"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.","href":"/kontext/kontext_text_to_image"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Quick Examples","slug":"quick-examples","depth":2,"children":[]},{"title":"Using FLUX.1 Kontext API for Text-to-Image Generation","slug":"using-flux-1-kontext-api-for-text-to-image-generation","depth":2,"children":[{"title":"Create a Request","slug":"create-a-request","depth":3,"children":[]},{"title":"Poll for Result","slug":"poll-for-result","depth":3,"children":[]},{"title":"FLUX.1 Kontext Text-to-Image Parameters","slug":"flux-1-kontext-text-to-image-parameters","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/bfl/589dc04dc07c9b1b/analytics.js"],"subdomain":"bfl","siteName":"Black Forest Labs","title":"Image Generation - Black Forest Labs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-04-27T00:12:43.298Z","originalFileLocation":"kontext/kontext_text_to_image.mdx"},"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=\"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Black Forest Labs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/bfl/qSW9OJZxslZOxxB1/_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/bfl/qSW9OJZxslZOxxB1/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/bfl/qSW9OJZxslZOxxB1/_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/bfl/qSW9OJZxslZOxxB1/_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/bfl/qSW9OJZxslZOxxB1/_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/bfl/qSW9OJZxslZOxxB1/_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/bfl/qSW9OJZxslZOxxB1/_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/bfl/qSW9OJZxslZOxxB1/_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/bfl/qSW9OJZxslZOxxB1/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Image Generation - Black Forest Labs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Black Forest Labs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.bfl.ml/kontext/kontext_text_to_image\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://bfl.mintlify.app/_mintlify/api/og/v2?division=FLUX.1+Kontext\u0026amp;title=Image+Generation\u0026amp;description=Generate+images+from+text+prompts+using+FLUX.1+Kontext.+For+new+projects%2C+we+recommend+FLUX.2+for+text-to-image+generation.\u0026amp;theme=a70df1157b5b08d96e98c16c\u0026amp;signature=a00c7ed458c62a3630fb3e234e14a1d5772487befeccadf159b948cb9af771ab\">\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=\"Image Generation - Black Forest Labs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://bfl.mintlify.app/_mintlify/api/og/v2?division=FLUX.1+Kontext\u0026amp;title=Image+Generation\u0026amp;description=Generate+images+from+text+prompts+using+FLUX.1+Kontext.+For+new+projects%2C+we+recommend+FLUX.2+for+text-to-image+generation.\u0026amp;theme=a70df1157b5b08d96e98c16c\u0026amp;signature=a00c7ed458c62a3630fb3e234e14a1d5772487befeccadf159b948cb9af771ab\">\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/bfl/qSW9OJZxslZOxxB1/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Black Forest Labs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#486A58\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.bfl.ml/kontext/kontext_text_to_image\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/kontext/kontext_text_to_image.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.bfl.ml/#organization\",\"name\":\"Black Forest Labs\",\"url\":\"https://docs.bfl.ml\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/bfl/OQ5B17YmedKOM4zs/logo/logo_light.png?fit=max\u0026auto=format\u0026n=OQ5B17YmedKOM4zs\u0026q=85\u0026s=a11f73fac1ef9254cffa5eb412269198\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.bfl.ml#website\",\"name\":\"Black Forest Labs\",\"url\":\"https://docs.bfl.ml\",\"publisher\":{\"@id\":\"https://docs.bfl.ml/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.bfl.ml/kontext/kontext_text_to_image#webpage\",\"url\":\"https://docs.bfl.ml/kontext/kontext_text_to_image\",\"name\":\"Image Generation\",\"description\":\"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.\",\"dateModified\":\"2026-04-27T00:12:43.298Z\",\"isPartOf\":{\"@id\":\"https://docs.bfl.ml#website\"},\"breadcrumb\":{\"@id\":\"https://docs.bfl.ml/kontext/kontext_text_to_image#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.bfl.ml/kontext/kontext_text_to_image#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Legacy Models\",\"item\":\"https://docs.bfl.ml/kontext/kontext_overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FLUX.1 Kontext\",\"item\":\"https://docs.bfl.ml/kontext/kontext_overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Image Generation\",\"item\":\"https://docs.bfl.ml/kontext/kontext_text_to_image\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.bfl.ml/kontext/kontext_text_to_image#article\",\"headline\":\"Image Generation\",\"name\":\"Image Generation\",\"description\":\"Generate images from text prompts using FLUX.1 Kontext. For new projects, we recommend FLUX.2 for text-to-image generation.\",\"url\":\"https://docs.bfl.ml/kontext/kontext_text_to_image\",\"mainEntityOfPage\":{\"@id\":\"https://docs.bfl.ml/kontext/kontext_text_to_image#webpage\"},\"dateModified\":\"2026-04-27T00:12:43.298Z\",\"publisher\":{\"@id\":\"https://docs.bfl.ml/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.bfl.ml#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Black Forest Labs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Black Forest Labs","nav":{"global":null,"anchors":[{"anchor":"Documentation","icon":"book-open-cover","tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"The frontier of visual intelligence","sidebarTitle":"Overview","mode":"wide","href":"/quick_start/introduction"},{"title":"Quick Start","sidebarTitle":"Quick Start","mode":"wide","href":"/quick_start/get_started"},{"title":"Overview","sidebarTitle":"API Pricing","href":"/quick_start/pricing"}]},{"group":"Account Management","pages":[{"title":"Organizations \u0026 Projects","sidebarTitle":"Organizations \u0026 Projects","href":"/account_management/organizations_projects"},{"title":"Team Management","sidebarTitle":"Team Management","href":"/account_management/team_management"},{"title":"Credits \u0026 Billing","sidebarTitle":"Credits \u0026 Billing","href":"/account_management/credits_billing"}]},{"group":"FLUX 3","pages":[{"group":"Video","pages":[{"title":"FLUX 3 Video","sidebarTitle":"Overview","mode":"wide","href":"/flux_3/flux3_overview"},{"title":"Video","sidebarTitle":"Generate video","mode":"wide","href":"/flux_3/flux3_video"}]},{"group":"Image","pages":[{"title":"FLUX 3 Image","sidebarTitle":"Overview","href":"/flux_3/flux3_image_overview"},{"title":"FLUX 3 Text to Image","sidebarTitle":"FLUX 3 Text to Image","href":"/flux_3/flux3_image_generate"},{"title":"FLUX 3 Image Editing","sidebarTitle":"FLUX 3 Image Editing","href":"/flux_3/flux3_image_layout"},{"title":"Bounding boxes with FLUX 3 Image","sidebarTitle":"Bounding boxes","href":"/flux_3/flux3_image_bounding_boxes"},{"title":"FLUX 3 Image Klein","sidebarTitle":"FLUX 3 Image Klein","href":"/flux_3/flux3_image_klein"}]},{"group":"Action","pages":[{"title":"FLUX 3 Action","sidebarTitle":"Overview","href":"/flux_3/flux3_action_overview"},{"title":"Run FLUX 3 Action","sidebarTitle":"Run the model","href":"/flux_3/flux3_action_inference"},{"title":"Fine-tune FLUX 3 Action","sidebarTitle":"Fine-tuning","href":"/flux_3/flux3_action_finetuning"},{"title":"SO-101 with LeRobot","sidebarTitle":"SO-101 with LeRobot","href":"/flux_3/flux3_action_so101"},{"title":"Example: FLUX 3 Action plays video games","sidebarTitle":"Example: a video game","href":"/flux_3/flux3_action_games"},{"title":"Example: teach FLUX 3 Action to fly a drone","sidebarTitle":"Example: a drone","href":"/flux_3/flux3_action_drone"}]}]},{"group":"FLUX.2","pages":[{"title":"Overview","sidebarTitle":"Overview","href":"/flux_2/flux2_overview"},{"title":"FLUX.2 Image Editing","sidebarTitle":"FLUX.2 Image Editing","href":"/flux_2/flux2_image_editing"},{"title":"FLUX.2 Text to Image","sidebarTitle":"FLUX.2 Text to Image","href":"/flux_2/flux2_text_to_image"}]},{"group":"FLUX Tools","pages":[{"title":"FLUX Video Edit","sidebarTitle":"FLUX Video Edit","href":"/flux_tools/flux_video_edit"},{"title":"FLUX Video Upscale","sidebarTitle":"FLUX Video Upscale","href":"/flux_tools/flux_video_upscale"},{"title":"FLUX Outpainting","sidebarTitle":"FLUX Outpainting","href":"/flux_tools/flux_outpainting"},{"title":"FLUX Erase","sidebarTitle":"FLUX Erase","href":"/flux_tools/flux_erase"},{"title":"FLUX Deblur","sidebarTitle":"FLUX Deblur","href":"/flux_tools/flux_deblur"},{"title":"FLUX Virtual Try-On (VTO)","sidebarTitle":"FLUX Virtual Try-On","href":"/flux_tools/flux_vto"}]},{"group":"API Integration","pages":[{"title":"FLUX API Integration Guide","sidebarTitle":"Integration Guide","href":"/api_integration/integration_guidelines"},{"title":"FLUX MCP server","sidebarTitle":"MCP \u0026 Agent Skills","mode":"wide","href":"/api_integration/mcp_integration"},{"title":"Errors","sidebarTitle":"Errors","href":"/api_integration/errors"}]},{"group":"Training","pages":[{"title":"FLUX.2 [klein] Training","sidebarTitle":"FLUX.2 [klein] Training","href":"/flux_2/flux2_klein_training"},{"title":"FLUX.2 [klein] Style Training","sidebarTitle":"FLUX.2 [klein] Style Training","href":"/flux_2/flux2_klein_training_example"}]},{"group":"Legacy Models","pages":[{"group":"FLUX.1 Kontext","pages":[{"title":"Introduction","sidebarTitle":"Introduction","description":"Overview of FLUX.1 Kontext, a model that combines text-to-image generation with context-aware image editing. For new projects, we recommend FLUX.2.","href":"/kontext/kontext_overview"},{"title":"Image Generation","sidebarTitle":"Image Generation","href":"/kontext/kontext_text_to_image"},{"title":"Image Editing","description":"FLUX.1 Kontext image editing model. For new projects, we recommend FLUX.2 with multi-reference support and up to 4MP output.","href":"/kontext/kontext_image_editing"}]},{"group":"FLUX1.1 [pro] Models","pages":[{"title":"FLUX1.1 [pro] Image Generation","sidebarTitle":"FLUX1.1 [pro]","href":"/flux_models/flux_1_1_pro"},{"title":"FLUX1.1 [pro] Ultra Mode","sidebarTitle":"FLUX1.1 [pro] Ultra / Raw","href":"/flux_models/flux_1_1_pro_ultra_raw"}]},{"group":"FLUX.1 Tools","pages":[{"title":"FLUX.1 Fill [pro]","href":"/flux_1_fill"}]}]}]},{"tab":"Cookbook","hidden":true,"searchable":true,"pages":[{"title":"Cookbook","href":"/cookbook/overview"}]},{"tab":"Prompting Guide","pages":[{"title":"Prompting Guide","href":"/guides/prompting_video_overview"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/utility/get-result"}]},{"tab":"Release Notes","pages":[{"title":"Release Notes","href":"/release-notes"}]}]},{"anchor":"Prompting Guide","icon":"graduation-cap","pages":[{"title":"Prompting Guide","href":"/guides/prompting_video_overview"}]},{"anchor":"BFL Homepage","icon":"house","href":"https://bfl.ai"},{"anchor":"Help Center","icon":"question","href":"https://help.bfl.ai"}]},"title":"Image Generation - Black Forest Labs","buildId":"dpl_849ArpqvBiCczQiT1Y1stNGpbqHT","deploymentId":"dpl_849ArpqvBiCczQiT1Y1stNGpbqHT","dynamics":["10e4515597","07c022d89b","a74be98ba7"],"chunks":["BannerMarkdown-cfwQA_n9.js","dist-2LoAhjKH.js","lib--scc4DXi.js","lib-B8HbPgcC.js","clsx-DZLdJUrt.js","html-void-elements-mCSPHezU.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","Frame-Cz91mEGH.js","DynamicMarkdown-a8hUKrw6.js","zoom-image-lightbox-CaUwvYH3.js","lightbox-handle-r17bVUz3.js"]}