# Stable Diffusion XL API

### Create high-quality AI images through our API.

Lowest price on the market - 100 images for just $0.50

Stable Diffusion XL (SDXL) is a state-of-the-art image generation model that can generate high-quality images from text prompts in just a few seconds. With a few lines of code, our easy-to-use API enables you to generate realistic photos, illustrations, paintings, and more. See below for examples of what you can create with our SDXL API.

### API Usage

To use our text-to-image API send a `POST` request to `https://api.lemonfox.ai/v1/images/generations`. If you haven't already, you will need to [create an API key](/content/apis/keys/index.html) to authenticate your requests.

#### Example Code

```javascript
fetch('https://api.lemonfox.ai/v1/images/generations', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    prompt: "photo of a cat"
  })
})
.then(response => response.json())
.then(data => {
  console.log(data[0].url);
})
.catch(error => {
  console.error('Error:', error);
});
```

### API Response

Image URLs remain accessible for a 12-hour window, after which they will be removed from our servers.

#### Response Example

```
{
  "created": 1698265325,
  "data": [
    {
      "url": "https://output.lemonfox.ai/images/f3a45520-1da4-4126-b924-22ab3818f91b.png"
    }
  ]
}
```

### API Parameters

The API `POST https://api.lemonfox.ai/v1/images/generations` takes the following parameters:

- **prompt**  
  string, required  
  A description of the desired image(s).

- **negative_prompt**  
  string, optional  
  A description of what you don't want to see in the generated images.

- **n**  
  integer, optional, default: 1  
  The number of images that will be generated. Must be between 1 and 8.

- **response_format**  
  url / b64_json, optional, default: url  
  The format in which the generated images are returned. Must be one of `url` or `b64_json`.

- **size**  
  string, optional, default: 1024x1024  
  The size of the generated images (width x height). The maximum width and height is 1024px.

### SDXL Prompt Examples

**photo of a cat**

**A haunting gothic horror scene of an abandoned mansion on a hill, with fog, full moon, and shadowy figures, in a digital painting style reminiscent of the Castlevania game series.**

**A tranquil Zen garden with cherry blossom trees, a small bridge, and a pond at sunset. Japanese drawing.**

**b&w photography, model shot, man in subway station, beautiful detailed eyes, professional award winning portrait photography, Zeiss 150mm f/2.8**

**Comic of couple walking away into the sunset**

**cute rabbit wearing a jacket, with a carrot, 3D Style, rendering, close-up, bokeh background**

**interior design of living room, neutral colors, modern, windows with nyc skyline view at night**

**beautiful landscape photo of a snowy mountain**

**isometric style farmhouse from RPG game, unreal engine, vibrant, beautiful, crisp, detailed, ultra detailed, intricate**
