Generate Stunning Images from Text Prompts with jcbianchi010/jeancbianchi Cognitive Actions

22 Apr 2025
Generate Stunning Images from Text Prompts with jcbianchi010/jeancbianchi Cognitive Actions

In today's digital landscape, the ability to generate images from text prompts can significantly enhance applications across various domains, from content creation to gaming. The jcbianchi010/jeancbianchi API provides a powerful Cognitive Action that enables developers to create unique images using descriptive text. This blog post will guide you through the capabilities of this action, its requirements, and how to integrate it into your applications seamlessly.

Prerequisites

To get started with the Cognitive Actions, you will need:

  • API Key: Ensure you have an API key for authenticating your requests.
  • HTTP Client: Familiarity with making HTTP requests in your programming language of choice, as this will be essential for invoking the Cognitive Actions.

Authentication typically involves passing your API key in the headers of your request, allowing you to securely access the service.

Cognitive Actions Overview

Generate Image from Text Prompt

The Generate Image from Text Prompt action allows you to create images based on a descriptive text prompt, utilizing advanced image generation techniques. This action supports various custom settings, including aspect ratios and image quality, to deliver tailored results for your application needs.

  • Category: Image Generation

Input

The input schema for this action is as follows:

{
  "prompt": "jean bianchi a full body photo, smiling, wearing a light gray suit, white shirt and dark green tie, with hands in pockets and hair styled.",
  "loraScale": 1,
  "imageFormat": "webp",
  "outputCount": 1,
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "extraLoraScale": 0.8,
  "inferenceModel": "dev",
  "imageAspectRatio": "1:1",
  "inferenceStepCount": 28
}

Required Fields:

  • prompt: The descriptive text for the image to be generated.

Optional Fields:

  • mask: URI to an image mask for inpainting.
  • seed: Integer for random seed.
  • image: URI to an input image.
  • width, height: Specify custom dimensions.
  • fastMode: Enable speed-optimized predictions.
  • loraScale: Adjust the intensity of the LoRA application.
  • outputCount: Number of images to generate (1-4).
  • guidanceScale: Control the diffusion process guidance.
  • outputQuality: Image quality from 0 to 100.
  • imageFormat: Specifies format (webp, jpg, png).
  • inferenceModel: Selects the model for inference.

Output

Upon successful execution, the action returns a URL pointing to the generated image:

[
  "https://assets.cognitiveactions.com/invocations/5695cdea-b27f-426b-891d-46840fae824c/34869d34-406b-4732-bf2d-de1ee30d9859.webp"
]

This URL allows you to access and display the generated image in your application.

Conceptual Usage Example (Python)

Here’s how you can invoke the Generate Image from Text Prompt action using Python:

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 = "e30194c7-c446-45d2-bf1c-4598095f7cf2"  # Action ID for Generate Image from Text Prompt

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "jean bianchi a full body photo, smiling, wearing a light gray suit, white shirt and dark green tie, with hands in pockets and hair styled.",
    "loraScale": 1,
    "imageFormat": "webp",
    "outputCount": 1,
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "extraLoraScale": 0.8,
    "inferenceModel": "dev",
    "imageAspectRatio": "1:1",
    "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 code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is constructed with the required and optional parameters for the action. The response will contain the URL of the generated image.

Conclusion

The Generate Image from Text Prompt action from the jcbianchi010/jeancbianchi API opens up exciting possibilities for developers looking to enhance their applications with dynamic image generation capabilities. By integrating this action, you can provide users with customized visuals based on their textual inputs, creating a more engaging experience. Explore this powerful tool and consider how you can incorporate it into your future projects!