Site icon Midjourney API

How to create images with Midjourney API

In this post, we will discuss how to create images using the Midjourney API. Firstly, you need to sign up for an account at www.omnibridge.io. The free account allows you to create images in economy mode, but these images will have a watermark. To upscale images, or perform other enhancements like zooming in/out or obtaining different image variations, you will need a paid account.

You can create images using the Omnibridge playground in your browser, or you can use your favorite programming language. Sample codes for Javascript and Python, as well as Curl commands, can be found in the Midjourney API documentation and the Omnibridge playground, which is accessible after logging into your account.

In the Midjourney API documentation, it is explained that to create images, the first step is to use the “imagine” API to describe the image you want to create. For instance, you can use the following curl command to create images of a blue sky:

curl -X POST 'https://prod.omnibridge.io/imagine' \
-H 'Authorization: Bearer API_SECRET' \
-d '{"prompt": "Blue Sky", "formats": "PNG"}' 

Replace ‘API_SECRET’ with the API Secret you receive after signing up with Omnibridge.
This command will return a ‘jobId’ needed to retrieve the image and/or perform other actions on it.

The ‘imagine’ API creates a single image composed of four sub-images. The top left image is #1, the top right is #2, the bottom left is #3, and the bottom right is #4. You need to know the index number of the image if you want to perform any enhancement operations on these images.

For example, if you want a higher quality image for the bottom left image (i.e., #3), you can use the ‘enhance’ command like this:

curl -X POST 'https://prod.omnibridge.io/enhance' \
-H 'Authorization: Bearer API_SECRET' \
-d '{"command": "U3", "jobId": "JOB_ID", "formats": "PNG"}'

Be sure to replace ‘API_SECRET’ with your API secret and ‘JOB_ID’ with the jobId received from the ‘imagine’ API.

This API will also return a ‘jobId’ (different from the one received from the ‘imagine’ API). To get the URL of the images from a ‘jobId’, you can perform the following action:

curl -X GET 'https://prod.omnibridge.io/job?jobId=JOB_ID' \
-H 'Authorization: Bearer API_SECRET'

And, as always, replace ‘API_SECRET’ with your API secret and ‘JOB_ID’ with the ‘jobId’ for which you want the images. This API will either return the URL of the produced images or the status of the job if it is not completed yet.

Exit mobile version