# Uncrop/Outpaint Extend images beyond their original boundaries using AI outpainting. #### Request Body (multipart/form-data) **`provider`** string required Provider to use. Values: `openai`, `clipdrop`. **`organization_id`** string required Organization ID (org_ prefixed string). **`image_file`** file required Image file to extend (PNG, JPEG, WebP). **`extend_left`** integer optional · Defaults to `0` Pixels to extend left (Clipdrop only, max 2000). **`extend_right`** integer optional · Defaults to `0` Pixels to extend right (Clipdrop only, max 2000). **`extend_up`** integer optional · Defaults to `0` Pixels to extend up (Clipdrop only, max 2000). **`extend_down`** integer optional · Defaults to `0` Pixels to extend down (Clipdrop only, max 2000). **`seed`** integer optional Random seed for reproducible results (Clipdrop only). **`mask_file`** file conditional Mask file (PNG with alpha channel). Required for OpenAI. **`prompt`** string optional Description for outpainting (OpenAI only). **`size`** string optional Output size (OpenAI only). Values: `1024x1024`, `1024x1536`, `1536x1024`. ## Returns Returns raw image bytes (JPEG for Clipdrop, PNG for OpenAI) with provider metadata in response headers. ### Response Headers - `X-Provider` - Provider that processed the request - `X-Provider-Request-Id` - Provider's request ID - `X-Provider-Credits-Consumed` - Credits consumed (Clipdrop only) Clipdrop ```bash curl -X POST "https://api.aitronos.com/api/v1/images/uncrop" \ -H "X-API-Key: $FREDDY_API_KEY" \ -F "provider=clipdrop" \ -F "organization_id=org_123abc" \ -F "image_file=@photo.jpg" \ -F "extend_left=100" \ -F "extend_right=100" \ -F "extend_up=50" \ -F "extend_down=50" \ -F "seed=42" ``` ```python import os import requests api_key = os.environ["FREDDY_API_KEY"] url = "https://api.aitronos.com/api/v1/images/uncrop" files = {"image_file": open("photo.jpg", "rb")} data = { "provider": "clipdrop", "organization_id": "org_123abc", "extend_left": 100, "extend_right": 100, "extend_up": 50, "extend_down": 50, "seed": 42 } response = requests.post( url, headers={"X-API-Key": api_key}, files=files, data=data ) if response.status_code == 200: with open("extended.jpg", "wb") as f: f.write(response.content) ``` ```javascript const formData = new FormData(); formData.append("provider", "clipdrop"); formData.append("organization_id", "org_123abc"); formData.append("image_file", imageFile); formData.append("extend_left", "100"); formData.append("extend_right", "100"); formData.append("extend_up", "50"); formData.append("extend_down", "50"); formData.append("seed", "42"); const response = await fetch( "https://api.aitronos.com/api/v1/images/uncrop", { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_API_KEY}`, }, body: formData, } ); const blob = await response.blob(); ``` OpenAI ```bash curl -X POST "https://api.aitronos.com/api/v1/images/uncrop" \ -H "X-API-Key: $FREDDY_API_KEY" \ -F "provider=openai" \ -F "organization_id=org_123abc" \ -F "image_file=@photo.png" \ -F "mask_file=@border_mask.png" \ -F "prompt=Extend the landscape naturally" \ -F "size=1024x1024" ``` ```python import os import requests api_key = os.environ["FREDDY_API_KEY"] url = "https://api.aitronos.com/api/v1/images/uncrop" files = { "image_file": open("photo.png", "rb"), "mask_file": open("border_mask.png", "rb") } data = { "provider": "openai", "organization_id": "org_123abc", "prompt": "Extend the landscape naturally", "size": "1024x1024" } response = requests.post( url, headers={"X-API-Key": api_key}, files=files, data=data ) if response.status_code == 200: with open("extended.png", "wb") as f: f.write(response.content) ``` ```javascript const formData = new FormData(); formData.append("provider", "openai"); formData.append("organization_id", "org_123abc"); formData.append("image_file", imageFile); formData.append("mask_file", maskFile); formData.append("prompt", "Extend the landscape naturally"); formData.append("size", "1024x1024"); const response = await fetch( "https://api.aitronos.com/api/v1/images/uncrop", { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_API_KEY}`, }, body: formData, } ); const blob = await response.blob(); ``` ## Response ```text Content-Type: image/jpeg X-Provider: clipdrop X-Provider-Request-Id: req_abc123 X-Provider-Credits-Consumed: 1 [JPEG image bytes] ``` ```text Content-Type: image/png X-Provider: openai X-Provider-Request-Id: req_xyz789 [PNG image bytes] ``` ```json { "success": false, "error": { "code": "INVALID_EXTEND_PARAMETERS", "message": "Extend parameters exceed 2000px", "type": "client_error", "status": 422, "details": { "extend_left": 2500, "max_allowed": 2000 } } } ``` ```json { "success": false, "error": { "code": "MASK_REQUIRED", "message": "OpenAI requires mask for this operation", "type": "client_error", "status": 422 } } ```