Create Custom Emojis Effortlessly with Genmoji Cognitive Actions

24 Apr 2025
Create Custom Emojis Effortlessly with Genmoji Cognitive Actions

In the world of digital communication, emojis have become an essential part of expressing emotions and ideas. The Genmoji Cognitive Actions from the astelvida/genmoji-gen spec allow developers to create customized emoji images utilizing advanced image generation models. These pre-built actions enable quick integration into applications, offering a seamless way to enhance user interactions with personalized visual content.

Prerequisites

Before you dive into using the Genmoji Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, which you will include in your requests for authentication.
  • Familiarity with JSON format for constructing input payloads.

Authentication typically involves passing your API key in the request headers, which allows you to access the action capabilities securely.

Cognitive Actions Overview

Generate Emojis with Genmoji

The Generate Emojis with Genmoji action enables the creation of customized emoji images using a sophisticated image generation model. This action supports various parameters, including aspect ratio, image dimensions, and output quality, allowing developers to tailor the generated content to their specific needs.

Input:

The input for this action consists of a structured JSON object. Here’s a breakdown of the relevant fields:

  • prompt (required): The main input prompt for generating the image. Example: "GENMOJI , emoji of a girl eating a pumpkin".
  • goFast (optional): A boolean to activate a faster prediction mode.
  • modelType (optional): Specifies the model to use; options are "dev" or "schnell".
  • numOutputs (optional): Number of output images to generate (default is 1).
  • guidanceScale (optional): Sets the guidance scale for the diffusion process (default is 3).
  • outputQuality (optional): Specifies the quality of saved output images (default is 80).
  • imageAspectRatio (optional): Defines the aspect ratio for the generated image (default is "1:1").
  • Other optional fields include height, width, mask, image, and various scaling factors.

Here’s an example input payload:

{
  "goFast": false,
  "prompt": "GENMOJI , emoji of a girl eating a pumpkin",
  "loraScale": 1,
  "modelType": "dev",
  "numOutputs": 1,
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "approxMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28
}

Output:

The action typically returns a URL to the generated emoji image. Here is an example of a response:

[
  "https://assets.cognitiveactions.com/invocations/d4aa6d85-8b2d-4e35-9c85-e2555dc7cc15/223c41fc-89d9-4b10-bd21-c84719f67a58.webp"
]

Conceptual Usage Example (Python):

Here’s how a developer might use the Genmoji action in a Python script:

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 = "92046f63-7ab6-437c-acea-e11c4c389a04"  # Action ID for Generate Emojis with Genmoji

# Construct the input payload based on the action's requirements
payload = {
    "goFast": false,
    "prompt": "GENMOJI , emoji of a girl eating a pumpkin",
    "loraScale": 1,
    "modelType": "dev",
    "numOutputs": 1,
    "guidanceScale": 3,
    "outputQuality": 80,
    "extraLoraScale": 1,
    "promptStrength": 0.8,
    "approxMegapixels": "1",
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "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, replace the placeholder with your actual API key. The structure of the input JSON is tailored to the requirements of the Genmoji action, ensuring that the generated emoji meets your specifications.

Conclusion

The Genmoji Cognitive Actions provide an innovative way to create custom emojis, enhancing user engagement in applications. By leveraging these actions, developers can easily incorporate personalized imagery into their platforms. Explore various configurations, and consider experimenting with different parameters to achieve the best results for your use cases. Start creating unique emoji experiences today!