canonical: https://jentic.com/apis/html2img.com/html2img

# Html2img HTML to Image API

The html2img HTML to Image API converts HTML and CSS, or any public URL, into a PNG image or a vector PDF rendered in headless Chrome, and returns a CDN URL for the result. You post your own markup to the html endpoint, capture a page you do not control through the screenshot endpoint, or fill a named template such as open-graph-image, invoice, event-ticket, or github-repo-card with a JSON payload. Each successful render costs one credit, requests return the finished URL synchronously or deliver it to a webhook_url for slower jobs, and paid-plan renders are hosted permanently.

## For AI agents

Render HTML and CSS or a public URL to a PNG or PDF, or fill a named template like an Open Graph card or invoice, and get back a CDN URL.

## Scope

Does not edit existing images, host arbitrary uploads, or scrape page data. Use for rendering HTML, URLs, and templates to PNG or PDF only.

## Capabilities

- Render your own HTML and CSS to a PNG or PDF at a chosen width, height, and dpi
- Capture a public URL as an image or PDF, optionally clipped to one element with selector
- Fill a named template such as open-graph-image, invoice, or certificate-of-completion from a JSON payload
- Wait for a selector or a ms_delay before rendering so late-loading content appears
- Receive the result asynchronously at a webhook_url instead of waiting on the request
- Check the calling key's account and credit balance without spending a credit

## Use cases

### Agent-generated share images

An AI agent publishing content needs a social card for each post without a designer. Through Jentic it finds the html2img template operation by intent, posts the post title and author to the open-graph-image template, and attaches the returned CDN URL to the post metadata, with the htim_ key held by your own instance.

Example prompt: Call POST `/v1/templates/{slug}` with slug set to open-graph-image and the post's title fields, then save the returned URL as the og:image

### Documents as images or PDFs

Apps that send receipts, tickets, or certificates as attachments can describe them in HTML. POST /html takes html and css with width, height, dpi, and format set to png or pdf, and scale_to_fit keeps fixed-size artwork whole on a PDF page.

Example prompt: Call POST /html with html set to the receipt markup, css set to the receipt styles, and format set to pdf, then email the returned URL

### Screenshots of external pages

Monitoring, archiving, or QA work needs pictures of pages you do not control. POST /screenshot takes a url with optional selector, fullpage, wait_for_selector, and ms_delay, and returns a CDN URL to the PNG or PDF.

Example prompt: Call POST /screenshot with url set to the competitor pricing page and fullpage true, then store the returned image URL

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/html` | Render HTML to a PNG or PDF |
| POST | `/screenshot` | Capture a public URL |
| POST | `/v1/templates/{slug}` | Render a named template |
| GET | `/me` | Account behind the key |

## Key resources

- **Rendering** — Render HTML and CSS, or capture a public URL, to a PNG or PDF
- **Templates** — Render a named template, such as Open Graph cards, invoices, and tickets, from a JSON payload
- **Account** — Read the account and credits behind a key, and a liveness ping

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 67 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 68 / 100
  - Developer Experience & Jentic Compatibility: 77 / 100
  - AI-Readiness & Agent Experience: 51 / 100
  - Agent Usability: 94 / 100
  - Security: 50 / 100
  - AI Discoverability: 95 / 100
- **View full report:** https://jentic.com/apis/html2img.com/html2img/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring html2img by hand means sending the htim_ key in the X-API-Key header, keeping it server-side because it spends credits, and choosing between synchronous renders and webhook_url delivery. Through Jentic you install once, import html2img from the API Directory, store the key once, and your agent calls it.
- **Permission scoping:** html2img puts the template slug in the URL path (`/v1/templates/{slug}`), so a rule can pin your agent to one template such as open-graph-image. You choose the operations it may call, so free-form HTML rendering or URL screenshots are not included unless you add them.
- **Credential handling:** Your html2img key is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'generate an og image' or 'html to pdf', and Jentic returns the matching html2img operation with its input schema so the agent sends valid html, url, or template fields without reading the reference docs.

## Related APIs

- **Urlbox** — Website screenshot and PDF rendering API
- **snaplab API** — Headless Chromium renders of URLs and HTML to images and PDFs
- **PDFMonkey** — Template-based PDF document generation
- **Cloudinary Upload API** — Upload and transform media assets

## FAQ

### What authentication does the HTML to Image API use?

Per its OpenAPI spec, html2img authenticates with an API key in the `X-API-Key` header, with keys prefixed htim_ and created in the html2img dashboard. GET /ping is declared without a security requirement, and GET /me lets you verify a key without spending a credit. Through Jentic the key is stored by your own instance and attached at call time.

### Which templates can I render with the HTML to Image API?

POST `/v1/templates/{slug}` takes a template slug such as open-graph-image, invoice, event-ticket, code-screenshot, github-repo-card, or certificate-of-completion, with the full list and each template's fields documented by html2img. Fields a template does not recognise are rejected with a 422, and an unknown slug returns 404 template_not_found.

### What are the rate limits for the HTML to Image API?

The spec states there is no rate-limit response: usage is metered in credits, one per successful render whether PNG or PDF, and running out returns 402 with your balance. Synchronous requests have a time budget, so pass webhook_url for slower renders.

### Is there an html2img MCP server?

The spec notes that html2img offers its render capabilities over MCP on paid plans, using the same key. You do not need it to give your agent html2img: Jentic connects the REST API directly from the API Directory, so your agent discovers the render, screenshot, and template operations on demand without loading another server's tool definitions into its context.

### How do I render HTML to an image through Jentic?

Search Jentic for 'convert html to an image', load POST /html, and send html with optional css, width, height, and format set to png. Your instance attaches the X-API-Key at call time and the response carries the CDN URL. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### Can I limit what my agent is allowed to do with the HTML to Image API?

Yes. Write a rule that allows only POST `/v1/templates/{slug}` and GET /me, and the agent can fill templates and check its credit balance but cannot render arbitrary HTML or screenshot URLs, and every call it makes is logged.
