Create Stunning Custom Images with Marius Flux

The Marius Flux API empowers developers to generate custom images through advanced image-to-image translation and inpainting capabilities. With a user-friendly interface, developers can harness the power of AI to create visually appealing images tailored to specific requirements. The service offers the flexibility to choose between two optimized models, 'dev' and 'schnell', allowing for either detailed or fast outputs while controlling various parameters like image dimensions, aspect ratio, and quality. This makes Marius Flux an ideal solution for a range of applications, from artistic projects to commercial content creation.
Common use cases include generating unique artwork for marketing campaigns, enhancing product images for e-commerce, or creating personalized graphics for social media. The ability to integrate diverse styles using LoRA weights further enriches the creative potential, making it an essential tool for any developer focused on visual content.
Prerequisites
To get started with Marius Flux, you will need an API key for the Cognitive Actions service and a basic understanding of making API calls.
Generate Custom Image
This action allows you to create a custom image based on a detailed text prompt. It supports advanced features like image-to-image translation and inpainting, enabling you to modify existing images or create completely new visuals. By leveraging the power of the Marius Flux API, you can customize numerous aspects of image generation, from dimensions to artistic style.
Input Requirements
The input for this action requires a JSON object that includes the following parameters:
- prompt (required): A detailed description of the image you want to generate.
- mask (optional): A URI to an image mask for inpainting mode.
- image (optional): A URI of an input image for image-to-image mode.
- width and height (optional): Custom dimensions for the generated image.
- modelType (default: "dev"): Select between the 'dev' and 'schnell' models.
- numOutputs (default: 1): Specify how many images to generate.
- guidanceScale (default: 3): Adjust the influence of the prompt on the generated image.
- outputQuality (default: 80): Determine the quality of the output image.
- Additional parameters for fine-tuning, such as loraScale, promptStrength, and others.
Expected Output
The output of this action will be a URL pointing to the generated image, allowing you to easily access or display the result.
Use Cases for this Specific Action
- Artistic Creation: Generate unique pieces of art based on imaginative prompts, suitable for galleries or exhibitions.
- E-commerce Enhancement: Create striking product images that stand out in online stores.
- Personalization: Tailor images for clients or specific campaigns, ensuring that content aligns with branding.
- Social Media Content: Produce eye-catching visuals that can be shared across various platforms to boost engagement.
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 = "ac099814-11f7-412e-b356-6aac3e599efb" # Action ID for: Generate Custom Image
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"prompt": "MARIUS sitting casually on a bench in a city park, dressed in a beige trench coat and dark jeans. His elbows rest on his knees, and his gaze is directed at something across the park, his face relaxed and thoughtful. The image is slightly out of focus, with soft natural lighting and some background blur. A bit of smudging around the lens gives the photo a genuine, unrefined quality, as if captured in an everyday moment.",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 1,
"guidanceScale": 0,
"outputQuality": 100,
"extraLoraScale": 1,
"promptStrength": 0.8,
"imageAspectRatio": "4:5",
"imageOutputFormat": "jpg",
"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 Marius Flux API opens up a world of possibilities for developers looking to create custom images efficiently and effectively. With its versatile features and options for customization, you can cater to various needs, from artistic endeavors to commercial projects. By leveraging this powerful tool, you can enhance your applications with unique visual content that resonates with users.
Explore the capabilities of Marius Flux and start creating stunning images today!