Create Stunning Custom Images with Tokk's AI Actions

In the realm of digital content creation, visual elements play a pivotal role in capturing attention and conveying messages effectively. Tokk offers a powerful set of Cognitive Actions designed to generate high-quality images tailored to your specific needs. By leveraging advanced AI capabilities, these actions enable developers to create stunning visuals quickly and easily, streamlining workflows and enhancing creative possibilities.
With Tokk's image generation features, you can customize images using various parameters, including prompts, image masks, and model types. This flexibility opens up numerous use cases, from producing unique artwork for marketing campaigns to generating personalized graphics for social media. Whether you’re an artist seeking inspiration or a developer looking to automate image creation, Tokk provides the tools to bring your vision to life.
Prerequisites
To get started with Tokk's Cognitive Actions, you'll need an API key and a basic understanding of how to make API calls. Once you have these, you can unlock the full potential of image generation.
Generate Image with Custom Parameters
The "Generate Image with Custom Parameters" action allows you to create high-quality images by inputting specific parameters such as prompts, image masks, and model types. This action supports inpainting and image-to-image modes, enabling you to customize results further by adjusting aspect ratios, resolutions, and more.
Input Requirements
To utilize this action, you must provide a prompt, which serves as the guiding description for the generated image. Additionally, you can include optional parameters such as:
- mask: An image mask for inpainting mode.
- seed: A random seed for consistent results across generations.
- image: An input image for image-to-image or inpainting modes.
- width and height: Dimensions for custom aspect ratios.
- numOutputs: The number of images to generate.
- guidanceScale: Adjusts the diffusion process for image generation.
Expected Output
The action returns a set of generated images based on the provided inputs, typically in the specified output format (e.g., PNG, JPG). For example, you might receive links to the generated images, which can be directly used in your applications.
Use Cases for this Specific Action
- Marketing and Advertising: Create unique visuals for advertisements or social media posts that resonate with your target audience.
- Personalized Content: Generate tailored images that match specific themes or user preferences for web applications or platforms.
- Artistic Exploration: Artists can use the action to explore different styles and concepts, generating inspiration for their projects.
- E-commerce: Automatically create product images or promotional graphics that align with branding guidelines.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "10c585e3-8525-462b-a21a-c336ccb25e92" # Action ID for: Generate Image with Custom Parameters
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"prompt": "a raw photo realistic ,high quality photo of tokk photo taken cannon ,black hair natural look,a plus size woman,mid 30's wearing a simi transparent tank top , adjusting her top, smiling, pulling top,tan lines,small saggy breasts,(best quality,4k,8k,highres,masterpiece:,ultra-detailed,(realistic,photorealistic,photo-realistic:HDR,UHD,studio lighting,,sharp focus,physically-based rendering,extreme detail description,professional,vivid colors,,photographic,bedroom on a bed ,on a couch ,,curvy figure,voluptuous,self-confident,empowering,body positive",
"loraScale": 1,
"numOutputs": 3,
"guidanceScale": 2.01,
"outputQuality": 100,
"extraLoraScale": 1,
"modelSelection": "dev",
"promptStrength": 0.58,
"imageAspectRatio": "1:1",
"imageOutputFormat": "png",
"numInferenceSteps": 27
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
Tokk's image generation capabilities empower developers to create stunning visuals with ease and precision. By leveraging customizable parameters, you can produce high-quality images suited for various applications, from marketing to personal projects. As you explore the potential of Tokk's Cognitive Actions, consider how these tools can enhance your workflow and expand your creative horizons. Start integrating Tokk into your projects today and unlock a world of visual possibilities!