Endpoint #
POST https://pixlab.davix.dev/v1/h2i
Action #
action=image
Description #
Renders HTML content as an image using the H2I engine (PixLab).
This action converts HTML layouts, templates, or dynamically generated markup into static image output. It is one of the core capabilities of Davix H2I and is suitable for workflows such as generated reports, social media graphics, previews, certificates, and other rendered visual assets.
Request Format #
Send the request as JSON.
The /v1/h2i route accepts JSON and URL-encoded bodies, but JSON is the recommended format for this action.
Parameters #
action #
Type: string
Required: Yes
Accepted value: image
Selects image output mode for the /v1/h2i route.
html #
Type: string
Required: Yes
The HTML content to render.
This is the required render source for the HTML-to-image flow. Missing html returns missing_field. Oversized HTML returns html_too_large.
css #
Type: string
Required: No
Default: empty string
Optional CSS string applied together with the HTML render request.
width #
Type: integer
Required: No
Default: 1000
Viewport width for rendering.
The route clamps width to the allowed render width range rather than rejecting oversized width values directly.
height #
Type: integer
Required: No
Default: 1500
Viewport height for rendering.
The route clamps height to the allowed render height range rather than rejecting oversized height values directly.
format #
Type: string
Required: No
Default: png
Controls the output image encoding.
The loaded public docs confirm PNG as the default, and that JPEG output is produced when the image format is explicitly set to JPEG.
Full cURL Example #
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": "<!doctype html><html><head><meta charset=\"utf-8\"><title>Report</title></head><body><div class=\"card\"><h1>Quarterly Report</h1><p>Generated with Davix H2I</p></div></body></html>",
"css": "html,body{margin:0;padding:0;background:#f5f7fb;font-family:Arial,sans-serif}.card{width:1000px;height:1500px;display:flex;flex-direction:column;align-items:center;justify-content:center;background:#ffffff;color:#111827}",
"width": 1000,
"height": 1500,
"format": "png"
}'
This matches the documented external /v1/h2i image request model: authenticated JSON body, optional idempotency header, and the verified HTML render fields for image mode.
Success Response #
Successful requests return HTTP 200.
Response body #
{
"url": "https://pixlab.davix.dev/h2i/<generated-file>?exp=<...>&sig=<...>",
"request_id": "<REQUEST_ID>"
}
urlpoints to the generated H2I image output.request_idmay be present and can be used for tracing, debugging, and support.
Generated H2I outputs are served from the public /h2i/* output path, and signed URL query parameters are used when signed output access is enabled.
Errors #
The loaded public docs support these common errors for /v1/h2i image rendering:
invalid_parametermissing_fieldhtml_too_large- pixel/render-size limit error for oversized render area
rate_limit_exceededrate_limit_store_unavailablemonthly_quota_exceededserver_busytimeouthtml_render_failed
Authentication and idempotency-related errors can also occur, including:
invalid_api_keykey_expiredapi_key_location_not_allowedinvalid_idempotency_key
The only point that needs caution is the exact code name for the oversized render-area failure: one loaded file names it render_size_exceeded, while another names it render_too_large. The source files are inconsistent on that single detail and should be reconciled before you publish the exact code string on this page.
Usage Notes #
action=imageis the image-render mode of/v1/h2i.htmlis required for this action. Missinghtmlreturnsmissing_field.- HTML size is limited. Oversized HTML returns
html_too_large. - Width and height are clamped to the configured render bounds.
- If the final render area exceeds the allowed pixel limit after width and height handling, the request fails with the route’s render-size limit error.
- The endpoint requires API key authentication. Both
X-Api-KeyandAuthorization: Bearer <key>are supported. Idempotency-KeyandX-Idempotency-Keyare optional and supported for safer retries and request correlation. Valid idempotency keys are echoed back in theIdempotency-Keyresponse header.
