> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modelslab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Base64 Image Crop

> Lets you Upload an image and crop it, by passing the appropriate request parameters to the endpoint.

<Note>
  Note that the maximum file size for upload is 5MB.
  and Make sure you are passing the image in **base64** format.
</Note>

## Request

Send a `POST` request to below endpoint.

```curl curl theme={null}
--request POST 'https://modelslab.com/api/v3/base64_crop' \
```

## Body

```json json theme={null}
{  
    "key": "your_api_key",  
    "image": "data:image/png;base64,your_base_64_string",  
    "crop": "true"
}
```


## OpenAPI

````yaml POST /base64_crop
openapi: 3.1.0
info:
  title: ModelsLab General API
  description: >-
    General utility endpoints for ModelsLab API including subscription
    management, content moderation, and file handling
  license:
    name: MIT
  version: 6.0.0
servers:
  - url: https://modelslab.com/api
    description: Main API server (for endpoints without version prefix)
  - url: https://modelslab.com/api/v3
    description: API v3 server
  - url: https://modelslab.com/api/v5
    description: API v5 server
  - url: https://modelslab.com/api/v6
    description: API v6 server
security: []
paths:
  /base64_crop:
    post:
      summary: Upload base64 image and crop
      description: >-
        Upload an image and crop it. Pass the appropriate request parameters to
        the endpoint. Note that the maximum file size for upload is 5MB
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Base64CropRequest'
      responses:
        '200':
          description: Base64 crop response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Base64CropResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      servers:
        - url: https://modelslab.com/api/v3
components:
  schemas:
    Base64CropRequest:
      type: object
      required:
        - key
        - image
        - crop
      properties:
        key:
          type: string
          description: Your API Key used for request authorization
        image:
          type: string
          description: Image to be uploaded converted in base64 format
        crop:
          type: string
          enum:
            - 'true'
            - 'false'
          default: 'true'
          description: A (true/false) flag for cropping the image upon uploading
    Base64CropResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
        messege:
          type: string
          example: image uploaded
        link:
          type: string
          format: uri
          description: URL of the uploaded image
        request_id:
          type: integer
          description: Request ID for the uploaded image
    Error:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: Error message

````