Generate Stunning Images with Inpainting Using fofr/flux-tessellate Actions

25 Apr 2025
Generate Stunning Images with Inpainting Using fofr/flux-tessellate Actions

In the realm of image generation, the fofr/flux-tessellate API offers powerful Cognitive Actions that allow developers to create captivating visuals with advanced inpainting capabilities. With features like customizable aspect ratios, various inference models, and output quality settings, these actions enable developers to push the boundaries of creativity in their applications. In this article, we'll explore how to leverage the "Generate Image with Inpainting" action to produce stunning images tailored to specific requirements.

Prerequisites

Before diving into the integration of Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic familiarity with making HTTP requests in your programming environment.
  • Understanding of JSON structure to format your input and output data correctly.

Authentication typically involves passing the API key in the headers of your HTTP requests, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action facilitates image generation with inpainting capabilities. This means you can specify areas in an image to be altered or generated anew based on a textual prompt, enhancing creativity in design workflows.

Input

The input for this action is structured as follows:

{
  "prompt": "a TSL8 tessellating repeating pattern of vehicles, side view, all gaps filled, escher",
  "guidanceScale": 2.5,
  "outputQuality": 80,
  "inferenceModel": "dev",
  "numberOfOutputs": 4,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "inferenceStepCount": 28,
  "loraIntensityScale": 0.75
}
  • Required Fields:
    • prompt: A text prompt guiding the image generation.
  • Optional Fields:
    • mask: URI for an image mask (if inpainting).
    • seed: Integer for reproducibility.
    • image: URI for an input image (if using image-to-image mode).
    • width & height: Dimensions for the image if using a custom aspect ratio.
    • guidanceScale: Influences realism and adherence to the prompt.
    • outputQuality: Quality of the saved output image.
    • inferenceModel: Choose between 'dev' (detailed) or 'schnell' (faster).
    • numberOfOutputs: Specify how many images to generate (max 4).
    • imageAspectRatio: Specifies the aspect ratio for the image.
    • imageOutputFormat: Format of the output image (webp, jpg, png).
    • Additional fields control various aspects like LoRA weights and speed optimization.

Output

The action returns an array of image URLs pointing to the generated images. An example output might look like this:

[
  "https://assets.cognitiveactions.com/invocations/3757c24d-01a0-467b-91e9-fcaff1aeebb9/2ddf5ea7-dd87-4848-929b-868457652804.webp",
  "https://assets.cognitiveactions.com/invocations/3757c24d-01a0-467b-91e9-fcaff1aeebb9/300016a1-2fd7-4eaf-8512-9fe5fce8e6cb.webp",
  "https://assets.cognitiveactions.com/invocations/3757c24d-01a0-467b-91e9-fcaff1aeebb9/10b9e1f4-d0c1-4bb3-b93d-ca7f4c441af9.webp",
  "https://assets.cognitiveactions.com/invocations/3757c24d-01a0-467b-91e9-fcaff1aeebb9/a6b2d36c-287f-46de-b414-8e665284b6a2.webp"
]

Conceptual Usage Example (Python)

Here is a conceptual Python code snippet to execute the Generate Image with Inpainting action:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "b90897a7-8a61-4636-8e6a-21ee00ecee67" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "a TSL8 tessellating repeating pattern of vehicles, side view, all gaps filled, escher",
    "guidanceScale": 2.5,
    "outputQuality": 80,
    "inferenceModel": "dev",
    "numberOfOutputs": 4,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "inferenceStepCount": 28,
    "loraIntensityScale": 0.75
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

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

In this code, you'll notice how to set the action ID and input payload appropriately. The endpoint URL and request structure are illustrative, giving you a conceptual framework for integrating this action into your application.

Conclusion

The fofr/flux-tessellate API's Generate Image with Inpainting action empowers developers to create visually stunning images tailored to their specifications. By utilizing customizable parameters and advanced inpainting techniques, you can elevate your applications with unique visual content. Consider exploring potential use cases such as graphic design, game development, or even automated content generation to fully harness the capabilities of these Cognitive Actions. Happy coding!