HTML to Image Quickstart

One of the core capabilities of Davix H2I is converting HTML content into images.

This allows you to generate visual assets such as social media images, reports, previews, and other rendered outputs directly from HTML using a simple API request. HTML rendering is one of the foundational capabilities of Davix H2I and remains one of the platform’s defining features.

All rendering is executed by the H2I engine (PixLab), and successful /v1/h2i image requests return a signed output URL in the response.

Step 1: Prepare Your HTML #

Create the HTML content you want to render.

Example HTML:

<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center">
Hello
</div>

This HTML is the render source that will be sent to the API. The public /v1/h2i endpoint accepts an html string as the required render input for image mode.

Step 2: Send the Request #

Use the public /v1/h2i endpoint and set action to image.

curl -sS -X POST "https://pixlab.davix.dev/v1/h2i" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Idempotency-Key: h2i-image-001" \
-H "Content-Type: application/json" \
-d '{
"action": "image",
"html": "<div style=\"width:100%;height:100%;display:flex;align-items:center;justify-content:center\">Hello</div>",
"css": "body{margin:0}",
"width": 1200,
"height": 1600,
"format": "jpeg"
}'

This is the full public HTML-to-image example documented for /v1/h2i. It includes the supported image-mode fields shown in the uploaded docs:

  • action
  • html
  • css
  • width
  • height
  • format
  • optional Idempotency-Key header.

Step 3: Receive the Result #

A successful request returns a 200 response with this shape:

{
"url": "https://pixlab.davix.dev/h2i/example-output.jpeg?exp=EXPIRES_AT&sig=SIGNATURE",
"request_id": "REQUEST_ID"
}

The public API reference defines the success output for /v1/h2i as:

  • 200: { url, request_id? }

Understanding the Result #

url #

The url field is the signed output URL for the generated image. For /v1/h2i, the output path is built under /h2i/<file>.

request_id #

The request_id field is the identifier attached to the request. It is useful for tracing and debugging. The platform propagates request IDs through response payloads.

What Happens Behind the Scenes #

When you send the request:

  1. the API key is validated
  2. the request body is validated
  3. the /v1/h2i route passes the render job to the H2I engine (PixLab)
  4. the HTML is rendered as an image
  5. Davix H2I returns the signed output URL in the response.

Example Workflow #

A common HTML-to-image workflow looks like this:

  1. your application generates HTML from dynamic data
  2. it sends that HTML to Davix H2I
  3. Davix H2I renders the image
  4. your system receives the signed image URL
  5. your application uses that image in its own workflow.

Common Use Cases #

HTML-to-image rendering is commonly used for:

  • social media images
  • previews and thumbnails
  • visual reports
  • automated marketing assets
  • template-based generated visuals.

Optional Next Steps #

The public /v1/h2i image mode also supports optional render controls such as:

  • css
  • width
  • height
  • format

More render options and response details are covered in the full API reference.

Summary #

To generate an image from HTML with Davix H2I:

  1. prepare your HTML
  2. send a POST request to /v1/h2i
  3. set action to image
  4. receive a signed output URL in the response.

All rendering is executed by the H2I engine (PixLab), which allows applications and workflows to generate images from HTML without managing their own rendering infrastructure.

Was it helpful ?
Scroll to Top