0PricingLogin
AI Prompt Engineering · Lesson

Negative Prompts and Exclusions

What to exclude: blurry, watermark, ugly, deformed — effective negative prompting.

What Are Negative Prompts?

Negative prompts tell an image model what not to include in the generated image. They are separate from the positive prompt and steer the generation away from unwanted artifacts, styles, and elements. Originally a Stable Diffusion feature, the concept has spread across image generation models.

Stable Diffusion Negative Prompt Syntax

In Stable Diffusion, negative prompts are passed as a separate parameter. The model treats them as anti-guidance: concepts in the negative prompt are actively pushed away during generation.

import requests

SD_API_URL = 'http://localhost:7860/sdapi/v1/txt2img'

def generate_sd_image(positive_prompt, negative_prompt, steps=30, cfg_scale=7):
    payload = {
        'prompt': positive_prompt,
        'negative_prompt': negative_prompt,
        'steps': steps,
        'cfg_scale': cfg_scale,  # 7-12 recommended
        'width': 512,
        'height': 512,
        'sampler_name': 'DPM++ 2M Karras'
    }
    response = requests.post(SD_API_URL, json=payload)
    return response.json()

# Example call with negative prompt
positive = (
    'portrait of a young woman, soft natural light, '
    'professional photography, sharp focus, elegant'
)
negative = (
    'blurry, watermark, text, logo, ugly, distorted, '
    'deformed, extra fingers, extra limbs, bad anatomy, '
    'low quality, low resolution, grainy, noisy, '
    'oversaturated, harsh shadows'
)

result = generate_sd_image(positive, negative)
print('Generated:', len(result.get('images', [])), 'images')

All lessons in this course

  1. Anatomy of an Image Generation Prompt
  2. Style and Artistic Medium Specification
  3. Negative Prompts and Exclusions
  4. Iterative Image Prompt Refinement
← Back to AI Prompt Engineering