Create Stunning Images with Stable Diffusion 3.5 Large

In today's digital landscape, the ability to generate high-quality images from text prompts has become increasingly valuable across various industries. The Stable Diffusion 3.5 Large Cognitive Action allows developers to harness the power of advanced AI to create custom images tailored to specific needs. With this service, you can generate stunning visuals quickly and efficiently, saving time and resources while enhancing creativity.
Common use cases for this action include generating artwork for marketing campaigns, creating unique illustrations for blogs or social media, and developing concept art for games or films. Whether you're a designer looking for inspiration or a developer seeking to automate image generation, Stable Diffusion 3.5 Large provides a seamless solution to your image creation needs.
Prerequisites
To get started with Stable Diffusion 3.5 Large, you will need a Cognitive Actions API key and a basic understanding of making API calls. This will enable you to integrate the image generation capabilities into your applications effortlessly.
Generate Image with Stable Diffusion
The "Generate Image with Stable Diffusion" action is designed to create custom images based on textual prompts. By leveraging configurable parameters such as guidance scale, the number of denoising steps, and image dimensions, developers can fine-tune the output to achieve the desired quality and style.
Input Requirements
To use this action, you will need to provide the following input parameters:
- Prompt: A textual description of the desired image (e.g., "A man with hoodie on, illustration").
- Width: The width of the output image in pixels (default is 1024, range is 1 to 2048).
- Height: The height of the output image in pixels (default is 1024, range is 1 to 2048).
- Steps: The number of denoising steps to refine the image (default is 28, must be between 1 and 50).
- Guidance Scale: A scale factor for classifier-free guidance, affecting the output style (default is 4.5, range is 0 to 20).
- Negative Prompt: Optional text to specify elements to exclude from the generated content, helping to refine the output.
- Number of Images: The number of images to generate (default is 1, can be between 1 and 4).
Expected Output
The output will be a link to the generated image, which will meet the specifications provided in the input. For example, a successful call might return an image link similar to:
https://assets.cognitiveactions.com/invocations/5e1dcb0c-d2f5-49bc-ba84-0cd352383be6/4ba23a81-2c22-4a30-a9da-1aa76263dfb9.png
Use Cases for this Specific Action
This action is ideal for:
- Marketing Teams: Quickly generating visuals for promotional materials without needing a graphic designer.
- Content Creators: Producing unique illustrations for articles, enhancing engagement with custom images.
- Game Developers: Creating concept art or assets based on narrative descriptions, streamlining the development process.
- Artists: Experimenting with different styles and compositions based on textual ideas, allowing for creative exploration.
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 = "e67dd8fb-ffed-4529-9291-31f3c1de8f8f" # Action ID for: Generate Image with Stable Diffusion
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"steps": 28,
"width": 1024,
"height": 1024,
"prompt": "A man with hoodie on, illustration",
"guidanceScale": 4.5,
"numberOfImages": 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
The Stable Diffusion 3.5 Large Cognitive Action provides developers with a powerful tool to generate custom images from text prompts, offering flexibility and creativity in various applications. By integrating this action into your projects, you can enhance visual content production, streamline workflows, and unlock new creative possibilities. Explore the potential of image generation today and start transforming your ideas into stunning visuals!