> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to Image Generation

> Generate high-quality images from text descriptions using Stable Diffusion and other AI models

Create stunning images from text prompts using state-of-the-art diffusion models including Stable Diffusion XL, Stable Diffusion 1.5, and custom fine-tuned models.

## Request Body

**prompt** `string` *required*

Detailed description of the image you want to generate. Be specific about style, composition, lighting, and details.

**model** `string` (default: stable-diffusion-xl)

Model to use for image generation:

* `stable-diffusion-xl` - Latest high-resolution model (1024x1024)
* `stable-diffusion-1.5` - Classic model (512x512)
* `kandinsky-2.2` - Russian text-to-image model
* Custom LoRA models available

**negativePrompt** `string`

What you don't want in the image (e.g., "blurry, low quality, distorted")

**width** `integer` (default: 1024)

Image width in pixels. Must be multiple of 64. Max 2048.

**height** `integer` (default: 1024)

Image height in pixels. Must be multiple of 64. Max 2048.

**steps** `integer` (default: 20)

Number of denoising steps. More steps = higher quality but slower generation (1-50)

**guidanceScale** `number` (default: 7.5)

How closely to follow the prompt (1-20). Higher values stick closer to prompt.

**seed** `integer`

Random seed for reproducible results. Leave empty for random generation.

**samples** `integer` (default: 1)

Number of images to generate (1-4 per request)

## Response

**images** `array`

Array of generated images

**Image Object**

**url** `string`

Publicly accessible URL to the generated image (expires in 24 hours)

**base64** `string`

Base64-encoded image data (only if requested)

**seed** `integer`

The seed used for this specific image

**metadata** `object`

Generation metadata

**Metadata Object**

**model** `string`

Model used for generation

**steps** `integer`

Number of steps used

**guidanceScale** `number`

Guidance scale used

**generationTime** `number`

Time taken in seconds

## Example

```bash cURL
curl -X POST "https://api.tensorone.ai/v2/ai/text-to-image" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A majestic golden dragon soaring through cloudy mountain peaks at sunset, fantasy art style, highly detailed, 8k resolution",
    "negativePrompt": "blurry, low quality, distorted, deformed",
    "model": "stable-diffusion-xl",
    "width": 1024,
    "height": 1024,
    "steps": 30,
    "guidanceScale": 8.0,
    "samples": 2
  }'
```

```python Python
import requests
import base64
from PIL import Image
from io import BytesIO

response = requests.post(
    "https://api.tensorone.ai/v2/ai/text-to-image",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "A serene Japanese garden with cherry blossoms, koi pond, traditional architecture",
        "model": "stable-diffusion-xl",
        "width": 1024,
        "height": 768,
        "steps": 25
    }
)

data = response.json()
for i, image in enumerate(data['images']):
    # Download and save image
    img_response = requests.get(image['url'])
    with open(f'generated_image_{i}.png', 'wb') as f:
        f.write(img_response.content)
```

```javascript JavaScript
const response = await fetch('https://api.tensorone.ai/v2/ai/text-to-image', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    prompt: 'A cyberpunk cityscape at night with neon lights and flying cars',
    model: 'stable-diffusion-xl',
    width: 1024,
    height: 1024,
    steps: 20,
    samples: 1
  })
});

const data = await response.json();
console.log('Generated image URL:', data.images[0].url);
```

```json Response
{
  "images": [
    {
      "url": "https://cdn.tensorone.ai/generated/img_abc123_0.png",
      "seed": 1234567890
    },
    {
      "url": "https://cdn.tensorone.ai/generated/img_abc123_1.png", 
      "seed": 1234567891
    }
  ],
  "metadata": {
    "model": "stable-diffusion-xl",
    "steps": 30,
    "guidanceScale": 8.0,
    "generationTime": 12.5
  }
}
```

## Style Prompts

Enhance your results with style-specific prompts:

### Photography

```
"portrait photo of [subject], professional lighting, shallow depth of field, bokeh background, shot with Canon 5D Mark IV"
```

### Digital Art

```
"[subject], digital painting, artstation trending, highly detailed, fantasy art, concept art, matte painting"
```

### Anime/Manga

```
"[subject], anime style, studio ghibli, makoto shinkai, cel shading, vibrant colors"
```

### Realistic

```
"photorealistic [subject], 8k uhd, film grain, shot with professional camera, natural lighting"
```

## Custom Models

Upload and use your own fine-tuned models or LoRA adapters:

```python
# Using a custom LoRA model
response = requests.post(
    "https://api.tensorone.ai/v2/ai/text-to-image",
    json={
        "prompt": "a portrait in the style of Van Gogh",
        "model": "stable-diffusion-xl",
        "lora": "your-van-gogh-lora-id",
        "loraWeight": 0.8
    }
)
```

## Best Practices

* **Be specific**: Detailed prompts yield better results
* **Use negative prompts**: Exclude unwanted elements explicitly
* **Optimal settings**: Start with 20-30 steps, guidance scale 7-10
* **Aspect ratios**: Common ratios work best (1:1, 16:9, 3:4, etc.)
* **Quality keywords**: Include "high quality", "detailed", "8k" for better results
* **Style consistency**: Reference specific artists, art movements, or techniques

## Pricing

* **Standard Generation**: \$0.02 per image (512x512 or 1024x1024)
* **High Resolution**: \$0.05 per image (above 1024x1024)
* **Bulk Generation**: Volume discounts available for 100+ images


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.