Building Automated PDF Analysis Workflows with n8n and the free-ai API

FreeAnthropicKeyApi · Updated 2026-11-24 · 12 min read

Magnifying glass on a printed document
Analyzing text content in PDF reports

Automating the review of PDF reports is a common requirement for operations teams, yet it often involves manual downloading, reading, and summarizing. By connecting n8n with the free-ai API, you can create a robust pipeline that extracts key information, identifies follow-up actions, and structures the output without requiring a commercial account or API key.

The free-ai model is an independent open-weight model of about 35B parameters, fine-tuned to refuse far less than commercial assistants. It is not affiliated with Anthropic, meaning you get access to a capable reasoning engine without the baggage of proprietary ecosystems. This guide focuses on using the standard OpenAI-compatible endpoints to process documents directly within your n8n workflows.

We will cover how to handle PDF ingestion, send the text payload to the API, and structure the JSON response. While commercial models may offer superior reasoning or multimodal capabilities, free-ai provides a cost-effective, keyless solution for text-only extraction tasks. We will also look at common pitfalls, such as context limits and user-agent requirements, ensuring your workflow runs smoothly.

Frequently asked questions

What is the free-ai model?

free-ai is an independent open-weight model of about 35B parameters, fine-tuned to refuse far less than commercial assistants. It is not affiliated with Anthropic, meaning it operates independently. It supports standard OpenAI-compatible endpoints, making it easy to integrate into existing tools like n8n without needing a specific SDK.

How does free-ai differ from commercial API models?

Commercial models often have stricter content filters and require paid subscriptions with specific quotas. free-ai is free, keyless, and uses a different base URL. It does not offer multimodal capabilities like image or audio processing, and it lacks an SLA. However, it allows for larger context windows relative to its size and requires no account creation.

Which is better for PDF extraction: free-ai or commercial models?

For simple text extraction, free-ai is highly effective and cost-free. Commercial models may offer better reasoning for complex documents but come with costs and rate limits. If your primary goal is extracting structured data from text-based PDFs, free-ai provides a robust, zero-infrastructure solution that integrates seamlessly with n8n.

What is the context window for free-ai?

The context window is 32,000 tokens, and you can receive up to 16,000 tokens in the response. This is sufficient for most standard PDF reports. If your document exceeds this limit, you will need to implement chunking strategies within your n8n workflow before sending the request to the API.

Do I need an API key for the free-ai API?

No, the API is completely free and keyless. You can send requests directly to the base URL without generating or managing keys. This eliminates the need for secure storage of credentials in your n8n environment, simplifying the setup process significantly.

How do I handle rate limits in n8n?

The API allows 1 request per second with bursts of 3, and up to 2 parallel requests. If you exceed these limits, you will receive a 429 status code with a Retry-After header. You can implement retry logic in n8n using the HTTP Request node with exponential backoff to handle these transient errors gracefully.

What is the difference between /v1/chat/completions and /v1/completions?

The /v1/chat/completions endpoint is designed for conversational models and requires a messages array with roles. The /v1/completions endpoint is the legacy text completion format. For PDF analysis, chat completions are generally preferred as they allow for clearer instruction formatting and better handling of system prompts.

Can I use free-ai for multi-modal PDF analysis?

No, the API is text only. It does not support images, audio, or embeddings. If your PDF contains charts or images that require visual analysis, you will need to extract the text first or use a different tool. The model will only process the raw text content you provide in the request body.

Step by step

  1. Extract PDF Text — Use n8n's PDF node to convert the uploaded PDF into plain text. Ensure the text preserves structure and handles OCR if needed. This text will be the input for the API request.
  2. Construct Request — Create a JSON payload with the model name "free-ai", system prompt, and user message containing the extracted text. Set the correct headers, including the User-Agent.
  3. Send to API — Use the HTTP Request node to send the payload to https://api.freeanthropickeyapi.com/v1/chat/completions. Implement retry logic for 429 and 503 errors.
  4. Parse Response — Parse the JSON response to extract the generated text. Structure the data into a format suitable for your team, such as a list of action items.
  5. Send Results — Use the email or Slack node to send the structured results to your team. Include relevant context and ensure the message is clear and actionable.

Setting Up the n8n Environment

Before building the workflow, ensure you have n8n installed and running. You can use the docker image or the cloud version. The key advantage of using n8n for this task is its ability to chain multiple nodes together, allowing you to download PDFs, extract text, and send data to the API in a single, automated sequence.

Create a new workflow and add an HTTP Request node. This node will be the primary tool for interacting with the free-ai API. Since the API requires a normal User-Agent header to avoid 403 errors, you must configure this in the node settings. Python urllib's default user-agent is often blocked, so specify a standard browser-like user-agent string.

Configuring the HTTP Request Node

Set the method to POST and the URL to https://api.freeanthropickeyapi.com/v1/chat/completions. In the Headers section, add Content-Type: application/json and User-Agent: n8n-bot/1.0. This ensures the server recognizes your request as legitimate and processes it correctly without blocking.

Handling Authentication

Since no API key is required, you do not need to add an Authorization header. However, ensure that your n8n instance is correctly configured to handle JSON payloads. The request body will contain the model name, messages, and other parameters necessary for the extraction task.

Extracting Text from PDFs

The first step in the workflow is to ingest the PDF report. You can use n8n's built-in PDF nodes or integrate a library like PyPDF2 if you are using a custom code node. The goal is to convert the binary PDF data into plain text that can be sent to the API. This text will serve as the input for the extraction model.

Ensure that the text extraction preserves the structure of the document, such as headings and lists, as this helps the model understand the context. If the PDF is scanned, you may need to use OCR before passing the text to the API. The quality of the extracted text directly impacts the accuracy of the extraction results.

Using n8n PDF Nodes

n8n offers various nodes for PDF processing. Use the PDF Extract Text node to convert the uploaded file into a string. This string will be passed to the next node in the workflow. Ensure that the node is configured to handle large files, as exceeding the context limit will result in errors.

Handling OCR Scans

If your PDFs are scanned images, use an OCR node to convert the images to text. This adds an extra step but ensures that the content is readable by the API. The resulting text may contain formatting artifacts, so consider cleaning the text before sending it to the model.

Cloud server infrastructure
The API infrastructure handling requests

Constructing the API Request

With the text extracted, you need to construct the JSON payload for the API. The payload should include the model name "free-ai", the system prompt, and the user message containing the extracted text. The system prompt should instruct the model to extract specific information, such as recommendations or action items, from the text.

The user message should contain the actual text from the PDF. You can use n8n's expression language to insert the extracted text into the request body. Ensure that the text is properly escaped to avoid JSON parsing errors. The API will process the text and return a structured response containing the extracted information.

Defining the System Prompt

The system prompt sets the context for the model. Use it to specify the format of the output, such as JSON or a list of items. For example, instruct the model to extract all recommendations and format them as a JSON array. This ensures that the response is easily parsable by subsequent nodes in your workflow.

Including the Extracted Text

Insert the extracted text into the user message. If the text is large, ensure it fits within the 32,000 token context limit. You may need to truncate or summarize the text if it exceeds this limit. The API will process the text and return the extracted information in the response body.

Processing the API Response

The API returns a JSON object containing the model's response. You need to parse this response to extract the relevant information. The response will include the generated text, which you can then structure into a format suitable for your team. This might involve creating a list of action items or summarizing key points.

Use n8n's JSON node to parse the response and extract the specific fields you need. You can then pass this structured data to the next step in the workflow, such as sending an email or updating a database. Ensure that the parsing logic handles potential errors, such as missing fields or malformed JSON.

Parsing the JSON Response

Use n8n's JSON node to extract the relevant fields from the API response. The response will contain the generated text, which you can then parse to extract specific information. Ensure that the parsing logic is robust and handles potential errors, such as missing fields or malformed JSON.

Structuring the Data

Format the extracted information into a structured format, such as a JSON object or a list. This makes it easier to process in subsequent nodes. You can use n8n's code node to transform the data into the desired format. This structured data will be used for the final output, such as an email or a database update.

Workflow flowchart on whiteboard
Visualizing the n8n workflow steps

Handling Rate Limits and Errors

The API has rate limits of 1 request per second and 2 parallel requests. If you exceed these limits, you will receive a 429 status code. You can implement retry logic in n8n using the HTTP Request node's retry settings. Set the retry count to a reasonable number, such as 3, and use exponential backoff to avoid overwhelming the server.

Additionally, the API may return a 503 status code when it is busy. In this case, you should retry the request after a short delay. Implementing error handling in your workflow ensures that transient issues do not cause the entire process to fail. This is crucial for maintaining reliability in automated workflows.

Implementing Retry Logic

Configure the HTTP Request node to retry on 429 and 503 status codes. Use exponential backoff to increase the delay between retries. This prevents your workflow from failing due to temporary rate limits or server busy errors. Ensure that the retry logic is configured correctly to avoid infinite loops.

Handling 503 Errors

When a 503 error is returned, wait for a few seconds before retrying. The API may be temporarily busy due to high traffic. Implementing a delay in your retry logic helps to distribute the load and increases the likelihood of a successful request. This is particularly important during peak usage times.

Sending Results to Your Team

Once the data is structured, you can send it to your team via email. Use n8n's email node to compose and send the report. Include the extracted recommendations and any relevant context in the email body. This ensures that your team receives the information in a clear and actionable format.

You can also integrate with other tools, such as Slack or Microsoft Teams, to send notifications. This allows for real-time updates and ensures that your team is aware of any new findings. The flexibility of n8n allows you to choose the best communication channel for your needs.

Configuring the Email Node

Set up the email node with your SMTP credentials. Compose the email body using the structured data from the API response. Include any relevant attachments or links if needed. Ensure that the email is formatted correctly and contains all the necessary information for your team to take action.

Integrating with Slack

Use n8n's Slack node to send notifications to your team's channel. This provides a real-time update and ensures that your team is aware of any new findings. You can customize the message format to include key points and links to the full report. This enhances communication and collaboration within your team.

Envelope and laptop
Sending results via email

Optimizing for Performance

To optimize your workflow, consider using streaming responses if supported. This allows you to receive the response as it is generated, reducing latency. However, for PDF extraction, the full response is usually required, so streaming may not be necessary. Focus on minimizing the number of API calls by batching requests if possible.

Also, consider caching the extracted text if the same PDFs are processed frequently. This reduces the load on the API and improves response times. Use n8n's memory nodes to store frequently accessed data. This optimization is particularly useful for workflows that process a large volume of similar documents.

Using Streaming Responses

If the API supports streaming, enable it in your HTTP Request node. This allows you to receive the response as it is generated, reducing latency. However, for PDF extraction, the full response is usually required, so streaming may not be necessary. Focus on minimizing the number of API calls by batching requests if possible.

Caching Extracted Text

Use n8n's memory nodes to cache the extracted text for frequently processed PDFs. This reduces the load on the API and improves response times. Implement a caching strategy that balances memory usage with the need for up-to-date data. This optimization is particularly useful for workflows that process a large volume of similar documents.

Common Pitfalls and Solutions

One common pitfall is exceeding the context limit. If your PDF text is too long, the API will reject the request. Implement a chunking strategy to split the text into smaller segments. Send each segment to the API and combine the results. This ensures that the entire document is processed without hitting the token limit.

Another issue is incorrect User-Agent headers. As mentioned earlier, the API blocks requests with default user-agents like Python urllib. Ensure that your n8n workflow includes a proper User-Agent header. This small detail can prevent 403 errors and ensure smooth operation of your workflow.

Handling Context Limits

If the PDF text exceeds 32,000 tokens, implement a chunking strategy. Split the text into smaller segments and send them to the API separately. Combine the results in a subsequent node. This ensures that the entire document is processed without hitting the token limit. Consider using a sliding window approach for better context retention.

Fixing User-Agent Errors

Ensure that your n8n workflow includes a proper User-Agent header. The API blocks requests with default user-agents like Python urllib. Add a header with a standard browser-like user-agent string. This small detail can prevent 403 errors and ensure smooth operation of your workflow. Check the API documentation for any specific requirements.

Stack of books on shelf
Organized data and documentation
Try the free API

Paste this free endpoint into your coding assistant today.

Read also