Generate Stunning Images Effortlessly with the Ronico Cognitive Actions

23 Apr 2025
Generate Stunning Images Effortlessly with the Ronico Cognitive Actions

Integrating advanced image generation capabilities into your applications has never been easier than with the Ronico Cognitive Actions. This powerful API allows developers to generate images through customizable prompts and models, leveraging inpainting capabilities and various advanced settings. Whether you're creating art, enhancing media, or developing innovative applications, these pre-built actions simplify the process, enabling you to focus on your creative vision.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • A basic understanding of JSON and RESTful APIs.
  • Familiarity with making HTTP requests, particularly POST requests.

To authenticate your requests, you will typically pass your API key in the headers of your HTTP requests.

Cognitive Actions Overview

Generate Image with Inpainting and Model Selection

Description: This action generates images using selected models with inpainting capabilities and customizable settings, including image dimensions, formats, and LoRA scale adjustments. You can choose between 'dev' and 'schnell' models based on your needs.

Category: Image Generation

Input

The following fields are required and optional for this action:

  • Required Fields:
    • prompt: A string guiding the image generation (e.g., "ronico woman face to the camera").
  • Optional Fields:
    • mask: URI of the image mask for inpainting.
    • seed: An integer for generating deterministic results.
    • image: URI of the input image for transformation.
    • model: Specifies the inference model (default: "dev").
    • width: An integer specifying the width of the image (256-1440).
    • height: An integer specifying the height of the image (256-1440).
    • fastMode: A boolean toggling faster prediction mode (default: false).
    • loraScale: A number specifying the intensity of the LoRA application.
    • aspectRatio: Defines the aspect ratio of the image.
    • outputFormat: The file format for the generated image (default: "webp").
    • guidanceScale: A number controlling the influence of guidance in the diffusion process.
    • outputQuality: An integer setting the JPEG quality (0-100).
    • numberOfOutputs: An integer specifying how many images to generate (1-4).
    • numberOfInferenceSteps: An integer indicating the number of denoising steps (1-50).
    • Additional fields for LoRA weights, additional settings, and safety checks are also available.

Example Input:

{
  "model": "dev",
  "prompt": "ronico woman face to the camera",
  "fastMode": false,
  "loraScale": 1,
  "aspectRatio": "16:9",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "numberOfMegapixels": "1",
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Output

The action typically returns a URL pointing to the generated image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/2c3a2a9a-1240-4441-a2ab-f85ccd76407f/be533233-c084-4b88-a266-b7962ad5ac21.webp"
]

Conceptual Usage Example (Python)

Here's how you might invoke 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"  # Hypothetical endpoint

action_id = "e02adcca-bbcb-4b89-abc6-85b2b6aa7cd6"  # Action ID for Generate Image with Inpainting and Model Selection

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "ronico woman face to the camera",
    "fastMode": False,
    "loraScale": 1,
    "aspectRatio": "16:9",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "outputQuality": 80,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "numberOfMegapixels": "1",
    "additionalLoraScale": 1,
    "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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload structure directly corresponds to the input fields defined above, making it easy to customize your image generation requests.

Conclusion

With the Ronico Cognitive Actions, developers can effortlessly generate stunning images tailored to their specifications. The flexibility of model selection, inpainting capabilities, and a plethora of customizable settings empowers your applications to produce high-quality visual content. Start experimenting with these actions today to unlock the potential of creative image generation in your projects!