SupermakerAIImageMaster
A robust Elixir library for seamless integration with the Supermaker AI Image API. Simplify image generation, manipulation, and retrieval within your Elixir applications.
Installation
Add supermaker_ai_image_master to your list of dependencies in mix.exs:
elixir
def deps do
[
{:supermaker_ai_image_master, "~> 0.1.0"} # Replace with the actual version] end
Then, run: bash mix deps.get
Usage Examples
Ensure you have configured your API key (consult Supermaker AI Image API documentation for details). The following examples demonstrate common usage patterns.
Example 1: Generating a simple image elixir alias SupermakerAIImageMaster
case SupermakerAIImageMaster.generate("A cat wearing a hat") do {:ok, image_url} ->
IO.puts("Image URL: #{image_url}")->
IO.puts("Error generating image: #{reason}")end
Example 2: Generating an image with specific dimensions and handling errors elixir alias SupermakerAIImageMaster
options = [width: 512, height: 512]
SupermakerAIImageMaster.generate("A futuristic cityscape", options) |> case do {:ok, image_url} ->
IO.puts("Image URL: #{image_url}")->
IO.puts("Invalid API key. Please configure your API key.")->
IO.puts("Error: #{reason}")end
Example 3: Asynchronously generating multiple images with different prompts elixir alias SupermakerAIImageMaster
prompts = ["A dog playing fetch", "A bird singing in a tree"]
prompts |> Enum.map(fn prompt -> Task.async(fn -> SupermakerAIImageMaster.generate(prompt) end) end) |> Enum.map(fn task -> Task.await(task) end) |> Enum.each(fn result -> case result do
{:ok, image_url} ->
IO.puts("Generated image: #{image_url}")
{:error, reason} ->
IO.puts("Error generating image: #{reason}")end end)
Example 4: Using pattern matching to handle different response types elixir alias SupermakerAIImageMaster
SupermakerAIImageMaster.generate("A portrait of a superhero") |> case do {:ok, %{url: image_url, size: image_size}} ->
IO.puts("Image URL: #{image_url}, Size: #{image_size}")->
IO.puts("Image URL: #{image_url}")} ->
IO.puts("API Error: #{error_message}")->
IO.puts("Error: #{reason}")end
Example 5: Piping operations for complex image generation scenarios elixir alias SupermakerAIImageMaster
"A majestic lion in the savanna" |> SupermakerAIImageMaster.generate([width: 768, height: 512]) |> case do {:ok, image_url} ->
IO.puts("Image URL: #{image_url}")
# Further processing with the image_url (e.g., storing it)->
IO.puts("Error generating image: #{reason}")end
Feature Summary
- Simple and intuitive API for image generation.
- Asynchronous operations for non-blocking execution.
- Comprehensive error handling with descriptive error messages.
- Flexible options for customizing image generation.
- Well-defined data structures for easy integration.
- Built with Elixir best practices for reliability and performance.
License
MIT
This package is part of the supermaker-ai-image-master ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/image/