# LangGraph → PDF with makesPDF

> For AI agents: a documentation index is available at https://makespdf.com/llms.txt — every docs page also has a markdown twin (append .md to the page URL), including this one: https://makespdf.com/docs/integrations/langgraph.md

LangGraph agents consume LangChain tools directly, so there is no separate
`makespdf[langgraph]` extra — reuse the
[LangChain shim](https://makespdf.com/docs/integrations/langchain). Both tools write a temp
`.pdf` and return its path.

## Install

```bash
pip install "makespdf[langchain]" langgraph
export MAKESPDF_API_KEY=... # mint at https://makespdf.com/settings/api-keys?ref=langgraph
```

LangGraph installs alongside the LangChain extra. The `MakesPDFClient` still
reads the key from the environment.

## 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` |

The agent picks `makespdf_render_md` for markdown and `makespdf_render` for
`template_id`/`dsl` renders (same shared demo data, same billing as the
[LangChain page](https://makespdf.com/docs/integrations/langchain)).

## Example

```python
from langgraph.prebuilt import create_react_agent
from makespdf import MakesPDFClient
from makespdf.integrations.demo import MARKDOWN_DEMO
from makespdf.integrations.langchain import get_langchain_tools

agent = create_react_agent("openai:gpt-4o-mini", get_langchain_tools(MakesPDFClient()))
print(agent.invoke({"messages": [f"Render this to PDF: {MARKDOWN_DEMO}"]}))
```

`create_react_agent` takes the model and the tool list; swap the model string
for any LangChain chat model. The tools are the same objects a plain LangChain
agent uses, so the tool-call arguments and return values are identical.

## Demo data

Every framework page here renders the same shared demo values, defined once in
`makespdf.integrations.demo`, so the examples stay directly comparable:

```python
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.
