# API Reference

### Image Generation

Creates an image given a prompt.

<pre><code><strong>POST https://api.blockentropy.ai/v1/images/generations
</strong></code></pre>

### Request body

***

**prompt**  <mark style="color:blue;">string</mark>  <mark style="color:red;">Required</mark>

A text description of the desired image. The maximum length is - characters.

***

**model**  <mark style="color:blue;">string  Optional  Defaults to SD-XL 1.0-base</mark>

The model to use for image generation.

***

**n**  <mark style="color:blue;">integer</mark>&#x20;

The value used to seed the model generator.

***

**quality** <mark style="color:blue;">string  Optional  Defaults to smooth</mark>

The quality of the image that will be generated.

***

**response\_format**  <mark style="color:blue;">string or null  Optional  Defaults to url</mark>

The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.

**size**  <mark style="color:blue;">string or null  Optional  Defaults to 1024x1024</mark>

The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.

### Returns

Returns a list of image objects.

{% code title="Example request" lineNumbers="true" fullWidth="false" %}

```python
from openai import OpenAI

be_api_key= "BE_API_KEY"
base_url='https://api.blockentropy.ai/v1'
model="be-stable-diffusion-xl-base-1.0"

client = OpenAI(
    base_url=base_url,
    api_key=be_api_key
)

client.images.generate(
  model=model,
  prompt="A cute baby sea otter",
  n=1,
  size="1024x1024"
)
```

{% endcode %}

{% code title="Response" lineNumbers="true" fullWidth="false" %}

```json
{
  "created": 1589478378,
  "data": [
    {
      "url": "https://..."
    }
  ]
}
```

{% endcode %}

### Image Editing

Creates an edited version of an image given an original image and a prompt.

<pre><code><strong>POST https://api.blockentropy.ai/v1/images/edits
</strong></code></pre>

### Request body

***

**image**  <mark style="color:blue;">file</mark>  <mark style="color:red;">Required</mark>

The image file to edit or use as a reference for pose estimation. Must be valid PNG file.

***

**prompt**  <mark style="color:blue;">string</mark>  <mark style="color:red;">Required</mark>

A text description of the desired image. The maximum length is - characters.

***

**model**  <mark style="color:blue;">string  Optional  Defaults to SD-XL 1.0-base</mark>

The model to use for image generation.

***

**n**  <mark style="color:blue;">integer</mark>&#x20;

The value used to seed the model generator.

***

**quality** <mark style="color:blue;">string  Optional  Defaults to smooth</mark>

The quality of the image that will be generated.

***

**response\_format**  <mark style="color:blue;">string or null  Optional  Defaults to url</mark>

The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.

**size** <mark style="color:blue;">string or null  Optional  Defaults to 1024x1024</mark>

The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.

**user** <mark style="color:blue;">string  Optional</mark>

An optional parameter must be set to `cn` when the user wants to use the endpoint for pose estimation.

### Returns

***

Returns a list of image objects.

{% code title="Example Request" lineNumbers="true" fullWidth="false" %}

```python
from openai import OpenAI

be_api_key= "BE_API_KEY"
base_url='https://api.blockentropy.ai/v1'
model="be-stable-diffusion-xl-base-1.0"

client = OpenAI(
    base_url=base_url,
    api_key=be_api_key
)

client.images.edit(
  image=open("otter.png", "rb"),
  prompt="A cute baby sea otter wearing a beret",
  n=2,
  size="1024x1024"
)
```

{% endcode %}

{% code title="Response" lineNumbers="true" fullWidth="false" %}

```json
{
  "created": 1589478378,
  "data": [
    {
      "url": "https://..."
    }
  ]
}

```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blockentropy.ai/generation/image-generation/api-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
