Enhance Your Applications with Image Generation: A Guide to the biggpt1/prospekt-mira-new-year Cognitive Actions

22 Apr 2025
Enhance Your Applications with Image Generation: A Guide to the biggpt1/prospekt-mira-new-year Cognitive Actions

In the world of AI and machine learning, generating images using advanced techniques has become increasingly accessible and powerful. The biggpt1/prospekt-mira-new-year API offers a set of Cognitive Actions that allow developers to generate images with inpainting capabilities. These pre-built actions simplify the process of creating customized visual content by providing a range of options for dimensions, quality, and style.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Familiarity with making HTTP requests.
  • Basic knowledge of JSON structure for constructing input payloads.

Authentication for the API generally involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Image with Inpainting

Description: This action enables developers to create images using inpainting techniques, allowing for the filling of masked areas or applying transformations. You can also perform image-to-image conversion with various customization options.

Category: Image Generation

Input

The input for this action is structured as follows:

{
  "prompt": "string (required)",
  "mask": "string (optional, uri)",
  "seed": "integer (optional)",
  "image": "string (optional, uri)",
  "model": "string (optional, enum: [dev, schnell])",
  "width": "integer (optional, 256-1440)",
  "height": "integer (optional, 256-1440)",
  "megapixels": "string (optional, enum: [1, 0.25])",
  "aspectRatio": "string (optional, enum: [1:1, 16:9, custom])",
  "outputCount": "integer (optional, 1-4)",
  "outputFormat": "string (optional, enum: [webp, jpg, png])",
  "guidanceScale": "number (optional, 0-10)",
  "outputQuality": "integer (optional, 0-100)",
  "enableFastMode": "boolean (optional)",
  "promptStrength": "number (optional, 0-1)",
  "primaryLoraScale": "number (optional, -1-3)",
  "additionalLoraScale": "number (optional, -1-3)",
  "denoisingStepsCount": "integer (optional, 1-50)",
  "turnOffSafetyChecker": "boolean (optional)",
  "additionalLoraWeights": "string (optional)"
}

Example Input:

{
  "model": "dev",
  "prompt": "tesla cybertruck in ossetian metallic  colors - white red and yellow, TOK at background,",
  "megapixels": "1",
  "aspectRatio": "1:1",
  "outputCount": 3,
  "outputFormat": "png",
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "primaryLoraScale": 1,
  "additionalLoraScale": 1,
  "denoisingStepsCount": 28
}

Output

The output typically includes URLs to the generated images. Here's an example of the output you can expect:

[
  "https://assets.cognitiveactions.com/invocations/ebf08b15-3e18-4385-8aa6-e3328d0184e6/5fe7f1a8-d7df-4111-985c-9d260b8c6f1b.png",
  "https://assets.cognitiveactions.com/invocations/ebf08b15-3e18-4385-8aa6-e3328d0184e6/5dc745f6-0865-493b-b66f-51cf5553579f.png",
  "https://assets.cognitiveactions.com/invocations/ebf08b15-3e18-4385-8aa6-e3328d0184e6/a8f6c4ca-679e-4657-ba83-80dc014726d0.png"
]

Conceptual Usage Example (Python)

Here’s how a developer might call the hypothetical Cognitive Actions execution endpoint 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 = "51e7d552-0a07-415f-829a-fefa9f2d1752"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "tesla cybertruck in ossetian metallic colors - white red and yellow, TOK at background,",
    "megapixels": "1",
    "aspectRatio": "1:1",
    "outputCount": 3,
    "outputFormat": "png",
    "guidanceScale": 3,
    "outputQuality": 80,
    "enableFastMode": False,
    "promptStrength": 0.8,
    "primaryLoraScale": 1,
    "additionalLoraScale": 1,
    "denoisingStepsCount": 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 snippet, you replace the placeholder for the API key and endpoint with your actual details. The action ID and input payload are structured according to the specifications, allowing seamless integration with the API.

Conclusion

The biggpt1/prospekt-mira-new-year Cognitive Actions provide a robust and flexible way to integrate advanced image generation capabilities into your applications. By leveraging the Generate Image with Inpainting action, developers can create unique visual content tailored to their specific needs. As you explore these actions, consider how they can enhance user experiences and streamline your development processes. Happy coding!