# Expand Image The  can be used to expand an image, by utilizing generative AI. You can decide on the image size of the final result as well as the position and size of the original image compared to the final result. Alternatively, you can define a desired aspect_ratio, and the service will automatically place the input image in the center and expand the canvas to match that ratio. In this way, you can create unique variations of your original image instead of cropping it into different aspect ratios and losing important details. If aspect_ratio is not provided, both original_image_size and original_image_location must be specified. * Ensure that the ratio of the input image foreground or main subject to the canvas area is greater than 15% to achieve optimal results. * The canvas size should be up to an area of 5000x5000 pixels. * This parameter is optional. If not provided or left empty, the service will automatically generate a prompt based on the input image. - If the input image includes an alpha channel and , newly generated pixels inherit the alpha values of the nearest original pixels along the same row or column, ensuring smooth transparency transitions. - If the input image contains fully transparent pixels along any edge (top, bottom, left, or right), the request is rejected with a 422 error. Expansion is not supported in such cases to avoid undefined transparency behavior. Here are some examples: : : : : This endpoint includes granular content moderation controls to ensure safe usage across all stages of processing: - – Validates the provided prompt and rejects requests containing unsafe or prohibited terms before processing starts. - – Scans the uploaded image and stops processing if inappropriate or restricted content is detected. - – Evaluates the generated image and blocks the response if it violates safety guidelines. Endpoint: POST /expand ## Header parameters: - `api_token` (string, required) ## Request fields (application/json): - `image` (string, required) The source image to be handled by the API. Supported input types: - - pointing to an image file that is publicly accessible and available at the time of processing. Accepted formats: , , , . - `aspect_ratio` (string,number) Automatically expands or crops the input image to the specified aspect ratio. Either or the combination of and must be provided. When provided, , , and are ignored. Centers the input image, expanding edges to reach the target ratio. Accepts either: - A predefined string: "1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9" - A custom float between 0.5 and 3.0 If the target ratio equals the input image’s current ratio, no changes are made. If the computed final dimensions exceed 5000×5000 px in total area, the input image is automatically resized so the area stays within limits. - `canvas_size` (array) Desired output canvas dimensions (width, height). Defaults to [1000, 1000] if not provided. Ignored when is used. Maximum allowed area is 25M pixels (i.e., width × height ≤ 5,000 × 5,000). Exceeding this returns a 400 error. - `original_image_size` (array) The desired size of the original image inside the final canvas, as in pixels. Ensure that the visible part of the input image (foreground or main subject) occupies more than 15% of the total canvas area for optimal results. This field is required when is not provided. Must be used together with . - `original_image_location` (array) The position of the top-left corner of the original image within the final canvas, provided as in pixels. This defines where the input image will be placed before expansion occurs. The values can be outside the canvas bounds—if so, the image will be cropped accordingly. Required when is not provided. Must be used together with . - `prompt` (string) Optional text prompt to guide the image expansion. If not provided or left empty, a prompt will be automatically generated as part of the service based on the input image. Currently, Bria supports prompts in English only and does not support special characters. - `prompt_content_moderation` (boolean) When enabled (default: ), the input prompt is moderated before processing. - The prompt is scanned for NSFW content and terms that violate Bria’s ethical guidelines. - If the prompt fails moderation, the request is blocked and the API responds with a 422 error. - `seed` (integer) You can choose whether you want your generated expension to be random or predictable. You can recreate the same result in the future by using the seed value of a result from the response. You can exclude this parameter if you are not interested in recreating your results. This parameter is optional. - `negative_prompt` (string) This parameter is optional. Currently, Bria supports prompts in English only and does not support special characters. - `preserve_alpha` (boolean) Controls whether the alpha channel values from the input image are retained in the output, if the input includes an alpha channel. - When true: The output image maintains the original transparency of fully and partially transparent pixels. - When false: The output image is fully opaque. - Has no effect if the input image does not include an alpha channel. - `sync` (boolean) Specifies the response mode. - When (default), the request is processed asynchronously: the API immediately returns a status URL to track progress. - When , the request is processed synchronously: the API hold the connection open until the proccess is complete and then returns the final image URL in the response. - `visual_input_content_moderation` (boolean) When enabled, applies content moderation to input visual. Expected behavior: - Processing stops if the image fails moderation. - Returns a 422 error with details about which parameter failed. - `visual_output_content_moderation` (boolean) When enabled, applies content moderation to result visual. Expected behavior: - If the modified image fails moderation, returns a 422 error. ## Response 200 fields (application/json): - `result` (object, required) - `result.image_url` (string, required) - `result.seed` (integer) - `result.prompt` (string) Original prompt sent by the user. - `request_id` (string, required) ## Response 202 fields (application/json): - `request_id` (string, required) - `status_url` (string, required) ## Response 400 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 401 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 403 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 404 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 415 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 422 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 429 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 460 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 5XX fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required)