Generate Stunning Images with the sundai-club/pc_valentino Cognitive Actions

21 Apr 2025
Generate Stunning Images with the sundai-club/pc_valentino Cognitive Actions

In the world of AI and machine learning, generating high-quality images from descriptive text prompts has become increasingly accessible. The sundai-club/pc_valentino API provides a powerful Cognitive Action: Generate Image with FLUX.1. This action leverages the optimized FLUX.1 model to create visually stunning images based on user-defined prompts while supporting advanced features like image inpainting and aspect ratio customization. By utilizing these pre-built actions, developers can seamlessly integrate image generation capabilities into their applications, enhancing user experiences with rich, dynamic visuals.

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 in your programming environment.

Authentication typically involves passing your API key in the request headers to authorize access to the Cognitive Actions.

Cognitive Actions Overview

Generate Image with FLUX.1

The Generate Image with FLUX.1 action is designed to create high-quality images based on a descriptive text prompt. It supports various customization options, including size, format, and advanced features like image inpainting.

Input

The input for this action is structured as a JSON object. Here's a breakdown of its schema:

  • Required Fields:
    • prompt (string): Descriptive text to generate an image. Example: "A photo of sks, sitting on a horse, with his face visible."
  • Optional Fields:
    • mask (string): URI for image inpainting mode.
    • seed (integer): Random seed for consistent image generation.
    • image (string): URI of input image for image-to-image mode.
    • model (string): Choose between "dev" and "schnell" models.
    • width (integer): Width of the generated image (256-1440).
    • height (integer): Height of the generated image (256-1440).
    • megapixels (string): Approximate megapixel count (e.g., "1").
    • aspectRatio (string): Aspect ratio of the generated image (e.g., "1:1").
    • ... (further options like outputFormat, numberOfOutputs, etc.)

Example Input:

{
  "model": "dev",
  "width": 1024,
  "height": 1024,
  "prompt": "A photo of sks, sitting on a horse, with his face visible.",
  "megapixels": "1",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "loraIntensity": 1,
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "guidanceIntensity": 7.5,
  "outputImageQuality": 80,
  "additionalLoraScale": 1,
  "inferenceStepsCount": 50,
  "enableFastGeneration": false
}

Output

The action typically returns a URL pointing to the generated image. The output format can vary based on the request parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/6bec9a4d-2b11-418c-bf5c-09cb18604856/6fa94147-39c5-4c78-a189-8a9cff8bf06e.webp"
]

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet demonstrating how to call the Generate Image with FLUX.1 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 = "85d40a64-7b72-4b4c-a3a6-fd9b2e314cb5" # Action ID for Generate Image with FLUX.1

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "width": 1024,
    "height": 1024,
    "prompt": "A photo of sks, sitting on a horse, with his face visible.",
    "megapixels": "1",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "loraIntensity": 1,
    "numberOfOutputs": 1,
    "promptIntensity": 0.8,
    "guidanceIntensity": 7.5,
    "outputImageQuality": 80,
    "additionalLoraScale": 1,
    "inferenceStepsCount": 50,
    "enableFastGeneration": false
}

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 example, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The action ID is set to the specific ID for the Generate Image with FLUX.1 action, and the input payload is constructed according to the schema.

Conclusion

The sundai-club/pc_valentino Cognitive Action for image generation empowers developers to easily create high-quality images from text prompts while offering a plethora of customization options. Integrating this functionality into your applications can enhance user engagement and creativity. Consider exploring various prompts and settings to discover the full potential of this powerful image generation tool!