# Welcome

Welcome to All-Images Integration Platform!

This documentation provides all the information needed to start using the **All-Images API**.


# Overview

Leverage the power of All-Images's API to create powerful integrations with your favorite tools and services.

The All-Images API allows you to download and generate images.

This section describes how to use the All-Images API and its resources. If you have any questions or issues, please contact the [All-Images Support](mailto:allimages.ai@gmail.Com).

### API Endpoint

The All-Images API can be accessed using the `api.all-images.ai` hostname:

```markup
curl https://api.all-images.ai/v1/
```


# Authentication

The All-Images API uses Personal access tokens to authenticate requests.

You can view and manage your access tokens in the [API Keys](https://app.all-images.ai/en/api-keys) page of your All-Images user account.

To authenticate a request, provide the token in the `api-key` header of the request:

```markup
curl -H "api-key: <your_access_token>" https://api.all-images.ai/v1/api-keys/check
```

Access tokens are tied to the All-Images user account for which they were created. **A token provides the same level of access & privileges that its associated All-Images user account would have.**

{% hint style="warning" %}
Please be sure to keep your API access tokens secure! Do not share them in emails, chat messages, client-side code or publicly accessible sites.

If you have accidentally shared an API access token publicly, you can revoke it in the [API Keys](https://app.all-images.ai/api-keys) page of your All-Images user account by clicking the "Remove" button beside the token.
{% endhint %}


# Errors

All-Images uses conventional HTTP response codes to indicate the success or failure of an API request.

As a general rule:

* Codes in the **`2xx`** range indicate success.
* Codes in the **`4xx`** range indicate incorrect or incomplete parameters (e.g. a required parameter was omitted, or an operation failed with a 3rd party, etc.).
* Codes in the **`5xx`** range indicate an error with All-Images's servers.

All-Images also outputs an error message and an error code formatted in JSON:

<pre class="language-json"><code class="lang-json">{
<strong>    "statusCode": number,
</strong>    "error": string,
    "message": string[]
}
</code></pre>


# Pagination

Some methods have `limit` and `offset` params in request body. You can create pagination system with them.&#x20;

In response, these methods return a `filteredResults` property corresponding to the total number of elements available and an array of the page's elements.

```json
{
  "filteredResults": 479,
  "images": [
    {
      "id": "65921cb1-111d-4cca-a554-809b61f842b4",
      "url": "http://api.all-images.ai/v1/images/preview/65921cb1-111d-4cca-a554-809b61f842b4.jpg",
    },
    ...
  ]
}
```


# API Reference

Here you can find a list of the different endpoints available to use across the All-Images API. Click into each card to learn more.


# Images

### Search Image

Search for images using keywords.

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/images/search" method="post" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Download Image (return binary file)

You need to have enough credits. Credits are debited only once.

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/images/download" method="post" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Buy Image (return direct URL)

Same like Download Image, but return direct public link for image. \
You need to have enough credits. Credits are debited only once.

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/images/buy" method="post" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Display Image

Each image has a display/download URL. Possible formats: "preview" or "full".

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/images/{format}/{imageId}.jpg" method="get" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Get Download Images

List images you've downloaded.

{% openapi src="/files/8g66AbFfYtQDgYVP66du" path="/v1/images/downladed" method="post" %}
[doc-json.json](https://3000441458-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5eow6Q376HF7RKVY4hLt%2Fuploads%2FgTY9xuwEsG7bC9gkD1Xy%2Fdoc-json.json?alt=media\&token=48275e15-df91-4981-9bea-7f54124ca3b7)
{% endopenapi %}


# Images generation

### Create Image generation

Image generation is used to obtain a proposal of 4 images based on a description and various parameters.

{% hint style="info" %}
See details of the steps involved in image generation : <https://developer.all-images.ai/integration-guide/image-generation>
{% endhint %}

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/image-generations" method="post" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Update Image Generation

An image generation can only be updated if it is not in "Pending" or "In Progress" status. You can only specify the values to be modified in the request.

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/image-generations/{printId}" method="put" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Retry Image Generation

If a generation is in error, it can be restarted (after modifying the description, for example).

{% openapi src="/files/8g66AbFfYtQDgYVP66du" path="/v1/image-generations/retry/{printId}" method="post" %}
[doc-json.json](https://3000441458-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5eow6Q376HF7RKVY4hLt%2Fuploads%2FgTY9xuwEsG7bC9gkD1Xy%2Fdoc-json.json?alt=media\&token=48275e15-df91-4981-9bea-7f54124ca3b7)
{% endopenapi %}

### Find Image Generations

Retrieves a list of all image generations.

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/image-generations" method="get" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Get Image Generation

Retrieves an image generation from its ID.

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/image-generations/{imageGenerationId}" method="get" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Delete Image Generation(s)

Delete one or more image generations.

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/image-generations" method="delete" expanded="true" fullWidth="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}


# API Keys

### Check API Key&#x20;

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/api-keys/check" method="get" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Create Endpoint Webhook

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/api-keys/webhook/subscribe" method="post" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Remove Webhook

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/api-keys/webhook/unsubscribe/{apiWebhookId}" method="delete" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Get Webhook

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/api-keys/webhook/{apiKeyWebhookId}" method="get" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}


# API Keys Webhook

### Subscribe

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/api-keys/webhook/subscribe" method="post" expanded="true" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}

### Unsubscribe

{% openapi src="<https://api.all-images.ai/doc-json>" path="/v1/api-keys/webhook/unsubscribe/{apiWebhookId}" method="delete" %}
<https://api.all-images.ai/doc-json>
{% endopenapi %}


# Image generation

With All-Images, you can generate images by AI from a description. Numerous parameters are available to customize generation. Each generation generates 4 images.

### Steps

* [Create Image Generate](/integration-guide/image-generation/create-image-generation)
* Wait for generation to finish using [webhooks](/integration-guide/webhooks/image-generation)
* [Download Image](/all-images.ai-api/api-reference/images#buy-image) and [Display Image](/all-images.ai-api/api-reference/images#display-image)


# Create Image generation

If you want to generate images, you need to [create a generation](/all-images.ai-api/api-reference/images-generation#create-image-generation).&#x20;

Two generation modes are available: simple and advanced mode.&#x20;

### Simple mode

Generate images with a simple description that we can optimize for you with `optimizePrompt` property. Optional options are also available.

```json
{
    "name": "Image generation in Simple mode",
    "prompt": "a dog playing in a park",
    "mode": "simple",
    "optimizePrompt"?: true | false,
    "params"?: [{ name: "param1", value: "value1" }, { name: "param2", value: "value2" }, ...],
    "tags"?: ["tag1", "tag2"],
    "metaData"?: { "name": "value" }
}
```

{% hint style="warning" %}
**The prompt must not contain a Midjourney parameter, only a text description. Use the various parameters or the "**[**advanced mode**](#advanced-mode)**"**
{% endhint %}

With the `optimizePrompt` parameter, the description will be optimised for generation. \
Example : "a dog" --> "A small brown dog sits on freshly fallen leaves looking into the distance, shot from a low angle."

In simple mode, you can add `params` to customize generation:&#x20;

* **Photo type** : "High quality realistic photo (realisticQuality, default)" or "Realistic photo taken on a smartphone (realisticManuel)".\
  `{ name: "templatePrompt", value: "realisticQuality" | "realisticManuel" }`
* **Format**: select image resolution.\
  `{ name: "format", value: "1:1" | "3:2" | "2:3" | "4:7" | "7:4" | "5:4" | "4:5" | "16:9" | "9:16" }`
* **Weather**: choose the weather for your image.\
  `{ name: "weather", value: "sunny" | "cloudy" | "foggy" | "rainy" | "thunderstorm" | "snowy" }`
* **Time**: this will change the image colors according to the time of day.\
  `{ name: "Time", value: "sunrise" | "morning" | "afternoon" | "sunset" | "evening" | "golden hour" | "night" | "midnight" }`
* **Camera**: enter a specific camera. Ex: GoPro or Cannon.\
  `{ name: "camera", value: "camera name" }`
* **Chaos**: value between 0 and 100 - This parameter influences how varied the initial image grids are. High chaos values will produce more unusual and unexpected results and compositions. Lower chaos values have more reliable, repeatable results.\
  `{ name: "chaos", value: 0-100 }`
* **Stylize**: value between 0 and 100 - Low stylization values produce images that closely match the prompt but are less artistic. High stylization values create images that are very artistic but less connected to the prompt.\
  `{ name: "stylize", value: 0-1000 }`
* **Interdiction**: separating what you don't want in the image (word, hands, human, ...) with a comma.\
  `{ name: "interdiction", value: "value1, value2, ..." }`

### Advanced mode

Our images are generated using Midjourney AI. In this mode, you just enter your ["Imagine" prompt](https://docs.midjourney.com/docs/image-prompts) as if you were on Discord.

```json
{
    "name": "Image generation in Advanced mode",
    "prompt": "a dog playing in a park --aspect 3:2",
    "mode": "advanced",
    "tags"?: ["tag1", "tag2"],
    "metaData"?: { "name": "value" }
}
```

***

{% hint style="info" %}
**User with "Dedicated" offer**\
The "processMode" parameter lets you choose the image generation mode: fast or relax. Remember to check your fast generation quota.
{% endhint %}

```
{
    "name": "Image generation",
    "processMode": "fast" | "relax"
}
```


# Lifecycle of Image generation

Image generation follows a life cycle defined by its status:&#x20;

<table><thead><tr><th width="156">Status</th><th width="224" align="center">Status value</th><th>Description</th></tr></thead><tbody><tr><td>Create</td><td align="center"><code>0</code></td><td>The generation has been created and will automatically change to the next status "Pending"</td></tr><tr><td>Pending</td><td align="center"><code>1</code></td><td>The generation has been taken into account and is awaiting processing.</td></tr><tr><td>Processing</td><td align="center"><code>2</code></td><td>The generation is being processed</td></tr><tr><td>Done</td><td align="center"><code>3</code></td><td>Generation is complete, and images are available.</td></tr><tr><td>Error</td><td align="center"><code>4</code></td><td>An error occurred during generation. This may be due to the image description not being accepted. You can <a href="/pages/ob9zO9XiAxdOav5njrnn#update-image-generation">modify the generation</a> and <a href="/pages/ob9zO9XiAxdOav5njrnn#retry-image-generation">try again</a>.</td></tr></tbody></table>

Status is indicated in the ImageGeneration object.


# Webhooks

### Register and manage your webhook endpoint![](https://b.stripecdn.com/docs-statics-srv/assets/fcc3a1c24df6fcffface6110ca4963de.svg)

#### User's account

From the user's account, in the "API Key" area, it is possible to create endpoints for webhooks.

{% embed url="<https://youtu.be/POhz_TAJSHU>" %}

#### API endpoint

With the API, you can [add an endpoint](/all-images.ai-api/api-reference/api-keys-webhook#subscribe) for your API key.

### Generic data in webhook

All webhooks are structured by generic properties:

<pre class="language-json"><code class="lang-json">{
<strong>   "id": string,
</strong>   "api_version": number,
   "created": number,
<strong>   "type": string,
</strong>   "data": object,
}
</code></pre>


# Image generation

For image generation, webhook is sent for the following status changes: `create`,`active`, `completed`, `failed`

The webhook contains [generic data](/integration-guide/webhooks#generic-data-in-webhook) and the[ Image generation object](/all-images.ai-api/api-reference/images-generation#get-image-generation). The `type`property depends on the status change :&#x20;

```json
{
   "id": string,
   "api_version": number,
   "created": number,
   "type": string,
   "data": { // Image Generation
      "id": "string",
      "name": "string",
      "prompt": "string",
      "status": 0,
      "params": [
        {
          "name": "sujetMode",
          "value": "string"
        }
      ],
      "images": [
        {
          "id": "string",
          "url": "string",
          "validate": true,
          "free": true,
          "titles": {}
        }
      ],
      "nbImages": 0,
      "tags": [
        "string"
      ],
      "metaData": {},
      "createdAt": "2023-10-30T14:10:34.002Z"
    }
}
```

| New status                    | Value of "Type" property |
| ----------------------------- | ------------------------ |
| `create`                      | print.created            |
| `active`                      | print.active             |
| *when one im*age is generated | print.progress           |
| `failed`                      | print.failed             |
| `completed`                   | print.completed          |


# API

### 23/02/2024 - New endpoint "Buy Image"'

You can now purchase an image and retrieve the direct public link instead of the binary (with Download Image).


