Create Stunning Oil Pastel Style Images with AI

26 Apr 2025
Create Stunning Oil Pastel Style Images with AI

Creating visually appealing images in the style of oil pastels has never been easier, thanks to the Oilpastel Style Image Generation Cognitive Action. This powerful tool enables developers to generate unique, artistic images by leveraging customizable prompts and various parameters. Whether you are looking to enhance your digital art, create content for social media, or bring your creative visions to life, this API provides a fast and efficient way to achieve stunning results.

The Oilpastel Style Image Generation action allows you to specify details such as image dimensions, aspect ratios, and even the quality of the output. By using different models optimized for speed and quality, developers can tailor the image generation process to their needs. Common use cases include creating promotional materials, designing unique illustrations for stories, or simply experimenting with artistic styles to inspire new ideas.

Prerequisites

Before diving into the API, ensure you have an API key for Cognitive Actions and a basic understanding of making API calls.

Generate Oil Pastel Style Image

The main action of this service is to generate images that mimic the look and feel of oil pastels. This action is particularly beneficial for artists and content creators who want to produce high-quality artwork without the need for extensive manual effort.

Purpose

The "Generate Oil Pastel Style Image" action solves the problem of creating artistic images quickly and easily. It allows for both image-to-image transformations and inpainting, giving you flexibility in how you use your existing images.

Input Requirements

The input schema requires a prompt that describes the desired image. Additional parameters include:

  • mask: For inpainting mode, providing an image mask.
  • seed: A random seed for reproducible results.
  • image: An input image for transformation.
  • model: Choose between the 'dev' or 'schnell' models.
  • width & height: Specify dimensions if using a custom aspect ratio.
  • imageAspectRatio: Select from predefined ratios or set a custom one.
  • numberOfOutputs: How many images to generate.
  • outputMegapixels: Approximate megapixels of the output.
  • imageOutputFormat: Format of the generated image (webp, jpg, png).
  • isFastModeEnabled: Toggle for faster predictions.
  • imageOutputQuality: Set the quality level of the output images.

Example Input

{
  "model": "dev",
  "prompt": "In the style of OILPASTEL, A frog wearing a top hat",
  "loraWeightScale": 1,
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "outputMegapixels": "1",
  "imageOutputFormat": "webp",
  "isFastModeEnabled": false,
  "imageOutputQuality": 80,
  "imagePromptStrength": 0.8,
  "diffusionGuidanceScale": 3,
  "numberOfInferenceSteps": 28,
  "additionalLoraWeightScale": 1
}

Expected Output

The output will be a generated image in the specified format, resembling an oil pastel artwork based on the provided prompt. For example:

  • https://assets.cognitiveactions.com/invocations/ed273f7e-c4a8-453f-a3c6-b0003665bd42/978e1dfe-2c0c-4c18-9bf1-8789c64333d0.webp

Use Cases for this Action

  • Artistic Creation: Artists can utilize this action to create unique pieces of digital art that replicate traditional oil pastel techniques.
  • Social Media Content: Marketers can generate eye-catching visuals for social media campaigns to engage their audience.
  • Story Illustration: Authors and storytellers can produce illustrations for their narratives, enhancing the visual appeal of their work.
  • Creative Experimentation: Developers and designers can explore different styles and prompts to inspire new creative directions.

```python
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 = "40257576-141e-47fd-92f9-97208b02938e" # Action ID for: Generate Oil Pastel Style Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "dev",
  "prompt": "In the style of OILPASTEL, A frog wearing a top hat",
  "loraWeightScale": 1,
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "outputMegapixels": "1",
  "imageOutputFormat": "webp",
  "isFastModeEnabled": false,
  "imageOutputQuality": 80,
  "imagePromptStrength": 0.8,
  "diffusionGuidanceScale": 3,
  "numberOfInferenceSteps": 28,
  "additionalLoraWeightScale": 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 Oilpastel Style Image Generation Cognitive Action provides a versatile and efficient solution for creating stunning, artistic images. With its customizable features and fast processing capabilities, developers can easily integrate this action into their applications to enhance creativity and visual storytelling. As you explore the potential of this API, consider how you can incorporate it into your projects, whether for personal use or commercial applications. Start generating your oil pastel masterpieces today!