# CrewAI → 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/crewai.md

The `makespdf[crewai]` extra exposes two CrewAI `BaseTool`s over the
[makesPDF](https://makespdf.com/?ref=crewai) hosted API — markdown → PDF and
stored-template/inline-DSL → PDF. Both write a temp `.pdf` and return its path.

## Install

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

The CrewAI 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` |

`render_tool._run(template_id="invoice-classic")` renders the stored library
template; `_run(dsl=..., data_json='{"name": "Ada"}')` renders inline DSL. Both
return a temp `.pdf` path.

## Example

```python
from crewai import Agent
from makespdf import MakesPDFClient
from makespdf.integrations.demo import MARKDOWN_DEMO
from makespdf.integrations.crewai import get_crewai_tools

md_tool, render_tool = get_crewai_tools(MakesPDFClient())
agent = Agent(role="reporter", goal="ship PDFs", tools=[md_tool, render_tool])
print(md_tool._run(MARKDOWN_DEMO))  # markdown -> PDF path
```

`get_crewai_tools()` returns `[md_tool, render_tool]`, ready for a CrewAI
agent's `tools=` list. LangChain agents want the
[LangChain shim](https://makespdf.com/docs/integrations/langchain) instead; LlamaIndex
agents want the [LlamaIndex shim](https://makespdf.com/docs/integrations/llamaindex).

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