Create Stunning Images Effortlessly with Pixray Genesis Cognitive Actions

23 Apr 2025
Create Stunning Images Effortlessly with Pixray Genesis Cognitive Actions

In this blog post, we will explore the powerful capabilities of the dribnet/pixray-genesis Cognitive Actions, specifically focusing on the Generate Image with Pixray Genesis action. This action leverages the Pixray Genesis model to produce high-quality images, offering options for both draft and production-ready outputs. By using this pre-built action, developers can easily integrate image generation into their applications, saving time and resources while ensuring top-notch results.

Prerequisites

Before you start integrating the Pixray Genesis Cognitive Actions into your application, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of JSON and how to make API requests.

Authentication typically involves including the API key in the request headers.

Cognitive Actions Overview

Generate Image with Pixray Genesis

The Generate Image with Pixray Genesis action allows developers to create high-quality images using the Pixray Genesis model. Whether you need initial drafts or production-ready images, this action provides the flexibility to customize your requests.

Input

The input for this action follows the CompositeRequest schema, which includes the following fields:

  • title (string, required): The title of the composite request used for categorization. Default is an empty string.
  • quality (string, optional): Specifies the quality level of the request. Acceptable values are "draft" for initial versions and "mintable" for final or production-ready versions. The default is "draft".
  • optionalSettings (string, optional): Any additional settings for the composite request. This can be left empty if not required.

Example Input:

{
  "title": "gradients",
  "quality": "draft",
  "optionalSettings": "\n"
}

Output

Upon successful execution, the action returns an array of URLs pointing to the generated images. Each URL corresponds to an image created based on the input parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/8f057c84-43a5-41b1-8679-86ee6ec0fbc3/e679543b-7a93-4c69-8281-0c71df0ad598.png",
  "https://assets.cognitiveactions.com/invocations/8f057c84-43a5-41b1-8679-86ee6ec0fbc3/875a4fce-f26d-4a02-913a-b45986f9700e.png",
  ...
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call the Generate Image with Pixray Genesis action using Python. This snippet demonstrates how to structure the input payload and make a request to a hypothetical Cognitive Actions execution endpoint.

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 = "171603eb-3ed4-48d0-af1d-dd3ef40dea3a" # Action ID for Generate Image with Pixray Genesis

# Construct the input payload based on the action's requirements
payload = {
    "title": "gradients",
    "quality": "draft",
    "optionalSettings": "\n"
}

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 snippet, you’ll need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and adjust the endpoint as necessary. The action ID and input payload structure will guide you in making the correct request.

Conclusion

The Generate Image with Pixray Genesis action offers an impressive array of capabilities for developers looking to integrate image generation into their applications. With the ability to customize quality levels and titles, this action simplifies the process of creating stunning visuals. Now that you have a clear understanding of how to implement this action, consider exploring additional use cases or experimenting with different input parameters to optimize your image generation tasks. Happy coding!