Prerequisites
- A refile API key (available from your refile dashboard)
- Node.js project with LangChain.js installed
- Basic familiarity with LangChain.js usage patterns
Quick Start
- Install the dependencies:
- Copy the refile tool code and use it with LangChain:
- Replace
<token>
with your refile API key and start generating PDFs!
How It Works
The integration follows these steps:- Create the tool: The
createRefileTool
function creates a LangChain-compatible tool that connects to the Refile API - Bind the tool to the model: Use LangChain’s
bindTools
method to give the model access to the PDF generation capability - Process tool calls: When the model decides to generate a PDF, it makes a tool call which your code executes
- Return results: The final result includes the URL of the generated PDF
Customization Options
Want a different look? Just change these parameters when callingcreateRefileTool()
: