$npx -y skills add calesthio/OpenMontage --skill bfl-apiBFL FLUX API integration guide covering endpoints, async polling patterns, rate limiting, error handling, webhooks, and regional endpoints with Python and TypeScript code examples.
| 1 | # BFL API Integration Guide |
| 2 | |
| 3 | Use this skill when integrating BFL FLUX APIs into applications for image generation, editing, and processing. |
| 4 | |
| 5 | ## First: Check API Key |
| 6 | |
| 7 | **Before generating images, verify your API key is set:** |
| 8 | |
| 9 | ```bash |
| 10 | echo $BFL_API_KEY |
| 11 | ``` |
| 12 | |
| 13 | If empty or you see "Not authenticated" errors, see [API Key Setup](#api-key-setup) below. |
| 14 | |
| 15 | ## Important: Image URLs Expire in 10 Minutes |
| 16 | |
| 17 | Result URLs from the API are temporary. Download images immediately after generation completes - do not store or cache the URLs themselves. |
| 18 | |
| 19 | ## When to Use |
| 20 | |
| 21 | - Setting up BFL API client |
| 22 | - Implementing async polling patterns |
| 23 | - Handling rate limits and errors |
| 24 | - Configuring webhooks for production |
| 25 | - Selecting regional endpoints |
| 26 | - Building production-ready integrations |
| 27 | |
| 28 | ## Quick Reference |
| 29 | |
| 30 | ### Base Endpoints |
| 31 | |
| 32 | | Region | Endpoint | Use Case | |
| 33 | | ------ | ----------------------- | --------------------------- | |
| 34 | | Global | `https://api.bfl.ai` | Default, automatic failover | |
| 35 | | EU | `https://api.eu.bfl.ai` | GDPR compliance | |
| 36 | | US | `https://api.us.bfl.ai` | US data residency | |
| 37 | |
| 38 | ### Model Endpoints & Pricing |
| 39 | |
| 40 | > **Credit pricing:** 1 credit = $0.01 USD. FLUX.2 uses megapixel-based pricing (cost scales with resolution). |
| 41 | |
| 42 | #### FLUX.2 Models |
| 43 | |
| 44 | | Model | Path | 1st MP | +MP | 1MP T2I | 1MP I2I | Best For | |
| 45 | | ----------------- | --------------------- | ------ | ---- | ------- | ------- | ---------------------------------- | |
| 46 | | FLUX.2 [klein] 4B | `/v1/flux-2-klein-4b` | 1.4c | 0.1c | $0.014 | $0.015 | Real-time, high volume | |
| 47 | | FLUX.2 [klein] 9B | `/v1/flux-2-klein-9b` | 1.5c | 0.2c | $0.015 | $0.017 | Balanced quality/speed | |
| 48 | | FLUX.2 [pro] | `/v1/flux-2-pro` | 3c | 1.5c | $0.03 | $0.045 | Production, fast turnaround | |
| 49 | | FLUX.2 [max] | `/v1/flux-2-max` | 7c | 3c | $0.07 | $0.10 | Maximum quality | |
| 50 | | FLUX.2 [flex] | `/v1/flux-2-flex` | 5c | 5c | $0.05 | $0.10 | Typography, adjustable controls | |
| 51 | | FLUX.2 [dev] | - | - | - | Free | Free | Local development (non-commercial) | |
| 52 | |
| 53 | > **Pricing formula:** `(firstMP + (outputMP-1) * mpPrice) + (inputMP * mpPrice)` in cents |
| 54 | |
| 55 | #### FLUX.1 Models |
| 56 | |
| 57 | | Model | Path | Price/Image | Best For | |
| 58 | | -------------------- | ------------------------ | ----------- | ----------------------------- | |
| 59 | | FLUX.1 Kontext [pro] | `/v1/flux-kontext` | $0.04 | Image editing with context | |
| 60 | | FLUX.1 Kontext [max] | `/v1/flux-kontext-max` | $0.08 | Max quality editing | |
| 61 | | FLUX1.1 [pro] | `/v1/flux-pro-1.1` | $0.04 | Standard T2I, fast & reliable | |
| 62 | | FLUX1.1 [pro] Ultra | `/v1/flux-pro-1.1-ultra` | $0.06 | Ultra high-resolution | |
| 63 | | FLUX1.1 [pro] Raw | `/v1/flux-pro-1.1-raw` | $0.06 | Candid photography feel | |
| 64 | | FLUX.1 Fill [pro] | `/v1/flux-pro-1.0-fill` | $0.05 | Inpainting | |
| 65 | |
| 66 | > **Tip:** All FLUX.2 models support image editing via the `input_image` parameter - no separate editing endpoint needed. Use [bfl.ai/pricing](https://bfl.ai/pricing) calculator for exact costs at different resolutions. |
| 67 | |
| 68 | ### Image Input for Editing |
| 69 | |
| 70 | **Preferred: Use URLs directly** - simpler and more convenient than base64. |
| 71 | |
| 72 | **Single image editing:** |
| 73 | |
| 74 | ```bash |
| 75 | curl -X POST "https://api.bfl.ai/v1/flux-2-pro" \ |
| 76 | -H "x-key: $BFL_API_KEY" \ |
| 77 | -H "Content-Type: application/json" \ |
| 78 | -d '{ |
| 79 | "prompt": "Change the background to a sunset", |
| 80 | "input_image": "https://example.com/photo.jpg" |
| 81 | }' |
| 82 | ``` |
| 83 | |
| 84 | **Multi-reference editing:** |
| 85 | |
| 86 | ```bash |
| 87 | curl -X POST "https://api.bfl.ai/v1/flux-2-pro" \ |
| 88 | -H "x-key: $BFL_API_KEY" \ |
| 89 | -H "Content-Type: application/json" \ |
| 90 | -d '{ |
| 91 | "prompt": "The person from image 1 in the environment from image 2", |
| 92 | "input_image": "https://example.com/person.jpg", |
| 93 | "input_image_2": "https://example.com/background.jpg" |
| 94 | }' |
| 95 | ``` |
| 96 | |
| 97 | The API fetches URLs automatically. Both URL and base64 work, but URLs are recommended when available. |
| 98 | |
| 99 | ### Multi-Reference I2I |
| 100 | |
| 101 | FLUX.2 models support multiple input images for combining elements, style transfer, and character consistency: |
| 102 | |
| 103 | | Model | Max References | |
| 104 | | --------------------- | -------------- | |
| 105 | | FLUX.2 [klein] | 4 images | |
| 106 | | FLUX.2 [pro/max/flex] | 8 images | |
| 107 | |
| 108 | **Parameters:** `input_image`, `input_image_2`, `input_image_3`, ... `input_image_8` |
| 109 | |
| 110 | **Prompt pattern:** Reference images by number in you |