Unlocking Image Generation: A Developer's Guide to the Aymankarim/SyrianDesign Cognitive Actions

23 Apr 2025
Unlocking Image Generation: A Developer's Guide to the Aymankarim/SyrianDesign Cognitive Actions

In the realm of artificial intelligence and image processing, the Aymankarim/SyrianDesign API offers a powerful Cognitive Action that enables developers to generate stunning inpainted images with ease. This action leverages advanced AI models and customizable parameters to deliver high-quality results, making it an invaluable tool for creative applications in fields like design, marketing, and content creation.

Prerequisites

Before diving into the integration of the Cognitive Actions, ensure you have:

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

Typically, authentication works by passing the API key in the request headers, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Inpainted Image

The Generate Inpainted Image action is designed to create images by filling in missing areas, utilizing image masking and AI optimization for speed and precision. This action supports various configurations, including customizable dimensions, aspect ratios, and intensity adjustments.

Input

The input schema for this action requires a well-structured JSON object, which includes the following fields:

  • prompt (required): A text description for image generation. For example: "Interior design of a living room SYRDESN IMG_1025.HEIC".
  • model (optional): Choose between "dev" or "schnell" for the inference model.
  • aspectRatio (optional): Define the aspect ratio, e.g., "1:1".
  • imageFormat (optional): Specify the output format, e.g., "jpg".
  • imageQuality (optional): Set the quality from 0 to 100, e.g., 90.
  • loraStrength (optional): The influence strength of LoRA, typically between 0 and 1.
  • guidanceScale (optional): Control the guidance level during the diffusion process, e.g., 3.5.
  • numberOfOutputs (optional): Indicate the number of images to generate, between 1 and 4.
Example Input
{
  "model": "dev",
  "prompt": "Interior design of a living room SYRDESN IMG_1025.HEIC",
  "aspectRatio": "1:1",
  "imageFormat": "jpg",
  "imageQuality": 90,
  "loraStrength": 1,
  "guidanceScale": 3.5,
  "numberOfOutputs": 1
}

Output

Upon successful execution, the action returns a URL pointing to the generated image. Here’s an example of the output you might receive:

[
  "https://assets.cognitiveactions.com/invocations/78edd2ca-da02-45ab-b0c7-bce79673b4c2/a098ad11-f68a-4f8c-a540-e51acc915830.jpg"
]

Conceptual Usage Example (Python)

Here’s how you might call 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 = "95aa9716-5819-4cf9-8a9e-d4e6ff76a4f2" # Action ID for Generate Inpainted Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Interior design of a living room SYRDESN IMG_1025.HEIC",
    "aspectRatio": "1:1",
    "imageFormat": "jpg",
    "imageQuality": 90,
    "loraStrength": 1,
    "guidanceScale": 3.5,
    "numberOfOutputs": 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 the placeholders with your actual API key and adjust the input payload as needed. The structure allows you to execute the inpainting action and handle the response effectively.

Conclusion

Integrating the Generate Inpainted Image action from the Aymankarim/SyrianDesign API into your projects can significantly enhance your applications with high-quality image generation capabilities. With customizable parameters and AI-driven features, developers can create visually compelling content efficiently. Consider exploring additional use cases or combining this action with other functionalities to maximize its impact!