Generate Stunning Images with the skcrypto86/fefe-ai Cognitive Actions

24 Apr 2025
Generate Stunning Images with the skcrypto86/fefe-ai Cognitive Actions

The skcrypto86/fefe-ai API offers a powerful set of Cognitive Actions designed to help developers effortlessly generate images based on text prompts. With advanced options for image transformation, aspect ratio customization, and model selection, these pre-built actions provide a streamlined approach to incorporating image generation capabilities into your applications. This guide will walk you through the details of the available actions, their inputs and outputs, and how to use them effectively.

Prerequisites

To integrate the Cognitive Actions from the skcrypto86/fefe-ai API, you will need:

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

Authentication typically involves passing your API key in the request headers as a Bearer token.

Cognitive Actions Overview

Generate Image with Custom Parameters

The Generate Image with Custom Parameters action allows you to create images based on detailed text prompts. This action supports various advanced features including image-to-image transformations, customizable aspect ratios, and model selections tailored for speed or quality.

Input

The input schema requires the following fields:

  • prompt (required): A textual description guiding the image generation.
  • model (optional): Choose between "dev" (28 inference steps) and "schnell" (4 steps, faster).
  • megapixels (optional): Sets the approximate size of the generated image.
  • aspectRatio (optional): Specifies the image dimensions ratio; "custom" allows manual width and height.
  • width (optional): Specifies the image width in pixels (only for custom aspect ratio).
  • height (optional): Specifies the image height in pixels (only for custom aspect ratio).
  • denoiseSteps (optional): Number of denoising steps (default is 28).
  • guidanceScale (optional): Controls the influence of the prompt (default is 3).
  • enableFastMode (optional): Speed-optimized processing (default is false).
  • promptStrength (optional): Strength of the prompt's influence in image transformations (default is 0.8).
  • numberOfOutputs (optional): The number of images to generate (default is 1).
  • imageOutputFormat (optional): Formats for the output image (default is "webp").
  • imageOutputQuality (optional): Quality rating for the output image (default is 80).

Example Input:

{
  "model": "dev",
  "prompt": "FEFE at an outdoor café in the early evening, with the ambient light transitioning from day to night. The café's lights start to reflect off his face, which shows a blend of satisfaction and contemplation after a day's work. He's in business casual, sipping coffee, with his phone showing market updates, the setting sun in the background symbolizing the end of another day's hustle towards his goal",
  "megapixels": "1",
  "aspectRatio": "4:5",
  "denoiseSteps": 28,
  "guidanceScale": 3,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "primaryLoraScale": 1,
  "imageOutputFormat": "jpg",
  "imageOutputQuality": 80,
  "additionalLoraScale": 1
}

Output

The output of this action typically includes a URI link to the generated image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/100ec58e-ad33-468e-9d03-c3e8419b93a3/0320b806-add9-4db2-aa24-edccafad529a.jpg"
]

Conceptual Usage Example (Python)

Here’s how you can call the Generate Image with Custom Parameters 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" # Hypothetical endpoint

action_id = "da219a6e-2632-401f-b083-f80a92c97f51" # Action ID for Generate Image with Custom Parameters

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "FEFE at an outdoor café in the early evening, with the ambient light transitioning from day to night. The café's lights start to reflect off his face, which shows a blend of satisfaction and contemplation after a day's work. He's in business casual, sipping coffee, with his phone showing market updates, the setting sun in the background symbolizing the end of another day's hustle towards his goal",
    "megapixels": "1",
    "aspectRatio": "4:5",
    "denoiseSteps": 28,
    "guidanceScale": 3,
    "enableFastMode": False,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "primaryLoraScale": 1,
    "imageOutputFormat": "jpg",
    "imageOutputQuality": 80,
    "additionalLoraScale": 1
}

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 is set to the ID for the Generate Image with Custom Parameters action. The input payload is structured according to the schema requirements.

Conclusion

Integrating the skcrypto86/fefe-ai Cognitive Actions into your applications allows for dynamic and rich image generation capabilities. By leveraging the Generate Image with Custom Parameters action, developers can create stunning visuals based on detailed prompts, customize various parameters, and enhance the user experience. Start experimenting with these actions to unlock creative possibilities in your projects!