Create Stunning Images with Samm's AI-Powered Image Generation

25 Apr 2025
Create Stunning Images with Samm's AI-Powered Image Generation

In the world of digital content creation, visuals play a crucial role in capturing attention and communicating ideas effectively. Samm offers a powerful Cognitive Action that allows developers to generate images using advanced AI models. This action not only simplifies the image creation process but also provides flexibility with adjustable parameters such as resolution, aspect ratio, and image quality. By harnessing the capabilities of inpainting and image-to-image transformation, developers can create unique visuals tailored to their specific needs.

Common use cases for Samm's image generation include designing marketing materials, creating artwork for social media, generating visuals for websites, and even producing custom images for events. Whether you need a stunning backdrop for a presentation or a unique illustration for a blog post, this action empowers you to create high-quality images with ease.

Prerequisites

To get started with Samm, you'll need a Cognitive Actions API key and a basic understanding of making API calls.

Generate Image Using AI Models

The "Generate Image Using AI Models" action leverages the 'dev' and 'schnell' models for creating images through inpainting or image-to-image transformation. This action is designed to solve the problem of generating high-quality visuals quickly and efficiently, while allowing developers to customize various parameters for optimal results.

Input Requirements: To utilize this action, you must provide a prompt, which is a text description guiding the image generation. Additional optional parameters include:

  • image: URI of the input image for transformations.
  • mask: URI of an image mask for inpainting.
  • model: Choose between 'dev' or 'schnell' for inference.
  • width and height: Define custom dimensions for the image.
  • outputCount: Specify the number of images to generate (1-4).
  • imageQuality: Set the quality level of the output images (0-100).
  • guidanceLevel: Adjust the guidance scale for the diffusion process (0-10).
  • And more, including settings for LoRA intensity, aspect ratio, and image output format.

Expected Output: The output will be a URI link to the generated image(s), which can be used directly in your applications or shared with others.

Use Cases for this specific action:

  • Marketing Campaigns: Create eye-catching visuals for advertisements or social media posts that stand out and engage audiences.
  • E-commerce: Generate product images or lifestyle shots that enhance the online shopping experience.
  • Content Creation: Produce unique graphics for blogs, articles, or presentations that align with your brand's identity.
  • Art and Design: Experiment with creative concepts and generate artwork for portfolios or personal projects.
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 = "c0462113-cdc8-48ea-a6e4-1d1c2e101f73" # Action ID for: Generate Image Using AI Models

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "image": "https://replicate.delivery/pbxt/Mh2BNJlANPp0j2LucgM1ihcb12VwPZcZwgXIkS4qhHVEJnvh/replicate-prediction-3feeypmpg5rj40cnph4t6gwjbm.png",
  "model": "dev",
  "goFast": false,
  "prompt": "samm deslumbra en la alfombra roja con un majestuoso vestido azul vibrante de tul en capas, que combina volumen y elegancia a la perfección. El diseño strapless resalta sus hombros y escote, mientras que la falda de múltiples niveles añade dramatismo y sofisticación. Su largo cabello ondulado cae con naturalidad, enmarcando su rostro con una expresión serena y segura. Caminando con gracia sobre la alfombra roja, rodeada de fotógrafos y espectadores, samm irradia presencia, estilo y confianza en un evento de alto glamour.",
  "outputCount": 1,
  "imageQuality": 80,
  "guidanceLevel": 3,
  "loraIntensity": 1,
  "imageResolution": "1",
  "promptIntensity": 0.8,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "jpg",
  "inferenceStepsCount": 28,
  "additionalLoraIntensity": 1
}

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

Samm's image generation capabilities offer developers the tools to easily create stunning visuals tailored to their specific requirements. With features that allow for customization and flexibility, this action can be applied in various contexts, from marketing to creative projects. As you explore the possibilities of Samm, consider how these powerful image generation features can enhance your applications and engage your audience more effectively. Start integrating Samm’s Cognitive Actions today and unlock the potential of AI-driven image creation!