How to use Obscurify Image Generation

First, make sure you have an account and sufficient funds. Prices are listed at Image Generation Models in USD per 1 million pixel steps.

Then, send a POST request to the following endpoint:

https://obscurify.ai/image_generation

The request body should be a JSON object with the following fields:

  • base: The base model to use. Options are stable-diffusion, stable-diffusion-xl, essential-v2.
  • model: The model to use. The available models are listed in the Image Generation Models section.
  • prompt: The prompt you want to generate an image for.
  • width: The width of the image to generate.
  • height: The height of the image to generate.

There are a few optional fields you can use, you can find more information about them in the Image Generation API Reference.

For example, in python:

import base64
import json
import os
import ssl
import requests

obscurify_api_key = "YOUR_OBSCURIFY_API_KEY"
def generate_image(base, model, prompt, width, height, **kwargs):
    url = f"https://obscurify.ai/image_generation"
    headers = {
        "accept": "application/json",
        "content-type": "application/json",
        "Authorization": f"Bearer {obscurify_api_key}",
    }
    data = {
        "base": base,
        "model": model,
        "prompt": prompt,
        "width": width,
        "height": height,
        **kwargs,
    }
    response = requests.post(url, headers=headers, json=data)
    response_data = response.json()
    image_data = response_data["image"]
    image_bytes = base64.b64decode(image_data)
    output_filename = f"image_{width}x{height}.png"
    with open(output_filename, "wb") as image_file:
        image_file.write(image_bytes)


generate_image(
    base="stable-diffusion-xl",
    model="reproduction-v3-31",
    prompt="sexy privacy supporter",
    width=512,
    height=512,
)