Create Stunning AI-Generated Images with Generador Imagen Ia

25 Apr 2025
Create Stunning AI-Generated Images with Generador Imagen Ia

The Generador Imagen Ia service offers developers the ability to create high-quality, AI-generated images tailored to specific needs through customizable prompts. This powerful tool harnesses advanced image generation techniques, including image-to-image transformation and inpainting modes, enabling users to produce images that align closely with their visions. With features like LoRA weights for enhanced specificity and options to optimize for speed or quality, developers can effortlessly integrate image generation into their applications.

Common use cases for this service include creating unique graphics for marketing materials, generating illustrations for web content, or enhancing existing images with AI-driven modifications. Whether you are building a portfolio of digital art or developing applications that require dynamic visual content, the Generador Imagen Ia can simplify and expedite your workflow.

Prerequisites

To get started, you'll need a Cognitive Actions API key and a basic understanding of making API calls to leverage the capabilities of the Generador Imagen Ia service effectively.

Generate AI-Based Image

The Generate AI-Based Image action allows you to produce images based on detailed text prompts. By specifying various parameters, you can guide the AI to create visuals that match your creative requirements.

Purpose

This action is designed to solve the challenge of image creation by providing a customizable interface for generating images that reflect specific themes, styles, or concepts.

Input Requirements

Input for this action requires a JSON object that includes the following key properties:

  • prompt (string): A detailed description guiding the image generation.
  • Various optional parameters such as width, height, aspectRatio, numOutputs, and more to refine the output.

Expected Output

The output will be a set of image URLs in the specified format (webp, jpg, png) that correspond to the generated images based on your prompt.

Use Cases for this Action

  • Marketing: Generate unique visuals for campaigns that capture the essence of your product or service.
  • Content Creation: Create eye-catching images for blogs or social media posts without the need for extensive graphic design skills.
  • Art and Design: Experiment with different styles and concepts to inspire new artistic directions or projects.
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 = "30041069-ee5b-4462-b7d0-8e5cb3f54a43" # Action ID for: Generate AI-Based Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "width": 741,
  "goFast": false,
  "height": 630,
  "prompt": "The image features a stylized and strong character named TOK frfer93, designed in a minimalist and modern style. He is wearing a tech-inspired T-shirt or something with a subtle geeky touch. TOK frfer93 is holding a prediction board displaying a price forecast for Airbnb rentals, with numbers and trend lines indicating price variations. The text on the board says \"Airbnb Price Prediction\" in a clear, professional font.\n\nThe background is sleek and modern, using a combination of technology-themed colors like shades of blue, black, and white, with some vibrant accents to maintain visual appeal. Subtle references to programming and data science can be included in the background, such as blurred lines of code, small icons related to machine learning, or Airbnb-related symbols.\n\nThe overall design maintains a professional and trustworthy look, making it ideal for a GitHub repository focused on predicting Airbnb prices using data-driven models.\n\nLet me know if you need any refinements!\n\n\n\n\n\n\n\n\n\n\n.\n\n\n\n\n\n\n\n\n\n",
  "numOutputs": 4,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "mainLoraScale": 1,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.88,
  "imageResolution": "1",
  "numInferenceSteps": 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 Generador Imagen Ia service empowers developers to create custom images quickly and efficiently, enhancing their projects with AI-driven visuals. With its flexible features and robust capabilities, you can explore a range of applications, from marketing to creative arts. Start integrating this service into your workflow today and unlock the potential of AI-enhanced image generation!