Create Stunning Custom Images with Kellogs Chocos

26 Apr 2025
Create Stunning Custom Images with Kellogs Chocos

Kellogs Chocos offers innovative Cognitive Actions that empower developers to generate custom images tailored to specific prompts and settings. With a focus on ease of use and flexibility, these actions simplify the image creation process, making it faster and more efficient. Whether you're looking to enhance user engagement in a digital product, create unique graphics for marketing campaigns, or generate art for personal projects, these tools provide the capabilities you need to bring your creative ideas to life.

Imagine being able to create high-quality images on demand, adjusting parameters like aspect ratio, image quality, and detail level to suit your project's requirements. Common use cases for this image generation action include creating visual content for social media, designing custom graphics for websites, or producing illustrations for presentations. The ability to generate images quickly and with precision can significantly enhance your workflow and productivity.

Prerequisites

To get started with Kellogs Chocos, you'll need an API key for the Cognitive Actions service and a basic understanding of making API calls.

Generate Custom Image

The "Generate Custom Image" action allows you to create custom images by providing a text prompt alongside various configurable settings. This action is particularly useful for developers who require tailored images for applications, websites, or other digital needs.

Purpose

The primary purpose of this action is to enable users to generate unique images based on specific prompts. It solves the problem of needing high-quality visuals without the extensive time and resources typically required for manual creation.

Input Requirements

To use this action, you must provide a structured input, including:

  • prompt: A string that describes the image you want to generate.
  • Optional parameters include masks, seed values for reproducibility, dimensions (width and height), model type, and more.

Example input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "TOK",
  "loraScale": 0.6,
  "outputCount": 1,
  "guidanceScale": 7.5,
  "promptStrength": 0.8,
  "inferenceStepCount": 50
}

Expected Output

The action will return a URL linking to the generated image. The output will be in the specified format (e.g., webp, jpg, png).

Example output:

[
  "https://assets.cognitiveactions.com/invocations/292b5419-75ed-43c3-822e-837fe76c968e/477528f2-5a8f-49c9-b8d7-9e77ad3f60ca.webp"
]

Use Cases for this Action

  • Social Media Content Creation: Quickly generate eye-catching images that fit the theme of your posts.
  • Custom Illustrations: Create tailored visuals for websites or applications that resonate with your audience.
  • Marketing Material: Design unique graphics for promotional campaigns, enhancing brand visibility.
  • Art Generation: Explore creative concepts by generating art based on specific themes or styles.
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 = "9ac8c714-fa12-47b0-b5d5-44cccbe3749c" # Action ID for: Generate Custom Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "width": 1024,
  "height": 1024,
  "prompt": "TOK",
  "loraScale": 0.6,
  "outputCount": 1,
  "guidanceScale": 7.5,
  "promptStrength": 0.8,
  "inferenceStepCount": 50
}

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

Kellogs Chocos' image generation capabilities provide developers with powerful tools to create stunning custom visuals tailored to their needs. With options for customization and quick generation, you can streamline your workflow and enhance the visual appeal of your projects. Start exploring the possibilities today and elevate your creative output!