Create Stunning Images with the submundonet/toby Cognitive Actions

In the realm of artificial intelligence, image generation has opened up exciting possibilities for developers. The submundonet/toby Cognitive Actions provide a robust set of tools for creating images based on custom parameters. With these pre-built actions, developers can efficiently generate high-quality images tailored to specific prompts, formats, and styles, enhancing the creative capabilities of their applications.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- API Key: Obtain your API key from the Cognitive Actions platform to authenticate your requests.
- Setup: Familiarize yourself with the API structure and ensure you can send HTTP requests. Authentication typically involves passing your API key in the request headers.
Cognitive Actions Overview
Generate Image with Custom Parameters
This action allows you to create images using a variety of parameters including prompts, image masks, and custom dimensions. It is optimized for both detail and speed, making it suitable for applications ranging from image inpainting to prompt-based generation.
Category: Image Generation
Input
The input for this action requires various fields, with prompt being mandatory. Below is the schema and a practical example:
{
"prompt": "TOBY, Visão de perto de um luxuoso kit de higiene para bebês em uma bancada de mármore em um berçário elegante. O kit inclui recipientes de cerâmica branca com tampas azuis, cobertos com pequenas figuras de ursinhos de pelúcia brancos. Um dispensador de sabão branco com uma fita dourada fica próximo. Todos os itens estão dispostos em uma bandeja azul-clara em forma de nuvem. O fundo mostra vislumbres de um quarto de bebê de alto padrão com iluminação suave e aconchegante e decoração sutil de berçário. O estilo da imagem é fotorrealista com tons suaves e aconchegantes.",
"loraScale": 1,
"numOutputs": 1,
"guidanceScale": 3.5,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "png",
"numInferenceSteps": 49,
"imageOutputQuality": 100
}
Output
The output from this action is typically a URL pointing to the generated image. Here’s an example of what you might receive:
[
"https://assets.cognitiveactions.com/invocations/96791363-0ca4-420a-b180-902809b91464/4ecc80f9-7e29-4652-a8f1-05f6d156d9d5.png"
]
Conceptual Usage Example (Python)
Here’s how you can call the Generate Image with Custom Parameters 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 = "06fdf282-e017-4f74-ad35-2ac3486ab9a5" # Action ID for Generate Image with Custom Parameters
# Construct the input payload based on the action's requirements
payload = {
"prompt": "TOBY, Visão de perto de um luxuoso kit de higiene para bebês em uma bancada de mármore em um berçário elegante. O kit inclui recipientes de cerâmica branca com tampas azuis, cobertos com pequenas figuras de ursinhos de pelúcia brancos. Um dispensador de sabão branco com uma fita dourada fica próximo. Todos os itens estão dispostos em uma bandeja azul-clara em forma de nuvem. O fundo mostra vislumbres de um quarto de bebê de alto padrão com iluminação suave e aconchegante e decoração sutil de berçário. O estilo da imagem é fotorrealista com tons suaves e aconchegantes.",
"loraScale": 1,
"numOutputs": 1,
"guidanceScale": 3.5,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "png",
"numInferenceSteps": 49,
"imageOutputQuality": 100
}
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 the placeholders with your actual API key and endpoint. The action_id corresponds to the specific action you want to invoke. The constructed payload contains all the necessary parameters needed for generating the image.
Conclusion
The submundonet/toby Cognitive Actions empower developers to create customized images seamlessly. By leveraging the capabilities of the Generate Image with Custom Parameters action, you can enhance your applications with stunning visuals tailored to specific needs. Explore the various parameters to experiment and refine your image generation process, and consider how these actions can be integrated into your next project for a richer user experience.