# Generations

## Generating new image

## Generate new images

<mark style="color:green;">`POST`</mark> `https://api.crazyhorse.ai/v1/generations`

Generate new images by your purpose.

#### Headers

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| api-key<mark style="color:red;">\*</mark> | String | api key     |

#### Request Body

| Name                                     | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| params<mark style="color:red;">\*</mark> | object | <p><strong>These params</strong></p><p>  <code>hair</code>: string,</p><p>  <code>pose</code>: string,</p><p>  <code>body</code>: string,</p><p>  <code>chest</code>: string,</p><p>  <code>clothes</code>: string,</p><p>  <code>background</code>: string,</p><p>  <code>number</code>: number,</p><p>  <code>girlId</code>: string,</p><p>  <code>loraId</code>: string (<a href="https://civitai.com/">model</a>),</p><p>  <code>debug</code>: boolean,</p> |
| image<mark style="color:red;">\*</mark>  | string | base64                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

{% tabs %}
{% tab title="200 Image successfully created" %}

```javascript
{
  "state": "WAITING",
  "code": "string",
  "imageUrls": [
    "string"
  ],
  "params": {
    "hair": "string",
    "pose": "string",
    "body": "string",
    "chest": "string",
    "clothes": "string",
    "background": "string",
    "number": 10,
    "loraId": "string",
    "debug": true
  }
}
```

{% endtab %}

{% tab title="403: Forbidden Error" %}

```javascript
{
  "message": "API key does not exist",
  "errorCode": 5001,
  "statusCode": 403,
  "path": "/v1/generations",
  "error": true,
  "method": "POST"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Node" %}

```
/ require the myapi module and set it up with your API key
const axios = require('axios').default;

const url = 'https://api.crazyhorse.ai/v1/generations';
const payload = {
    params: {
     "hair": "red",
     "pose": "",
     "body": "",
     "chest": "",
     "clothes": "t-shirt, jean",
     "background": "ocean",
     "number": 10,
     "girlId": "yuna-jp",
     "loraId": "115728",
     "debug": true
    },
    image: '/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxISEhUTEBIVFRUVFRUVFRUVFRUVFRYVFxcXFxUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGhAQGy0dHx0tLS0tLS0tLSstLS0tLS0tLSstKy0xLS0tKy0rLS0tLS0tKy0rKy0tLS0tLS0tLS0tLf/AABEIARMAtwMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAEAQIDBQYABwj/xAA/EAABAwIDBQUFBQgBBQEAAAABAAIRAyEEBTESQVFxgQYTImGRMqGxwdEHQlJichQjgpKy4fDxwhUzU5OiJP/EABkBAAMBAQEAAAAAAAAAAAAAAAABAgMEBf/EACERAQEAAgMAAgIDAAAAAAAAAAABAhEDITESQTJRBHHB/9oADAMBAAIRAxEAPwDSU/Y6KJgUwHg6KNgWSxdIWRYCHpDRFDR'
};
const options = {
   headers: {
     'api-key': 'xxxxxxxx'
   }
};
const genImage = away axios.post(url, payload, options)
```

{% endtab %}
{% endtabs %}

## Get Result

## Get result for generate

<mark style="color:blue;">`GET`</mark> `https://api.crazyhorse.ai/v1/generations`

Using `code` value to get result

#### Path Parameters

| Name                                   | Type   | Description                      |
| -------------------------------------- | ------ | -------------------------------- |
| code<mark style="color:red;">\*</mark> | String | 89e78b15d29165008cbfd61ba3bb679f |

#### Headers

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| api-key<mark style="color:red;">\*</mark> | String | api key     |

{% tabs %}
{% tab title="200 successfully" %}

```javascript
{
  "state": "DONE",
  "code": "89e78b15d29165008cbfd61ba3bb679f",
  "image": "ced3e3051c203193952d8b51fe5c9d82/89e78b15d29165008cbfd61ba3bb679f.png",
  "generateImageUrls": [
    "ced3e3051c203193952d8b51fe5c9d82/89e78b15d29165008cbfd61ba3bb679f/generate-1.png"
  ],
  "params": {
    "hair": "red",
    "clothes": "t-shirt, jean",
    "number": 1
  },
  "createdAt": "2023-10-09T11:11:07.174Z"
}
```

{% endtab %}

{% tab title="403: Forbidden Error" %}

```javascript
{
  "message": "API key does not exist",
  "errorCode": 5001,
  "statusCode": 403,
  "path": "/v1/generations",
  "error": true,
  "method": "GET"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=" Node" %}

```
/ require the myapi module and set it up with your API key
const axios = require('axios').default;

const url = 'https://api.crazyhorse.ai/v1/generations';
const options = {
   headers: {
     'api-key': 'xxxxxxxx'
   }
};
const getResult = away axios.get(url, options)
```

{% endtab %}
{% endtabs %}
