Generate Stunning Images with the asiryan/babes-xl Cognitive Actions

23 Apr 2025
Generate Stunning Images with the asiryan/babes-xl Cognitive Actions

In the world of artificial intelligence, the ability to generate and manipulate images from textual descriptions is revolutionizing creativity. The asiryan/babes-xl API provides powerful Cognitive Actions that allow developers to leverage advanced image generation capabilities using the Babes XL Model. Whether you're looking to create images from scratch or modify existing ones, these pre-built actions simplify the process, enabling developers to focus on innovation rather than implementation details.

Prerequisites

Before you start integrating the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform. This key is essential for authenticating your requests.
  • Familiarity with sending HTTP requests and handling JSON data.

For authentication, you'll typically include your API key in the request headers, ensuring secure access to the actions.

Cognitive Actions Overview

Generate and Manipulate Images with Babes XL

The Generate and Manipulate Images with Babes XL action allows for versatile image generation and manipulation. It supports creating images from descriptive text prompts (Text2Img), modifying existing images (Img2Img), and performing inpainting processes to fill in missing areas of an image.

Category: Image Generation

Input

To invoke this action, you need to structure your input according to the following schema:

{
  "mask": "string (optional)",
  "seed": "integer (optional)",
  "image": "string (optional)",
  "width": 1024,
  "height": 1024,
  "prompt": "string",
  "strength": 0.8,
  "loraScale": 0.6,
  "scheduler": "string (default: K_EULER_ANCESTRAL)",
  "numOutputs": 1,
  "loraWeights": "string (optional)",
  "guidanceScale": 3.5,
  "negativePrompt": "string",
  "numInferenceSteps": 40
}

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "score_9, score_8_up, score_7_up, score_6_up, very beautiful girl on the beach, zoom view, portrait",
  "strength": 0.8,
  "loraScale": 0.6,
  "scheduler": "K_EULER_ANCESTRAL",
  "numOutputs": 1,
  "guidanceScale": 3.5,
  "negativePrompt": "score_6, score_5, score_4, bad quality, bad anatomy, worst quality, low quality, low resolutions, extra fingers, blur, blurry, ugly, wrongs proportions, watermark, image artifacts, lowres, jpeg artifacts, deformed, noisy image, poorly drawn face, ugly face, crossed eyes",
  "numInferenceSteps": 40
}

Output

Upon successful execution, the action typically returns a list of generated image URLs. An example output might look like this:

[
  "https://assets.cognitiveactions.com/invocations/830c82e2-4d27-44e4-bc11-9c573ff745e7/39903c44-c7a4-4105-ada7-2478bc892ae2.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call this action using Python:

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"

action_id = "234e9d89-4565-420f-b21b-9f0b60e1739f"  # Action ID for Generate and Manipulate Images with Babes XL

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "score_9, score_8_up, score_7_up, score_6_up, very beautiful girl on the beach, zoom view, portrait",
    "strength": 0.8,
    "loraScale": 0.6,
    "scheduler": "K_EULER_ANCESTRAL",
    "numOutputs": 1,
    "guidanceScale": 3.5,
    "negativePrompt": "score_6, score_5, score_4, bad quality, bad anatomy, worst quality, low quality, low resolutions, extra fingers, blur, blurry, ugly, wrongs proportions, watermark, image artifacts, lowres, jpeg artifacts, deformed, noisy image, poorly drawn face, ugly face, crossed eyes",
    "numInferenceSteps": 40
}

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}
    )
    response.raise_for_status()

    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, you replace the API key and set the action ID for the "Generate and Manipulate Images with Babes XL" action. The input payload is constructed following the schema provided, and the request is sent to the hypothetical Cognitive Actions execution endpoint.

Conclusion

The asiryan/babes-xl Cognitive Actions empower developers to create and manipulate images seamlessly, opening doors to endless creative possibilities. By leveraging the capabilities of the Babes XL Model, you can integrate advanced image generation features into your applications with ease. As you explore these actions further, consider various use cases such as art generation, content creation, and more. Happy coding!