For AI agents: a documentation index is available at /llms.txt — every docs page also has a markdown twin (append .md to the page URL).
LangChain → PDF with makesPDF
The makespdf[langchain] extra exposes the makesPDF hosted API as two LangChain tools: makespdf_render_md for Markdown and makespdf_render for a stored template or inline DSL. Both write a temporary .pdf and return its path.
Install
pip install "makespdf[langchain]"
export MAKESPDF_API_KEY=... # mint at https://makespdf.com/settings/api-keys?ref=langchainThe LangChain import happens inside the factory, so import makespdf never imports a framework. A missing extra raises ImportError naming the pip extra.
The two tools
| Tool | Endpoint | Arguments |
|---|---|---|
| makespdf_render_md | POST /api/v1/md | markdown |
| makespdf_render | POST /api/v1/render | template_id or dsl, plus data_json |
data_json is a JSON object string for {{vars}} — here {"name": "Ada"} overrides the script’s sampleData. Pass template_id="invoice-classic" instead of dsl to render the stored library template. Both tools return the path of a temp .pdf.
Example
from makespdf import MakesPDFClient
from makespdf.integrations.demo import MARKDOWN_DEMO, DSL_DEMO, DATA_DEMO
from makespdf.integrations.langchain import get_langchain_tools
tools = get_langchain_tools(MakesPDFClient()) # [makespdf_render_md, makespdf_render]
print(tools[0].invoke({"markdown": MARKDOWN_DEMO})) # markdown -> PDF path
print(tools[1].invoke({"dsl": DSL_DEMO, "data_json": '{"name": "Ada"}'})) # DSL -> PDF pathget_langchain_tools() takes an optional MakesPDFClient (a key from the environment is the default) and returns [makespdf_render_md, makespdf_render]. LangGraph agents consume the same tools directly — see the LangGraph guide.
Demo data
Every framework page here renders the same shared demo values, defined once in makespdf.integrations.demo, so the examples stay directly comparable:
MARKDOWN_DEMO = "# Invoice INV-2026-001\n\nHello **Ada** — total **$7,095.00**.\n"
DSL_DEMO = (
'const template = doc({ size: "A4" }, page(col(s("Hello {{name}}"))));\n'
'const sampleData = { name: "World" };\n'
)
DATA_DEMO = {"name": "Ada"}
TEMPLATE_ID_DEMO = "invoice-classic"Billing and limits
Billing matches the underlying endpoint: both /md and /render cost 1 credit per 10 pages on success, and every failure path deducts zero. Markdown input is capped at 200KB of text — inline data: images are excluded from that budget, the request body is capped at 15MB — and inline DSL at 512KB. Rate limit: 10,000 renders/hour per caller.