{
  "openapi": "3.1.0",
  "info": {
    "title": "FLUX image generation API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/flux/v1/{model}": {
      "post": {
        "summary": "Generate or edit a FLUX image",
        "operationId": "flux_generate_image",
        "description": "Submit a native BFL-format asynchronous task. Store the top-level response `id`, then poll `GET /flux/v1/get_result?id=...`. Use that CometAPI route instead of depending on a response-supplied `polling_url`.",
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "description": "FLUX.2 model ID in the URL path. Check `/v1/models` or the Models page for account availability.",
            "schema": {
              "type": "string"
            },
            "example": "flux-2-pro"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "dependentRequired": {
                  "input_image_2": [
                    "input_image"
                  ]
                },
                "properties": {
                  "prompt": {
                    "type": "string",
                    "description": "Text prompt describing the image or reference-image edit.",
                    "example": "A clean editorial photograph of a red ceramic teapot on a pale blue table, soft window light, no text."
                  },
                  "input_image": {
                    "type": "string",
                    "description": "Public HTTPS URL of the first reference image. Replace the example URL with an image that the model provider can retrieve. This editing field is available for the FLUX.2 models covered by this reference.",
                    "example": "https://your-image-host/reference-one.jpg"
                  },
                  "input_image_2": {
                    "type": "string",
                    "description": "Public HTTPS URL of a second reference image for `flux-2-pro`. Replace the example URL and also send `input_image`.",
                    "example": "https://your-image-host/reference-two.jpg"
                  },
                  "seed": {
                    "type": "integer",
                    "description": "Optional seed value. A completed result can report the used seed; that field alone does not establish repeatable output."
                  },
                  "width": {
                    "type": "integer",
                    "description": "Requested output width in pixels. Use a dimension supported by the selected model.",
                    "example": 1280
                  },
                  "height": {
                    "type": "integer",
                    "description": "Requested output height in pixels. Use a dimension supported by the selected model.",
                    "example": 768
                  },
                  "output_format": {
                    "type": "string",
                    "description": "Requested output image format supported by the selected model. The examples use `png`.",
                    "example": "png"
                  }
                }
              },
              "examples": {
                "Text to image (FLUX.2 Pro)": {
                  "summary": "Submit a PNG task with FLUX.2 Pro",
                  "value": {
                    "prompt": "A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.",
                    "seed": 424242,
                    "width": 1280,
                    "height": 768,
                    "output_format": "png"
                  }
                },
                "Text to image (FLUX.2 Flex)": {
                  "summary": "Submit a text-to-image task that requests PNG output with FLUX.2 Flex",
                  "value": {
                    "prompt": "A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.",
                    "width": 1280,
                    "height": 768,
                    "output_format": "png"
                  }
                },
                "Text to image (FLUX.2 Max)": {
                  "summary": "Submit a PNG task with FLUX.2 Max",
                  "value": {
                    "prompt": "A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.",
                    "width": 1280,
                    "height": 768,
                    "output_format": "png"
                  }
                },
                "Reference image edit (FLUX.2 Flex)": {
                  "summary": "Replace the example URL with a public reference image for FLUX.2 Flex",
                  "value": {
                    "prompt": "Turn the subject in the reference image into a hand-painted clay sculpture while preserving the pose, colors, and composition.",
                    "input_image": "https://your-image-host/reference-one.jpg",
                    "width": 1280,
                    "height": 768,
                    "output_format": "png"
                  }
                },
                "Two reference images (FLUX.2 Pro)": {
                  "summary": "Replace both example URLs with public reference images for FLUX.2 Pro",
                  "value": {
                    "prompt": "Create a magazine-style scene that preserves the subject from reference one and places the object from reference two beside it, no text.",
                    "input_image": "https://your-image-host/reference-one.jpg",
                    "input_image_2": "https://your-image-host/reference-two.jpg",
                    "width": 1280,
                    "height": 768,
                    "output_format": "png"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "FLUX task submission response. Save the top-level `id` and poll the CometAPI result endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Task ID to pass to `GET /flux/v1/get_result?id=...`."
                    },
                    "status": {
                      "type": "string",
                      "description": "Submission state. An accepted task can return `processing`."
                    },
                    "result": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "description": "Task result. It can be empty or null at submission time."
                    },
                    "polling_url": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Response-supplied convenience URL when returned. Clients should poll the documented CometAPI result route by the top-level `id`."
                    },
                    "cost": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Numeric billing coefficient when returned. This field is not documented as a currency or credit amount."
                    },
                    "input_mp": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Input image megapixels when returned."
                    },
                    "output_mp": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Output image megapixels when returned."
                    },
                    "progress": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Task progress when returned."
                    },
                    "details": {
                      "description": "Additional task details when returned."
                    },
                    "preview": {
                      "description": "Task preview data when returned."
                    }
                  }
                },
                "example": {
                  "id": "<task_id>",
                  "status": "processing",
                  "result": {},
                  "polling_url": "https://api.cometapi.com/flux/v1/get_result?id=<task_id>",
                  "cost": 3,
                  "output_mp": 0.9375
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Text to image (FLUX.2 Pro)",
            "source": "curl https://api.cometapi.com/flux/v1/flux-2-pro \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n    \"seed\": 424242,\n    \"width\": 1280,\n    \"height\": 768,\n    \"output_format\": \"png\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Text to image (FLUX.2 Pro)",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/flux/v1/flux-2-pro\",\n    headers={\n        \"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"],\n        \"Content-Type\": \"application/json\",\n    },\n    json={\n            \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n            \"seed\": 424242,\n            \"width\": 1280,\n            \"height\": 768,\n            \"output_format\": \"png\"\n        },\n    timeout=60,\n)\nresponse.raise_for_status()\nprint(response.json()[\"id\"])\n"
          },
          {
            "lang": "JavaScript",
            "label": "Text to image (FLUX.2 Pro)",
            "source": "const response = await fetch(\n  \"https://api.cometapi.com/flux/v1/flux-2-pro\",\n  {\n    method: \"POST\",\n    headers: {\n      Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    signal: AbortSignal.timeout(60_000),\n    body: JSON.stringify({\n      \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n      \"seed\": 424242,\n      \"width\": 1280,\n      \"height\": 768,\n      \"output_format\": \"png\"\n    }),\n  },\n);\n\nif (!response.ok) throw new Error(await response.text());\nconst task = await response.json();\nconsole.log(task.id);\n"
          },
          {
            "lang": "Shell",
            "label": "Text to image (FLUX.2 Flex)",
            "source": "curl https://api.cometapi.com/flux/v1/flux-2-flex \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n    \"width\": 1280,\n    \"height\": 768,\n    \"output_format\": \"png\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Text to image (FLUX.2 Flex)",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/flux/v1/flux-2-flex\",\n    headers={\n        \"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"],\n        \"Content-Type\": \"application/json\",\n    },\n    json={\n            \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n            \"width\": 1280,\n            \"height\": 768,\n            \"output_format\": \"png\"\n        },\n    timeout=60,\n)\nresponse.raise_for_status()\nprint(response.json()[\"id\"])\n"
          },
          {
            "lang": "JavaScript",
            "label": "Text to image (FLUX.2 Flex)",
            "source": "const response = await fetch(\n  \"https://api.cometapi.com/flux/v1/flux-2-flex\",\n  {\n    method: \"POST\",\n    headers: {\n      Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    signal: AbortSignal.timeout(60_000),\n    body: JSON.stringify({\n      \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n      \"width\": 1280,\n      \"height\": 768,\n      \"output_format\": \"png\"\n    }),\n  },\n);\n\nif (!response.ok) throw new Error(await response.text());\nconst task = await response.json();\nconsole.log(task.id);\n"
          },
          {
            "lang": "Shell",
            "label": "Text to image (FLUX.2 Max)",
            "source": "curl https://api.cometapi.com/flux/v1/flux-2-max \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n    \"width\": 1280,\n    \"height\": 768,\n    \"output_format\": \"png\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Text to image (FLUX.2 Max)",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/flux/v1/flux-2-max\",\n    headers={\n        \"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"],\n        \"Content-Type\": \"application/json\",\n    },\n    json={\n            \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n            \"width\": 1280,\n            \"height\": 768,\n            \"output_format\": \"png\"\n        },\n    timeout=60,\n)\nresponse.raise_for_status()\nprint(response.json()[\"id\"])\n"
          },
          {
            "lang": "JavaScript",
            "label": "Text to image (FLUX.2 Max)",
            "source": "const response = await fetch(\n  \"https://api.cometapi.com/flux/v1/flux-2-max\",\n  {\n    method: \"POST\",\n    headers: {\n      Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    signal: AbortSignal.timeout(60_000),\n    body: JSON.stringify({\n      \"prompt\": \"A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.\",\n      \"width\": 1280,\n      \"height\": 768,\n      \"output_format\": \"png\"\n    }),\n  },\n);\n\nif (!response.ok) throw new Error(await response.text());\nconst task = await response.json();\nconsole.log(task.id);\n"
          },
          {
            "lang": "Shell",
            "label": "Reference image edit (FLUX.2 Flex)",
            "source": "curl https://api.cometapi.com/flux/v1/flux-2-flex \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"prompt\": \"Turn the subject in the reference image into a hand-painted clay sculpture while preserving the pose, colors, and composition.\",\n    \"input_image\": \"https://your-image-host/reference-one.jpg\",\n    \"width\": 1280,\n    \"height\": 768,\n    \"output_format\": \"png\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Reference image edit (FLUX.2 Flex)",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/flux/v1/flux-2-flex\",\n    headers={\n        \"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"],\n        \"Content-Type\": \"application/json\",\n    },\n    json={\n            \"prompt\": \"Turn the subject in the reference image into a hand-painted clay sculpture while preserving the pose, colors, and composition.\",\n            \"input_image\": \"https://your-image-host/reference-one.jpg\",\n            \"width\": 1280,\n            \"height\": 768,\n            \"output_format\": \"png\"\n        },\n    timeout=60,\n)\nresponse.raise_for_status()\nprint(response.json()[\"id\"])\n"
          },
          {
            "lang": "JavaScript",
            "label": "Reference image edit (FLUX.2 Flex)",
            "source": "const response = await fetch(\n  \"https://api.cometapi.com/flux/v1/flux-2-flex\",\n  {\n    method: \"POST\",\n    headers: {\n      Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    signal: AbortSignal.timeout(60_000),\n    body: JSON.stringify({\n      \"prompt\": \"Turn the subject in the reference image into a hand-painted clay sculpture while preserving the pose, colors, and composition.\",\n      \"input_image\": \"https://your-image-host/reference-one.jpg\",\n      \"width\": 1280,\n      \"height\": 768,\n      \"output_format\": \"png\"\n    }),\n  },\n);\n\nif (!response.ok) throw new Error(await response.text());\nconst task = await response.json();\nconsole.log(task.id);\n"
          },
          {
            "lang": "Shell",
            "label": "Two reference images (FLUX.2 Pro)",
            "source": "curl https://api.cometapi.com/flux/v1/flux-2-pro \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"prompt\": \"Create a magazine-style scene that preserves the subject from reference one and places the object from reference two beside it, no text.\",\n    \"input_image\": \"https://your-image-host/reference-one.jpg\",\n    \"input_image_2\": \"https://your-image-host/reference-two.jpg\",\n    \"width\": 1280,\n    \"height\": 768,\n    \"output_format\": \"png\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Two reference images (FLUX.2 Pro)",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/flux/v1/flux-2-pro\",\n    headers={\n        \"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"],\n        \"Content-Type\": \"application/json\",\n    },\n    json={\n            \"prompt\": \"Create a magazine-style scene that preserves the subject from reference one and places the object from reference two beside it, no text.\",\n            \"input_image\": \"https://your-image-host/reference-one.jpg\",\n            \"input_image_2\": \"https://your-image-host/reference-two.jpg\",\n            \"width\": 1280,\n            \"height\": 768,\n            \"output_format\": \"png\"\n        },\n    timeout=60,\n)\nresponse.raise_for_status()\nprint(response.json()[\"id\"])\n"
          },
          {
            "lang": "JavaScript",
            "label": "Two reference images (FLUX.2 Pro)",
            "source": "const response = await fetch(\n  \"https://api.cometapi.com/flux/v1/flux-2-pro\",\n  {\n    method: \"POST\",\n    headers: {\n      Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    signal: AbortSignal.timeout(60_000),\n    body: JSON.stringify({\n      \"prompt\": \"Create a magazine-style scene that preserves the subject from reference one and places the object from reference two beside it, no text.\",\n      \"input_image\": \"https://your-image-host/reference-one.jpg\",\n      \"input_image_2\": \"https://your-image-host/reference-two.jpg\",\n      \"width\": 1280,\n      \"height\": 768,\n      \"output_format\": \"png\"\n    }),\n  },\n);\n\nif (!response.ok) throw new Error(await response.text());\nconst task = await response.json();\nconsole.log(task.id);\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
