---
updatedAt: 2026-08-06T10:00:42.000Z
---

# Infer

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "contact": {
      "name": "NVIDIA Support",
      "url": "https://help.nvidia.com/"
    },
    "description": "The NVIDIA NIM REST API. Please see https://docs.api.nvidia.com/nim for more details.",
    "license": {
      "name": "FLUX.1 [dev] Non-Commercial License",
      "url": "https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev/blob/main/LICENSE.md"
    },
    "termsOfService": "https://nvidia.com/legal/terms-of-use",
    "title": "NVIDIA NIM API for black-forest-labs/flux.1-kontext-dev",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://ai.api.nvidia.com/v1/"
    }
  ],
  "paths": {
    "/genai/black-forest-labs/flux.1-kontext-dev": {
      "post": {
        "operationId": "_infer_infer_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": " Infer",
        "x-nvai-meta": {
          "examples": [
            {
              "name": "Example 1",
              "input": {
                "image": "https://assets.ngc.nvidia.com/products/api-catalog/flux_1-kontext-dev/input2.jpg",
                "text": "Now the mouse is holding pizza instead"
              },
              "output": {
                "image": "https://assets.ngc.nvidia.com/products/api-catalog/flux_1-kontext-dev/output1.jpg"
              },
              "requestJson": "{ \"prompt\": \"<%- input.text %>\", \"image\": \"data:image/png;example_id,0\", \"aspect_ratio\": \"match_input_image\", \"cfg_scale\": 3.5, \"steps\": 30, \"seed\": 0 }"
            },
            {
              "name": "Example 2",
              "input": {
                "image": "https://assets.ngc.nvidia.com/products/api-catalog/flux_1-kontext-dev/input1.jpg",
                "text": "Give him a cowboy hat"
              },
              "output": {
                "image": "https://assets.ngc.nvidia.com/products/api-catalog/flux_1-kontext-dev/output3.jpg"
              },
              "requestJson": "{ \"prompt\": \"<%- input.text %>\", \"image\": \"data:image/png;example_id,1\", \"aspect_ratio\": \"match_input_image\", \"cfg_scale\": 3.5, \"steps\": 30, \"seed\": 0 }"
            },
            {
              "name": "Example 3",
              "input": {
                "image": "https://assets.ngc.nvidia.com/products/api-catalog/flux_1-kontext-dev/input3.jpeg",
                "text": "Transform to Bauhaus style"
              },
              "output": {
                "image": "https://assets.ngc.nvidia.com/products/api-catalog/flux_1-kontext-dev/output2.jpg"
              },
              "requestJson": "{ \"prompt\": \"<%- input.text %>\", \"image\": \"data:image/png;example_id,2\", \"steps\": 30, \"aspect_ratio\": \"match_input_image\", \"cfg_scale\": 3.5, \"seed\": 0 }"
            }
          ],
          "name": "Generate a new image from a text prompt",
          "path": "infer",
          "returns": "Returns an Image artifact that consists from a generated image (JPEG) encoded in base64, finish reason and a seed used during the generation",
          "templates": [
            {
              "requestEjs": {
                "curl": "invoke_url='https://ai.api.nvidia.com/v1/genai/black-forest-labs/flux.1-kontext-dev'\n\nauthorization_header=\"Authorization: Bearer $NVIDIA_API_KEY\"\naccept_header='Accept: application/json'\ncontent_type_header='Content-Type: application/json'\n\ndata='{\n  \"prompt\": <%- JSON.stringify(request.prompt).replaceAll('\\'', '\\'\\\\\\'\\'') %>,\n  \"image\": \"<%- request.image %>\",\n  \"aspect_ratio\": <% if(request.ratio) { %> <%- JSON.stringify(request.ratio) %> <% } else { %> \"match_input_image\" <% } %>,\n  \"steps\": <% if(request.steps) { %> <%- request.steps %> <% } else { %> 30 <% } %>,\n  \"cfg_scale\": <% if(request.cfg_scale) { %> <%- request.cfg_scale %> <% } else { %> 3.5 <% } %>,\n  \"seed\": <% if(request.seed) { %> <%- request.seed %> <% } else { %> 0 <% } %>\n}'\n\nresponse=$(curl --silent -i -w \"\\n%{http_code}\" --request POST \\\n  --url \"$invoke_url\" \\\n  --header \"$authorization_header\" \\\n  --header \"$accept_header\" \\\n  --header \"$content_type_header\" \\\n  --data \"$data\"\n)\n\nhttp_code=$(echo \"$response\" | tail -n 1)\n\necho \"$response\" | awk '/{/,EOF-1'\n",
                "node.js": "import fetch from \"node-fetch\";\n\nconst invokeUrl = \"https://ai.api.nvidia.com/v1/genai/black-forest-labs/flux.1-kontext-dev\"\n\nconst headers = {\n    \"Authorization\": \"Bearer $NVIDIA_API_KEY\",\n    \"Accept\": \"application/json\",\n}\n\nconst payload = {\n  \"prompt\": <%- JSON.stringify(request.prompt).replaceAll('\\'', '\\'\\\\\\'\\'') %>,\n  \"image\": \"<%- request.image %>\",\n  \"aspect_ratio\": <% if(request.ratio) { %> <%- JSON.stringify(request.ratio) %> <% } else { %> \"match_input_image\" <% } %>,\n  \"steps\": <% if(request.steps) { %> <%- request.steps %> <% } else { %> 30 <% } %>,\n  \"cfg_scale\": <% if(request.cfg_scale) { %> <%- request.cfg_scale %> <% } else { %> 3.5 <% } %>,\n  \"seed\": <% if(request.seed) { %> <%- request.seed %> <% } else { %> 0 <% } %>\n}\n\nlet response = await fetch(invokeUrl, {\n    method: \"post\",\n    body: JSON.stringify(payload),\n    headers: { \"Content-Type\": \"application/json\", ...headers }\n});\n\nif (response.status != 200) {\n  let errBody = await (await response.blob()).text()\n  throw \"invocation failed with status \" + response.status + \" \" + errBody\n}\nlet response_body = await response.json()\nconsole.log(JSON.stringify(response_body))\n",
                "python": "import requests\n\ninvoke_url = \"https://ai.api.nvidia.com/v1/genai/black-forest-labs/flux.1-kontext-dev\"\n\nheaders = {\n    \"Authorization\": \"Bearer $NVIDIA_API_KEY\",\n    \"Accept\": \"application/json\",\n}\n\npayload = {\n    \"prompt\": <%- JSON.stringify(request.prompt).replaceAll('\\'', '\\'\\\\\\'\\'') %>,\n    \"image\": \"<%- request.image %>\",\n    \"aspect_ratio\": <% if(request.ratio) { %> <%- JSON.stringify(request.ratio) %> <% } else { %> \"match_input_image\" <% } %>,\n    \"steps\": <% if(request.steps) { %> <%- request.steps %> <% } else { %> 30 <% } %>,\n    \"cfg_scale\": <% if(request.cfg_scale) { %> <%- request.cfg_scale %> <% } else { %> 3.5 <% } %>,\n    \"seed\": <% if(request.seed) { %> <%- request.seed %> <% } else { %> 0 <% } %>\n}\n\nresponse = requests.post(invoke_url, headers=headers, json=payload)\n\nresponse.raise_for_status()\nresponse_body = response.json()\nprint(response_body)\n"
              },
              "response": "{\n    \"artifacts\": [\n        {\n            \"base64\":  \"...very long string...\",\n            \"finishReason\": \"SUCCESS\",\n            \"seed\": 1100106574\n        }\n    ]\n}\n",
              "title": "Example"
            }
          ]
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Artifact": {
        "properties": {
          "base64": {
            "description": "A base64-encoded string of the generated image (JPEG)",
            "examples": [
              "/9j/4AAQSkZ...b+AVZ/9k="
            ],
            "title": "Base64",
            "type": "string"
          },
          "finishReason": {
            "allOf": [
              {
                "$ref": "#/components/schemas/FinishReason"
              }
            ],
            "description": "The result of the generation process. `SUCCESS` indicates success. `ERROR` indicates an error. `CONTENT_FILTERED` indicates the result affected by the content filter"
          },
          "seed": {
            "description": "The seed used during generation",
            "title": "Seed",
            "type": "integer"
          }
        },
        "required": [
          "base64",
          "finishReason",
          "seed"
        ],
        "title": "Artifact",
        "type": "object"
      },
      "FinishReason": {
        "enum": [
          "CONTENT_FILTERED",
          "ERROR",
          "SUCCESS"
        ],
        "title": "FinishReason",
        "type": "string"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "title": "Detail",
            "type": "array"
          }
        },
        "title": "HTTPValidationError",
        "type": "object"
      },
      "ImageRequest": {
        "additionalProperties": false,
        "properties": {
          "prompt": {
            "description": "What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.",
            "maxLength": 10000,
            "title": "Prompt",
            "type": "string",
            "examples": [
              "Now the mouse is holding pizza instead"
            ]
          },
          "image": {
            "type": "null",
            "description": "An image input to edit. Preview API NIM supports only a predefined set of images. The image should be in form of `data:image/png;example_id,{example_id}` with example_id in a range [0,2]. ",
            "examples": [
              "data:image/png;example_id,0",
              "data:image/png;example_id,1",
              "data:image/png;example_id,2"
            ],
            "title": "Image"
          },
          "height": {
            "default": 1024,
            "description": "The image height in pixels. Supported heights=[1568, 1504, 1456, 1392, 1328, 1248, 1184, 1104, 1024, 944, 880, 832, 800, 752, 720, 688, 672].",
            "enum": [
              1568,
              1504,
              1456,
              1392,
              1328,
              1248,
              1184,
              1104,
              1024,
              944,
              880,
              832,
              800,
              752,
              720,
              688,
              672
            ],
            "title": "Height",
            "type": "integer"
          },
          "width": {
            "default": 1024,
            "description": "The image width in pixels. Supported widths=[672, 688, 720, 752, 800, 832, 880, 944, 1024, 1104, 1184, 1248, 1328, 1392, 1456, 1504, 1568].",
            "enum": [
              1568,
              1504,
              1456,
              1392,
              1328,
              1248,
              1184,
              1104,
              1024,
              944,
              880,
              832,
              800,
              752,
              720,
              688,
              672
            ],
            "title": "Width",
            "type": "integer"
          },
          "cfg_scale": {
            "default": 3.5,
            "description": "How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt).",
            "exclusiveMinimum": 1,
            "maximum": 9,
            "title": "Cfg Scale",
            "type": "number"
          },
          "aspect_ratio": {
            "enum": [
              "match_input_image",
              "9:21",
              "5:11",
              "1:2",
              "7:13",
              "3:5",
              "2:3",
              "3:4",
              "6:7",
              "1:1",
              "7:6",
              "4:3",
              "3:2",
              "5:3",
              "13:7",
              "2:1",
              "11:5",
              "21:9"
            ],
            "type": [
              "string"
            ],
            "default": "match_input_image",
            "description": "Aspect ratio of the image to generate.",
            "title": "Aspect ratio"
          },
          "samples": {
            "default": 1,
            "description": "Number of images to generate. Only samples=1 is supported",
            "maximum": 1,
            "minimum": 1,
            "title": "Samples",
            "type": "integer"
          },
          "seed": {
            "default": 0,
            "description": "The seed which governs generation. Changing the seed with other inputs fixed results in different outputs. (Use 0 for a random seed)",
            "exclusiveMaximum": 4294967296,
            "minimum": 0,
            "title": "Seed",
            "type": "integer"
          },
          "steps": {
            "default": 30,
            "description": "The number of diffusion steps applied to generate an output image.",
            "maximum": 50,
            "minimum": 20,
            "title": "Steps",
            "type": "integer"
          }
        },
        "required": [
          "prompt",
          "image"
        ],
        "title": "ImageRequest",
        "type": "object"
      },
      "ImageResponse": {
        "properties": {
          "artifacts": {
            "items": {
              "$ref": "#/components/schemas/Artifact"
            },
            "maxItems": 1,
            "minItems": 1,
            "title": "Artifacts",
            "type": "array"
          }
        },
        "required": [
          "artifacts"
        ],
        "title": "ImageResponse",
        "type": "object"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "title": "Location",
            "type": "array"
          },
          "msg": {
            "title": "Message",
            "type": "string"
          },
          "type": {
            "title": "Error Type",
            "type": "string"
          }
        },
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError",
        "type": "object"
      }
    },
    "securitySchemes": {
      "Token": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "security": [
    {
      "Token": []
    }
  ],
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```