Skip to main content

Ruby SDK

The official Pictify SDK for Ruby provides an idiomatic Ruby interface for the Pictify API — generate images, PDFs, and GIFs from raw HTML, live URLs, and reusable templates.

Installation

Add to your Gemfile:
Then run:
Or install directly:

Quick Start

Configuration

The client is constructed with a keyword api_key. Every request is sent with an Authorization: Bearer <API_KEY> header.
Keep your API key secret. Read it from an environment variable (e.g. ENV["PICTIFY_API_KEY"]) and never expose it in client-side code or public repositories.

Rendering Images

From HTML — POST /image

Returns an ImageResult with url, id, and created_at.
The /image endpoint accepts a single html field, so any css you pass is injected into a <style> tag prepended to the HTML.

From a live URL (screenshot) — POST /image

Rendering Templates

Single render — POST /templates/:uid/render

Returns a RenderResult results array (one item per rendered layout). result.url is a convenience accessor for the first result’s URL.
You can also render a single named variant via render(..., layout: "square").

Multiple layout variants — POST /templates/:uid/render

Templates can have multiple layout variants (e.g. landscape, square, story) created via AI Resize in the Pictify editor. Render several in one call (max 20); layouts that fail land in errors.

Rendering GIFs — POST /gif

Provide exactly one source: html, url, or template_id (+ optional variables). The source must contain motion (CSS animation, etc.). The { gif: {...} } envelope is flattened to a GifRenderResult.
Static content produces no frames and returns a render error (HTTP 422).

Batch Rendering (async) — POST /templates/:uid/batch-render

Batch rendering is asynchronous. Submitting returns a batch_id immediately (HTTP 202); poll get_batch_results to track progress.
The poll endpoint reports per-item index, success, and variables but not rendered URLs — URLs are delivered via the render.completed webhook.

Template Management

Error Handling

Only 5xx responses and network failures are retried (with exponential backoff); 4xx responses (including 429) are never retried.

Framework Example — Rails

API Reference

See the API Reference for full endpoint documentation.