Create Stunning Images with the biguloff/sarmat-ttkv Cognitive Actions

23 Apr 2025
Create Stunning Images with the biguloff/sarmat-ttkv Cognitive Actions

In today's digital age, the ability to generate unique and captivating images through artificial intelligence has become essential for many developers. The biguloff/sarmat-ttkv spec provides a powerful set of Cognitive Actions designed to simplify the image creation process. Among these actions is the ability to generate custom inpainted images, leveraging advanced techniques like inpainting and custom models. This integration offers developers a chance to create visually striking images tailored to their specific needs.

Prerequisites

Before diving into the integration of these Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, typically obtained upon registration.
  • Familiarity with JSON format, as the input and output will be structured this way.

When making requests to the Cognitive Actions API, you will typically pass your API key in the headers for authentication.

Cognitive Actions Overview

Generate Custom Inpainted Image

Description:
This operation allows for detailed image generation utilizing inpainting and custom models to synthesize images based on specified prompts. It supports advanced controls such as image-to-image transformation, aspect ratio customization, and stepwise control for high-detail outcomes. Models 'dev' and 'schnell' provide options for varying processing speeds and precision.

Category: image-generation

Input

The input schema for this action requires the following fields:

  • prompt (required): Text prompt describing the desired output image.
  • aspectRatio (optional): Aspect ratio of the generated image (default is "1:1").
  • outputCount (optional): Number of images to generate per request (default is 1).
  • outputFormat (optional): File format for the output images (default is "webp").
  • guidanceScale (optional): Controls adherence to the prompt during generation (default is 3).
  • mainLoraScale (optional): Intensity of the main LoRA effect (default is 1).
  • outputQuality (optional): Quality setting for output images (default is 80).
  • inferenceModel (optional): Selects the model for the inference process (default is "dev").
  • inferenceStepCount (optional): Total number of denoising steps (default is 28).

Here’s an example of a valid input payload:

{
  "prompt": "A hyper-realistic portrait of a rugged masculine bodybuilder man, identified as ‘SRMT,’ with a tough, intense expression, standing in a gritty, urban setting.",
  "aspectRatio": "9:16",
  "outputCount": 4,
  "outputFormat": "png",
  "guidanceScale": 3.19,
  "mainLoraScale": -0.92,
  "outputQuality": 90,
  "inferenceModel": "dev",
  "inferenceStepCount": 28
}

Output

The output of this action will typically be a list of URLs pointing to the generated images. Here’s an example of the returned output:

[
  "https://assets.cognitiveactions.com/invocations/06be6484-7ee1-4fc1-980f-ca48cbac694a/ecdb9733-9070-41c9-865a-dd5ca5ef0845.png",
  "https://assets.cognitiveactions.com/invocations/06be6484-7ee1-4fc1-980f-ca48cbac694a/ad8f6ea1-5251-4a3d-baac-d495295df0ce.png",
  "https://assets.cognitiveactions.com/invocations/06be6484-7ee1-4fc1-980f-ca48cbac694a/7c66569b-51f3-4938-a86a-d33fa64a99ee.png",
  "https://assets.cognitiveactions.com/invocations/06be6484-7ee1-4fc1-980f-ca48cbac694a/479725f3-af84-4473-8ce1-b25c4f9a97a2.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Cognitive Actions execution endpoint for generating custom inpainted images:

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 = "b4891bd2-be3e-4ee2-9fb9-0b3bac016bd8" # Action ID for Generate Custom Inpainted Image

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "A hyper-realistic portrait of a rugged masculine bodybuilder man, identified as ‘SRMT,’ with a tough, intense expression, standing in a gritty, urban setting.",
    "aspectRatio": "9:16",
    "outputCount": 4,
    "outputFormat": "png",
    "guidanceScale": 3.19,
    "mainLoraScale": -0.92,
    "outputQuality": 90,
    "inferenceModel": "dev",
    "inferenceStepCount": 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 code, replace the placeholder API key and endpoint with your actual details. The input payload is structured according to the action's requirements, allowing for seamless integration into your applications.

Conclusion

The biguloff/sarmat-ttkv Cognitive Action for generating custom inpainted images empowers developers to create stunning, personalized visuals with ease. By utilizing the detailed input schema and understanding the output structure, you can effectively integrate this action into your applications. Explore the possibilities and enhance your projects with advanced image generation capabilities today!