Create Stunning Images with Custom Parameters Using Ferchis

25 Apr 2025
Create Stunning Images with Custom Parameters Using Ferchis

In today's digital landscape, the ability to generate high-quality images quickly and efficiently can give developers a significant edge. Ferchis offers advanced Cognitive Actions that empower users to generate images with customizable parameters, making it easier than ever to create visuals tailored to specific needs. With features like customizable aspect ratios, image masking, and LoRA weight adjustments, developers can enhance image detailing and style variation, all while optimizing for speed or precision based on their project requirements.

Whether you're building a content creation tool, enhancing a gaming experience, or crafting personalized marketing materials, the image generation capabilities of Ferchis can streamline your workflow and elevate your outputs. Imagine being able to produce tailored visuals that resonate with your audience, all through simple API calls.

Prerequisites

To get started with Ferchis, you'll need a Cognitive Actions API key and a basic understanding of making API calls.

Generate Images with Custom Parameters

The Generate Images with Custom Parameters action allows developers to create unique images by leveraging advanced features tailored to their specific requirements. This action is particularly useful for generating visually appealing content that meets precise artistic or branding criteria.

Purpose

This action solves the challenge of creating customized images by providing a wide range of parameters to manipulate, ensuring that users can achieve their desired aesthetic and functional outcomes.

Input Requirements

The input for this action is structured as a composite request that includes the following parameters:

  • prompt (string): A detailed description or directive for generating the image.
  • image (string, optional): A URI for an input image if using image-to-image transformation or inpainting mode.
  • mask (string, optional): An optional image mask for inpainting mode, which overrides certain dimension inputs.
  • width (integer, optional): Custom width of the generated image (only if aspect_ratio is set to 'custom').
  • height (integer, optional): Custom height of the generated image (only if aspect_ratio is set to 'custom').
  • modelType (string): Choose between 'dev' for precision or 'schnell' for faster generation.
  • numberOfOutputs (integer): Specify how many images to generate (from 1 to 4).
  • imageOutputFormat (string): Select the desired output format (webp, jpg, png).
  • Additional parameters for fine-tuning include LoRA strengths, aspect ratios, output quality, and more.

Expected Output

The output will be a URL linking to the generated image, which can be utilized directly in applications or shared with users.

Example output:

["https://assets.cognitiveactions.com/invocations/8d38d227-c2b2-48ee-b1e0-bed46015ab81/1fd7502b-4ca2-40e7-8a9d-7276a1e6ff88.jpg"]

Use Cases for this Action

  • Content Creation: Easily generate visuals for blogs, social media, or marketing campaigns that align with specific themes or brand guidelines.
  • Gaming: Create unique assets for characters, environments, or promotional materials that require specific artistic styles.
  • Design Prototyping: Quickly visualize concepts for client presentations or internal reviews, allowing for rapid iteration and feedback.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "892134da-25d1-4bf5-9c45-0c8e97a68ed2" # Action ID for: Generate Images with Custom Parameters

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "image": "https://replicate.delivery/pbxt/MLduxI6PVOfigoUhqJVsyw7O5Jfg2FQQEVdBIKodtiVcrkKy/hanna%20davis%20Sexiest%20Dresses%20at%20Oscars%202015.png",
  "prompt": "Retrato elegante de 'ferchis' posando con confianza frente a un fondo de diseño moderno, resaltando su estatura de 1 metro con 55 centímetros. Lleva un conjunto de traje negro entallado que acentúa su figura curvilínea de manera sofisticada. La combinación de líneas limpias y su postura erguida realzan su presencia, mientras su mirada directa y el peinado pulido completan la escena con un aire de glamour contemporáneo.",
  "modelType": "dev",
  "loraStrength": 1,
  "enableFastMode": false,
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "jpg",
  "imageOutputQuality": 80,
  "imagePromptStrength": 0.8,
  "approximateMegapixels": "1",
  "additionalLoraStrength": 1,
  "diffusionGuidanceScale": 3,
  "numberOfInferenceSteps": 28
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")

Conclusion

The Ferchis image generation capabilities provide developers with a powerful tool to create stunning visuals tailored to their needs. By harnessing customizable parameters, you can streamline your workflow and produce high-quality images that resonate with your target audience. Whether for content creation, gaming, or design, the ability to quickly generate images with precision opens up new possibilities for innovation and creativity. Start integrating Ferchis today and transform your visual content strategy!