Create Stunning Cyberpunk Images with the teaglis-kury/sana Cognitive Actions

24 Apr 2025
Create Stunning Cyberpunk Images with the teaglis-kury/sana Cognitive Actions

In this article, we’ll explore the capabilities of the teaglis-kury/sana API, specifically focusing on the powerful image generation action it offers. Using the Generate Cyberpunk Image action, developers can create visually stunning cyberpunk-themed images by simply providing prompts and customizing various parameters. This pre-built action saves time and effort, allowing you to integrate advanced image generation capabilities into your applications with ease.

Prerequisites

To get started with the Cognitive Actions, you'll need to acquire an API key from the Cognitive Actions platform. This key allows you to authenticate your requests. Typically, authentication is done by including the API key in the request headers. Once you have your key, you're ready to dive into the capabilities of the Generate Cyberpunk Image action.

Cognitive Actions Overview

Generate Cyberpunk Image

The Generate Cyberpunk Image action allows you to create a cyberpunk-themed image based on a prompt that describes the desired elements. You can also specify negative prompts to exclude unwanted aspects, while customizing image dimensions, guidance scales, and inference steps to tailor the output.

Input

The input for this action consists of several fields, both required and optional, as defined in the input_schema. Here's a breakdown:

  • seed (optional): An integer that serves as a random seed for reproducibility. If left blank, a random seed will be used.
  • width (optional): The width of the output image in pixels (default: 1024).
  • height (optional): The height of the output image in pixels (default: 1024).
  • prompt (required): A string describing the desired image content (e.g., "frog").
  • guidanceScale (optional): A scale factor from 1 to 20 that influences how closely the output adheres to the prompt (default: 5).
  • negativePrompt (optional): A string specifying undesirable elements to be excluded from the image.
  • pagGuidanceScale (optional): Similar to guidance scale, this factor ranges from 1 to 20 (default: 2).
  • numInferenceSteps (optional): The number of denoising steps to perform during image generation (default: 18).

Here’s an example JSON payload for the input:

{
  "seed": 42,
  "width": 512,
  "height": 512,
  "prompt": "frog",
  "guidanceScale": 5,
  "negativePrompt": "",
  "pagGuidanceScale": 2,
  "numInferenceSteps": 18
}

Output

Upon executing the action, a URL of the generated image is returned. The response typically includes a link to the image, such as:

https://assets.cognitiveactions.com/invocations/c0b9b155-c53c-41fe-94e6-7b09c66d18d9/cb67f06e-4a06-472e-b021-6f6a23c4a1f8.png

This URL can then be used to display the generated image in your application.

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet illustrating how you might call the Generate Cyberpunk Image 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 = "cfd902de-e3c3-4891-9096-4d5a3a5fd96c" # Action ID for Generate Cyberpunk Image

# Construct the input payload based on the action's requirements
payload = {
    "seed": 42,
    "width": 512,
    "height": 512,
    "prompt": "frog",
    "guidanceScale": 5,
    "negativePrompt": "",
    "pagGuidanceScale": 2,
    "numInferenceSteps": 18
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the action's input schema. The endpoint URL and request structure are illustrative, focusing on how to format the input data appropriately.

Conclusion

Integrating the Generate Cyberpunk Image action from the teaglis-kury/sana API into your applications allows you to create unique, visually appealing images with minimal effort. By leveraging the flexibility of prompts and customizable settings, developers can quickly generate images tailored to their specific needs. Consider exploring this action further to unlock creative possibilities in your projects!