Create Stunning Images with Ophelie’s Custom Parameters

25 Apr 2025
Create Stunning Images with Ophelie’s Custom Parameters

Ophelie offers a powerful and versatile image generation service that allows developers to create stunning visuals tailored to specific requirements. With customizable parameters, Ophelie simplifies the process of generating high-quality images, making it easier and faster for developers to integrate advanced image generation capabilities into their applications. Whether you're looking to produce realistic portraits, artistic renditions, or unique designs, Ophelie provides the tools necessary to bring your creative vision to life.

Use Cases

  • Marketing and Branding: Generate high-definition images for promotional materials, social media posts, or product displays that resonate with your target audience.
  • Content Creation: Create visually appealing images for blogs, articles, or websites, enhancing user engagement and information retention.
  • Game Development: Design character portraits, backgrounds, or concept art that aligns with the game's aesthetics and storyline.
  • Personal Projects: Bring personal art concepts or ideas to fruition, experimenting with different styles and compositions effortlessly.

Prerequisites

To get started with Ophelie, you will need an API key for accessing the Cognitive Actions service and a basic understanding of making API calls.

Generate Image with Custom Parameters

The "Generate Image with Custom Parameters" action allows you to create images using Ophelie's advanced capabilities. This action provides flexibility in model selection, image resolution, and various customization options, enabling you to generate images that meet specific artistic or functional requirements.

Purpose

This action is designed to solve the challenge of generating high-quality images tailored to unique specifications. By offering options for model selection, resolution, and customizable parameters, developers can produce images that suit their exact needs.

Input Requirements

The input for this action requires a JSON object with the following key parameters:

  • prompt: A descriptive text prompt guiding the image generation.
  • mask (optional): A URI to an image mask for inpainting.
  • image (optional): A URI to an input image for image-to-image or inpainting mode.
  • width and height: Specify the dimensions of the generated image when using a custom aspect ratio.
  • outputCount: The number of images to generate (1 to 4).
  • loraIntensity: Adjust the intensity of the main LoRA applied.
  • enableFastMode: Toggle for optimizing speed.
  • inferenceModel: Choose between 'dev' or 'schnell' models.
  • imageAspectRatio: Set the aspect ratio for the image.
  • outputImageFormat: Specify the format for the output images (e.g., webp, jpg, png).
  • imageOutputQuality: Define the quality level for the generated images.

Expected Output

The expected output is an array of image URLs pointing to the generated images, allowing you to easily access and use the images in your projects.

Use Cases for this Specific Action

  • Custom Art Creation: Generate unique artwork based on specific themes or concepts, perfect for artists and designers.
  • Dynamic Content Generation: Automatically create images for user-generated content, enhancing personalization.
  • Prototyping and Testing: Quickly generate visuals for mockups or prototypes in development phases, saving time and resources.

```python
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 = "0600ab46-5dad-417d-8c43-3ce77f626da8" # Action ID for: Generate Image 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 = {
  "prompt": "Ultra-realistic, high-definition portrait of OPHELIE with a natural, professional look. She has a confident yet approachable expression with a subtle smile, engaging gaze directly at the camera. She wears elegant business attire suitable for a corporate setting. Bbackground remains a gently blurred neutral tone (light gray or soft blue) to emphasize the subject. The composition is centered, adhering to LinkedIn profile picture standards, with a sharp focus on the face. Her blonde highlights should cover two-thirds of her hair length.",
  "outputCount": 1,
  "loraIntensity": 1,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "imageMegapixels": "1",
  "promptIntensity": 0.8,
  "imageAspectRatio": "1:1",
  "outputImageFormat": "webp",
  "imageOutputQuality": 80,
  "inferenceStepCount": 28,
  "diffusionGuidanceScale": 3,
  "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
Ophelie's ability to generate images with custom parameters empowers developers to create tailored visuals that meet a variety of needs. The flexibility offered by this action opens up new possibilities for marketing, content creation, and personal projects. As you explore the capabilities of Ophelie, consider how you can leverage these features to enhance your applications and engage your audience more effectively. Start integrating today and watch your creative ideas come to life!