Generate Stunning Images with the tokaito14/laura Cognitive Actions

The tokaito14/laura API offers powerful Cognitive Actions that allow developers to generate images from text prompts, leveraging advanced image inpainting and diffusion models. These pre-built actions are designed to simplify the integration of cutting-edge image generation capabilities into your applications, enhancing user experiences with visually stunning outputs.
Prerequisites
Before you start using the tokaito14/laura Cognitive Actions, ensure you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic understanding of JSON and RESTful APIs.
- Familiarity with making HTTP requests in your programming environment.
For authentication, you will typically pass your API key in the headers of your requests.
Cognitive Actions Overview
Generate Image from Prompt
The Generate Image from Prompt action takes a user-provided prompt and generates an image based on that input. It supports various modes, including image-to-image transformation, and customizable settings such as output quality, image format, and aspect ratio.
- Category: Image Generation
Input
The action requires a JSON object with the following schema. Here’s a breakdown of the required and optional fields:
{
"prompt": "string (required)",
"model": "string (optional, default: 'dev')",
"numOutputs": "integer (optional, default: 1)",
"aspectRatio": "string (optional, default: '1:1')",
"outputFormat": "string (optional, default: 'webp')",
"guidanceScale": "number (optional, default: 3)",
"outputQuality": "integer (optional, default: 80)",
"promptStrength": "number (optional, default: 0.8)",
"numInferenceSteps": "integer (optional, default: 28)"
}
Example Input:
{
"model": "dev",
"prompt": "Fashionable portrait photograph of an intense woman, dressed in a crumpled brown leather blazer, \na crumpled skirt \ntight gloves, \nwith a straight black bowl haircut and a single long braided ponytail, dramatic lighting, depth of field that emphasises",
"loraScale": 1,
"numOutputs": 1,
"aspectRatio": "9:16",
"outputFormat": "jpg",
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"numInferenceSteps": 28
}
Output
The action typically returns a URL to the generated image. Here’s an example of the output structure:
[
"https://assets.cognitiveactions.com/invocations/b23af533-79c4-440a-bd48-902196a344e0/3fc5973c-09b2-4485-94c6-8e5f831931f4.jpg"
]
Conceptual Usage Example (Python)
Here’s how you can invoke the Generate Image from 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 = "68dda591-e3ff-4f50-b092-19eca47acb69" # Action ID for Generate Image from Prompt
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "Fashionable portrait photograph of an intense woman, dressed in a crumpled brown leather blazer, "
"a crumpled skirt, tight gloves, with a straight black bowl haircut and a single long braided ponytail, "
"dramatic lighting, depth of field that emphasises",
"numOutputs": 1,
"aspectRatio": "9:16",
"outputFormat": "jpg",
"guidanceScale": 3.5,
"outputQuality": 90,
"promptStrength": 0.8,
"numInferenceSteps": 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 example, we set up the input payload according to the action's specifications, including the model, prompt, and various output parameters. The API request is then sent to the hypothetical endpoint, and the response is handled appropriately.
Conclusion
The tokaito14/laura Cognitive Actions provide an efficient way for developers to integrate sophisticated image generation capabilities into their applications. By using the Generate Image from Prompt action, you can create visually compelling content tailored to your users' needs. Explore these actions further to discover how they can enhance your projects, and consider experimenting with various prompts and settings to achieve the best results.