Quickstart

In this guide, we will demonstrate how you can effectively utilize GetImage.io to develop your exceptional applications. Furthermore, we will provide you with step-by-step instructions on how to begin utilizing one of our API clients and effortlessly make your initial API request.

Next, you'll learn:

  • How to obtain API key and setting up the environment
  • How to call the API to kick off a new image generation from text input
  • How to get the generated images

Setting up

Before using GetImage.io, you need to obtain an API key, which serves as the credential for accessing our API service. After signing up (opens in a new tab) for an account, you can find it under API Keys (opens in a new tab) page.

GetImage.io provide REST APIs for you to use. We use cURL, Javascript/Typescript and Python as examples here, but you can easily integrate it into your applications just like any other APIs in any programming language.

# cURL is most likely already installed on your machine 
curl --version 

Generate an image

Next, let's generate an image with the Midjourney model. You can see how to send a Post request to the Diffusions endpoint to kick off an imagegeneration. The response will contain the id of the image generation task.

curl -X POST https://api.getimage.io/v1/diffusions \
-H 'Authorization: Bearer {API_KEY}' \
-d '{"prompt": "Mountain village landscape, neo fauvist style", "model": "midjourney"}'

The response will look like this:

{
  "id": "636f02e3-2df1-11ee-91eb-ba334091ec99",
  "status": "NEW",
  "createdAt": "2023-01-01T00:00:00.000Z"
}

You probably noticed that there are no image results in the response. That's because the image generation task is time consuming and not finished yet.

The image generation task may take a few minutes to finish depending on the model and bandwidth of GPU resources.

The id is the unique identifier of the generation task. You can use it to query the status of the task and retrieve the result later.

Retrieve the result

There're two ways to retrieve the result of the image generation task. One is to query the status periodically (also known as long polling) and the other is to subscribe to the result via webhooks (coming soon).

In the guide, we will use the first method to retrieve the result.

You can query the result by sending a GET request to the Diffusions endpoint with the id of the image generation task from previous step. The response will contain status of the task and the image urls if finished.

curl https://api.getimage.io/v1/diffusions/{ID} \
-H 'Authorization: Bearer {API_KEY}' \

If the task is finished, the response will look like this:

{
  "id": "636f02e3-2df1-11ee-91eb-ba334091ec99",
  "status": "FINISHED",
  "createdAt": "2023-01-01T00:00:00.000Z",
  "finishedAt": "2023-01-01T00:01:18.239Z",
  "images": [
    "https://cdn.getimage.io/assets/636f02e3-2df1-11ee-91eb-ba334091ec99/52a4df51-7125-4d9c-9ed1-40fd3bf35706.jpg",
    "https://cdn.getimage.io/assets/636f02e3-2df1-11ee-91eb-ba334091ec99/9f7d3a9d-22ff-4676-9285-3cec905eec74.jpg",
  ]
}

What's next

Great, you have made your first request to the API. Here are a few links that might be handy as you venture further into the API: