{
  "openapi": "3.1.0",
  "info": {
    "title": "Generate Image API",
    "version": "1.0.0",
    "description": "Generate Bria text-to-image outputs through CometAPI. This route returns final image URLs directly."
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  },
  "paths": {
    "/bria/text-to-image": {
      "post": {
        "summary": "Generate Bria images",
        "operationId": "generate_image",
        "description": "Create one or more Bria images from a text prompt. For the most predictable first request, keep num_results at 1 and use a square aspect ratio.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "type": "string",
                    "description": "English text prompt for image generation.",
                    "example": "A paper boat floating on calm water at sunrise."
                  },
                  "num_results": {
                    "type": "integer",
                    "description": "Number of images to generate. Use 1 for the simplest integration test.",
                    "default": 1
                  },
                  "aspect_ratio": {
                    "type": "string",
                    "description": "Requested output aspect ratio.",
                    "enum": [
                      "1:1",
                      "2:3",
                      "3:2",
                      "3:4",
                      "4:3",
                      "4:5",
                      "5:4",
                      "9:16",
                      "16:9"
                    ],
                    "default": "1:1"
                  },
                  "seed": {
                    "type": "integer",
                    "description": "Optional seed for reproducible results."
                  },
                  "negative_prompt": {
                    "type": "string",
                    "description": "Optional exclusions for the generated image."
                  },
                  "steps_num": {
                    "type": "integer",
                    "description": "Optional refinement step count.",
                    "default": 30
                  },
                  "text_guidance_scale": {
                    "type": "integer",
                    "description": "Optional prompt adherence setting.",
                    "default": 5
                  },
                  "medium": {
                    "type": "string",
                    "description": "Optional visual medium.",
                    "enum": [
                      "photography",
                      "art"
                    ]
                  },
                  "prompt_enhancement": {
                    "type": "boolean",
                    "description": "Optional prompt enhancement switch.",
                    "default": false
                  },
                  "enhance_image": {
                    "type": "boolean",
                    "description": "Optional image detail enhancement switch.",
                    "default": false
                  },
                  "prompt_content_moderation": {
                    "type": "boolean",
                    "description": "Optional moderation switch.",
                    "default": false
                  },
                  "ip_signal": {
                    "type": "boolean",
                    "description": "Optional IP warning flag.",
                    "default": false
                  },
                  "sync": {
                    "type": "boolean",
                    "description": "Optional sync hint. CometAPI returns final results immediately without setting this field.",
                    "default": false
                  }
                },
                "default": {
                  "prompt": "A paper boat floating on calm water at sunrise.",
                  "num_results": 1,
                  "aspect_ratio": "1:1"
                }
              },
              "examples": {
                "Validated request": {
                  "summary": "Validated request",
                  "value": {
                    "prompt": "A paper boat floating on calm water at sunrise.",
                    "num_results": 1,
                    "aspect_ratio": "1:1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Image generation result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "urls",
                          "seed",
                          "uuid"
                        ],
                        "properties": {
                          "urls": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "seed": {
                            "type": "integer"
                          },
                          "uuid": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "example": {
                    "result": [
                      {
                        "urls": [
                          "https://example.com/generated.png"
                        ],
                        "seed": 278741175,
                        "uuid": "27c39b06-1dfe-11f1-ad57-6ac2c454c04d_278741175"
                      }
                    ]
                  }
                },
                "example": {
                  "result": [
                    {
                      "urls": [
                        "https://temp.bria.ai/api/generate_image/A_paper_boat_..._seed_934469972.png"
                      ],
                      "seed": 934469972,
                      "uuid": "<uuid>"
                    }
                  ]
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/bria/text-to-image \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n      \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n      \"num_results\": 1,\n      \"aspect_ratio\": \"1:1\"\n    }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/bria/text-to-image\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n            \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n            \"num_results\": 1,\n            \"aspect_ratio\": \"1:1\"\n    },\n)\n\nprint(response.json())  # the route responds synchronously with result[].urls\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "const response = await fetch(\"https://api.cometapi.com/bria/text-to-image\", {\n    method: \"POST\",\n    headers: {\n        Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n        \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n            \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n            \"num_results\": 1,\n            \"aspect_ratio\": \"1:1\"\n        }),\n});\n\nconsole.log(await response.json()); // the route responds synchronously with result[].urls\n"
          }
        ]
      }
    }
  }
}