Aigifmaker (aigifmaker v0.1.0)

Copy Markdown View Source

Official Elixir SDK for AI GIF Maker: turn text into animated GIFs.

{:ok, url} = Aigifmaker.generate("a corgi in sunglasses dancing on a beach")
{:ok, left} = Aigifmaker.credits()

Pass api_key: or set AIGIFMAKER_API_KEY; create a key at https://aigifmaker.ai/settings/apikeys. Each GIF costs 1 credit on your AI GIF Maker account, the same as on the website.

Failures are {:error, reason, message} where reason is :auth, :quota, :rejected, :failed, :timeout or :other.

Options for every call: :api_key, :base_url ("https://aigifmaker.ai"), :timeout (milliseconds generate/2 and wait/2 keep polling, 15 minutes), :poll_ms (3000).

Uses only :httpc from OTP and the standard JSON module; no dependencies.

Summary

Functions

Remaining credits on the account. Free to call.

Generates one animated GIF and returns its URL.

Returns the task record: a map with "id", "status" ("pending", "processing", "success" or "failed"), "images" (the GIF URL first, once it succeeds) and, while an account without purchased credits waits its turn, "queued" => true.

Starts one GIF and returns its task id without waiting.

Turns a response envelope into {:ok, data} or the error that says what to do next. Every response is HTTP 200; the JSON code tells success from refusal.

Polls a task every 3 seconds until it finishes and returns the GIF URL.

Types

error()

@type error() :: {:error, reason(), String.t()}

reason()

@type reason() :: :auth | :quota | :rejected | :failed | :timeout | :other

Functions

credits(opts \\ [])

@spec credits(keyword()) :: {:ok, integer()} | error()

Remaining credits on the account. Free to call.

generate(prompt, opts \\ [])

@spec generate(String.t(), keyword()) :: {:ok, String.t()} | error()

Generates one animated GIF and returns its URL.

status(task_id, opts \\ [])

@spec status(String.t(), keyword()) :: {:ok, map()} | error()

Returns the task record: a map with "id", "status" ("pending", "processing", "success" or "failed"), "images" (the GIF URL first, once it succeeds) and, while an account without purchased credits waits its turn, "queued" => true.

submit(prompt, opts \\ [])

@spec submit(String.t(), keyword()) :: {:ok, String.t()} | error()

Starts one GIF and returns its task id without waiting.

unwrap(http_status, env)

@spec unwrap(integer(), term()) :: {:ok, map()} | error()

Turns a response envelope into {:ok, data} or the error that says what to do next. Every response is HTTP 200; the JSON code tells success from refusal.

wait(task_id, opts \\ [])

@spec wait(String.t(), keyword()) :: {:ok, String.t()} | error()

Polls a task every 3 seconds until it finishes and returns the GIF URL.