In this guide we will be walking you through how to enhance your first single bracket image, you will:
Learn how to register the fact you want to enhance an image with Autoenhance
Upload your image file to Autoenhance using the provided endpoint received after registering your image
Downloading the final enhanced image
This guide assumes you have already have an API key, if you don't have one please see our guide here.
1. Registering an image
So you have a single image you want to enhance using Autoenhance. Before we can upload anything we need to register our new image with Autoenhance, by passing a POST request to the /images endpoint.
During this process we provide the name and the MIME type for the image (i.e image/jpeg). This is also where we indicate other editing settings we want to be applied to the image when it's enhanced but we won't cover that in this guide.
As part of this request Autoenhance will make a new record for this image and create space for us to upload our image including a unique endpoint which will be returned in the s3PutObjectUrl field
constapiKey="YOUR_API_KEY";constblob= Blob // Blob or File of your imageconstcreateImage=async (apiKey, blob) => {constcreateImageResponse=awaitfetch("https://api.autoenhance.ai/v3/images/", { method:"POST", headers: {"Content-Type":"application/json","x-api-key": apiKey, }, body:JSON.stringify({ image_name:"your-image-name", contentType:blob.type, }), } );const { s3PutObjectUrl,order_id,image_id } =awaitcreateImageResponse.json();}
Important note
You will see an image_id and order_id in the response. You can specify both of them yourself in the body of the request, but they both have to be unique. We're using uuidv4 in order to create unique identifiers for both orders and images.
If you want to group multiple images into the same order, you must use the exact same order_id value for all of the created images. Learn more on the Orders page.
2. Uploading image
Now Autoenhance has registered our image and created a unique upload endpoint for us. We need to upload the file for the image we wish to be enhanced.
To do this we will perform a PUT request to the url contained provided at the s3PutObjectUrl field provided to us in Step 1, the body of this request should be the raw data of the file and the Content-Type header should match what we sent as the image_type for the registration i.e if it was image/jpeg then the header should also be image/jpeg
Once successfully uploaded, your image will start being processed with our AI. To check it's current status we can use a GET request to the /images/:image_id:/ using the image_id returned in the registration endpoint to get the current status.
Once the status field returned is "processed"we can download the image using the /images/:image_id:/enhanced endpoint.
If you only wish to allow your users to see a preview of the image before downloading without consuming any of your credits then you can use the /images/:image_id:/preview endpoint
Checking the image status
curl -X GET \
https://api.autoenhance.ai/v3/images/ID_OF_YOUR_IMAGE \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY'
Downloading the image
curl -X GET \
https://api.autoenhance.ai/v3/images/ID_OF_YOUR_IMAGE/enhanced \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY'
This example uses the least possible amount of properties in order to create an image. If you want to apply any kind of preferences to it, visit our Image Settings page to find out more about them. Once you are familiar with them, simply add them in the body of the POST request to our API.