Create Stunning Images with My Gufeng's Image Generation Action

26 Apr 2025
Create Stunning Images with My Gufeng's Image Generation Action

In today's digital landscape, the ability to create high-quality visuals quickly and efficiently is paramount for developers. Enter My Gufeng, an innovative service that empowers you to generate stunning images through its advanced Cognitive Actions. With a focus on image generation, My Gufeng offers developers a streamlined API that simplifies the process of creating visually appealing content. Whether you are working on applications in gaming, marketing, or content creation, these actions can significantly enhance your projects by providing high-quality images tailored to your specifications.

Imagine being able to create images that meet your specific requirements in terms of aspect ratio, resolution, and quality—all while optimizing for speed. My Gufeng leverages cutting-edge models designed for fast inference, making it an invaluable tool for developers looking to integrate image generation capabilities into their applications.

Prerequisites

To get started with My Gufeng, you'll need to obtain a Cognitive Actions API key and have a basic understanding of making API calls. This will allow you to leverage the full potential of the image generation capabilities offered.

Generate Enhanced Images

The Generate Enhanced Images action is designed to create high-quality images using both inpainting and image-to-image modes. This action allows you to customize various parameters, such as aspect ratio, resolution, and output quality, ensuring that the generated images meet your specific needs.

Purpose

This action solves the problem of producing high-quality images quickly, which is essential for applications that require fast turnaround times without compromising on visual fidelity.

Input Requirements

The action requires a prompt to guide the image generation, along with optional parameters such as:

  • image: The input image for modifications or inpainting.
  • mask: An image mask for inpainting mode.
  • model: Choose between 'dev' for optimal results or 'schnell' for faster processing.
  • width and height: Dimensions of the generated image.
  • Additional options like megapixels, aspectRatio, and outputQuality to further refine the output.

Expected Output

Upon successful execution, the action returns a high-quality image URL, which you can directly use in your applications. The output format can be specified as webp, jpg, or png, depending on your needs.

Use Cases for this Action

  • Marketing Materials: Quickly generate promotional images tailored to specific campaigns.
  • Game Development: Create unique assets for characters or environments based on design prompts.
  • Content Creation: Enhance blog posts or social media content with custom graphics.
  • Artistic Projects: Experiment with different styles and concepts by leveraging the customizable parameters.
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 = "6347594b-aba5-427c-b333-7e2429e06c95" # Action ID for: Generate Enhanced Images

# 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/MjB9XrVbIRbaqKXVO98ugSm28UAwgJ1bDj2VL3odytzvNzC8/2.jpg",
  "model": "dev",
  "width": 1024,
  "height": 1024,
  "prompt": "TOK,低头微笑,白衣汉服,墨色长发,清冷气质,写实风格",
  "megapixels": "1",
  "aspectRatio": "1:1",
  "imageFormat": "webp",
  "loraIntensity": 1,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "acceleratedMode": false,
  "numberOfOutputs": 1,
  "guidanceIntensity": 3,
  "numberOfInferenceSteps": 28,
  "additionalLoraIntensity": 1
}

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 Generate Enhanced Images action offered by My Gufeng provides developers with a powerful, flexible tool for creating high-quality visuals. With its customizable parameters and fast processing capabilities, this action addresses the needs of a variety of applications, from marketing to gaming. By integrating My Gufeng into your projects, you can streamline your image generation process and enhance the overall quality of your visual content.

As a next step, consider exploring the various input parameters and experimenting with different prompts to see how My Gufeng can elevate your creative projects.