Generate Stunning Images with the hssangha575/ziki-jinder Cognitive Actions

23 Apr 2025
Generate Stunning Images with the hssangha575/ziki-jinder Cognitive Actions

In the world of artificial intelligence, image generation has taken a front seat, enabling developers to create stunning visuals from mere text prompts. The hssangha575/ziki-jinder Cognitive Actions provide a robust API that allows you to generate images using advanced models with various customization options. By leveraging these pre-built actions, developers can save time and resources while integrating powerful capabilities into their applications.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Familiarity with making HTTP requests and handling JSON data.

Authentication typically works by passing your API key in the headers of your requests, ensuring secure access to the services.

Cognitive Actions Overview

Generate Image with LoRA

The Generate Image with LoRA action is designed to create images based on text prompts. It supports features like inpainting, setting image dimensions, and optimizing quality through specific models. This action is categorized under image-generation.

Input

The input for this action is structured as follows:

  • prompt (required): A string that describes the image you want to generate.
  • mask (optional): A URI string for an image mask used in inpainting mode.
  • seed (optional): An integer for setting a random seed, allowing reproducible generation.
  • image (optional): A URI string for an input image, applicable in image-to-image or inpainting modes.
  • model (optional): Specifies the model to use for inference, such as "dev" or "schnell".
  • width (optional): Width of the generated image (256 to 1440).
  • height (optional): Height of the generated image (256 to 1440).
  • goFast (optional): A boolean to enable faster predictions.
  • imageAspectRatio (optional): Defines the aspect ratio of the generated image.
  • numberOfOutputs (optional): Number of images to generate (1 to 4).
  • imageOutputFormat (optional): The format of the output image (e.g., webp, jpg, png).
  • imageOutputQuality (optional): Quality of the output image (0 to 100).
  • Additional fields allow for further customization, including LoRA weights and scales.

Here is an example of a JSON payload you would send:

{
  "model": "dev",
  "goFast": false,
  "prompt": "jssangha, an adult man, with more hair, looking at the camera, wearing a high quality buttoned shirt, shooting pool in a high end building",
  "mainLoraScale": 1,
  "imageMegapixels": "1",
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8,
  "diffusionGuidanceScale": 3,
  "numberOfInferenceSteps": 28
}

Output

Upon successful execution of the action, you will receive a response containing the URL(s) of the generated image(s). Here’s an example of what the output may look like:

[
  "https://assets.cognitiveactions.com/invocations/5710d889-21bf-497c-b8aa-e295477c5a11/1df17781-ebb6-4669-abcb-43592a81cd73.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Cognitive Actions endpoint for generating an image:

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 = "7305db79-9597-4e3b-b695-bb7401ff1578"  # Action ID for Generate Image with LoRA

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "jssangha, an adult man, with more hair, looking at the camera, wearing a high quality buttoned shirt, shooting pool in a high end building",
    "mainLoraScale": 1,
    "imageMegapixels": "1",
    "numberOfOutputs": 1,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "imageOutputQuality": 80,
    "additionalLoraScale": 1,
    "imagePromptStrength": 0.8,
    "diffusionGuidanceScale": 3,
    "numberOfInferenceSteps": 28
}

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, you will need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and the input payload are structured to align with the requirements of the Generate Image with LoRA action.

Conclusion

The hssangha575/ziki-jinder Cognitive Actions provide an efficient way to generate images from text prompts with various customization options. By utilizing the Generate Image with LoRA action, developers can create highly tailored visuals that enhance user experiences. Explore the potential of these actions in your applications, and consider integrating them to bring your creative ideas to life!