Create Stunning Line Art Images with cuuupid/flux-lineart Cognitive Actions

23 Apr 2025
Create Stunning Line Art Images with cuuupid/flux-lineart Cognitive Actions

In the world of digital art, generating high-quality images with precision and creativity is at the forefront of many applications. The cuuupid/flux-lineart API provides a powerful toolset for developers looking to integrate image generation capabilities into their applications. This API features a specialized action that allows you to generate black and white line art efficiently, making it ideal for artists, designers, and developers alike.

Prerequisites

Before you can start using the Cognitive Actions, you'll need to meet a few general requirements:

  • An API key for the Cognitive Actions platform.
  • Familiarity with JSON format, as you'll be constructing JSON payloads for your requests.
  • Basic knowledge of how to make HTTP requests in your programming environment.

Authentication usually involves passing your API key in the headers of your requests to ensure secure access to the API.

Cognitive Actions Overview

Generate Line Art with Flux

Description: This action generates black and white line art using the Flux model, which is finely tuned for this purpose. It provides an efficient method for creating detailed and high-quality line art images.

Category: Image Generation

Input

The input for this action requires a structured JSON object with the following fields:

  • prompt (required): A text prompt that guides the image generation.
  • mask (optional): URI of the image mask for inpainting.
  • seed (optional): Integer seed for reproducibility.
  • image (optional): URI of the input image for image-to-image or inpainting mode.
  • width (optional): Width of the generated image in pixels (when aspect_ratio is custom).
  • height (optional): Height of the generated image in pixels (when aspect_ratio is custom).
  • aspectRatio (optional): Specifies the aspect ratio of the generated image.
  • goFast (optional): Enables faster predictions.
  • outputCount (optional): Number of output images to generate.
  • outputFormat (optional): The format for the output image (webp, jpg, png).
  • guidanceScale (optional): Adjusts the guidance scale during the generation.
  • outputQuality (optional): Specifies quality for saving output images.
  • inferenceModel (optional): Selects the model for inference (dev or schnell).
  • inferenceStepCount (optional): Number of denoising steps during generation.

Example Input:

{
  "prompt": "a picture in black and white lineart in the style of TOK, astronaut riding a unicorn, black background",
  "loraScale": 1,
  "aspectRatio": "1:1",
  "outputCount": 1,
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "inferenceModel": "dev",
  "inferenceStepCount": 28
}

Output

Upon successful execution, this action returns a URL to the generated line art image. Here’s an example of the output:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/05151fa5-be06-43d7-8304-a35b9c2251e0/7cd90962-8d25-464b-a0b3-c1d526f90af3.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Generate Line Art 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 = "3d063fc6-01cc-402e-b8c4-99b777bea695"  # Action ID for Generate Line Art with Flux

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "a picture in black and white lineart in the style of TOK, astronaut riding a unicorn, black background",
    "loraScale": 1,
    "aspectRatio": "1:1",
    "outputCount": 1,
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "inferenceModel": "dev",
    "inferenceStepCount": 28
}

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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the action’s input requirements, including the prompt and various optional parameters.

Conclusion

The cuuupid/flux-lineart Cognitive Actions offer developers an efficient solution for integrating line art generation into their applications. With a variety of customizable options, you can create stunning images that meet your specific needs. As you explore these capabilities, consider experimenting with different prompts and settings to discover the full potential of this action. Happy coding!