Generate Stunning Images with Adirik's RealVisXL V4.0 Cognitive Actions

24 Apr 2025
Generate Stunning Images with Adirik's RealVisXL V4.0 Cognitive Actions

In today's digital landscape, the ability to create photorealistic images on demand can significantly enhance applications across various domains, from marketing to entertainment. The Adirik RealVisXL V4.0 offers a powerful set of Cognitive Actions to generate stunning images based on detailed prompts. By leveraging this API, developers can automate image creation processes, refine existing images, and customize outputs to meet specific needs. Let’s explore how to integrate these capabilities into your applications.

Prerequisites

Before you start using the RealVisXL V4.0 Cognitive Actions, make sure you have the following:

  • An API key for the Cognitive Actions platform. This key will authorize your requests.
  • Basic knowledge of JSON and how to make HTTP requests.

For authentication, you'll typically pass your API key in the headers of your requests.

Cognitive Actions Overview

Generate Photorealistic Image with RealVisXL V4.0

The Generate Photorealistic Image with RealVisXL V4.0 action is designed to create high-quality images based on detailed text prompts. This action provides various options to control the image generation process, including inpainting capabilities, refinement styles, and output dimensions.

Input

The input for this action requires a JSON object with the following fields:

  • prompt (string): The text prompt guiding the image generation.
    • Example: "An astronaut riding a rainbow unicorn"
  • width (integer): The width of the output image in pixels.
    • Default: 768
  • height (integer): The height of the output image in pixels.
    • Default: 768
  • refineStyle (string): The refinement style to use when generating images.
    • Default: "no_refiner"
  • useWatermark (boolean): Option to apply a watermark to generated images.
    • Default: false
  • guidanceScaler (number): Intensity of classifier-free guidance (1 to 50).
    • Default: 4
  • promptIntensity (number): Strength of the prompt during generation (0 to 1).
    • Default: 0.8
  • outputImageCount (integer): Number of images to generate (1 to 4).
    • Default: 1
  • prohibitedPrompt (string): Negative prompt elements to avoid.
    • Default: "(worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth"
  • highNoiseFraction (number): Fraction of noise applied in refinement mode (0 to 1).
    • Default: 0.8
  • inferenceStepCount (integer): Steps for image denoising (1 to 500).
    • Default: 25
  • processingScheduler (string): Scheduler for processing (e.g., "DPM++_SDE_Karras").
    • Default: "DPM++_SDE_Karras"
  • seed (integer): Random seed for generating images (optional).
  • image (string): URI of the input image for img2img or inpaint mode (optional).
  • mask (string): URI of the input mask for inpaint mode (optional).
  • refinementStepCount (integer): Sets the number of refinement steps (optional).

Here’s an example of the input JSON payload:

{
  "width": 768,
  "height": 768,
  "prompt": "An astronaut riding a rainbow unicorn",
  "refineStyle": "no_refiner",
  "useWatermark": false,
  "guidanceScaler": 4,
  "promptIntensity": 0.8,
  "outputImageCount": 1,
  "prohibitedPrompt": "(worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
  "highNoiseFraction": 0.8,
  "inferenceStepCount": 25,
  "processingScheduler": "DPM++_SDE_Karras"
}

Output

The action typically returns a JSON array containing URLs of the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/85c6c925-7bd8-42e9-9cf1-6969c39d3b9c/01209437-6df0-41bc-bc6c-a436104453dd.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call this action:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "e6a67088-1f27-4c80-88a6-314e8e579aef"  # Action ID for Generate Photorealistic Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 768,
    "height": 768,
    "prompt": "An astronaut riding a rainbow unicorn",
    "refineStyle": "no_refiner",
    "useWatermark": False,
    "guidanceScaler": 4,
    "promptIntensity": 0.8,
    "outputImageCount": 1,
    "prohibitedPrompt": "(worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
    "highNoiseFraction": 0.8,
    "inferenceStepCount": 25,
    "processingScheduler": "DPM++_SDE_Karras"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}  # Hypothetical structure
    )
    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the "Generate Photorealistic Image" action. The input payload is structured according to the action’s requirements.

Conclusion

The Adirik RealVisXL V4.0 Cognitive Actions open up a world of possibilities for developers looking to incorporate advanced image generation capabilities into their applications. By understanding how to leverage these actions, you can create unique and engaging visual content tailored to your needs. Consider experimenting with different prompts, styles, and settings to explore the full potential of this powerful tool. Happy coding!