https://github.com/0xcryptoangel/llm-pdf-extraction
This project provides an API for uploading PDF documents and extracting structured summaries using either OpenAI's GPT-4o or Anthropic's Claude models. It is optimized for environmental and agricultural reports, transforming unstructured PDF content into structured JSON for downstream use.
https://github.com/0xcryptoangel/llm-pdf-extraction
bun claude-api llm-agent machine-learning nodejs openai-chatgpt react tailwindcss typescript
Last synced: 11 months ago
JSON representation
This project provides an API for uploading PDF documents and extracting structured summaries using either OpenAI's GPT-4o or Anthropic's Claude models. It is optimized for environmental and agricultural reports, transforming unstructured PDF content into structured JSON for downstream use.
- Host: GitHub
- URL: https://github.com/0xcryptoangel/llm-pdf-extraction
- Owner: 0xCryptoAngel
- Created: 2025-07-30T00:54:10.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-30T01:10:56.000Z (12 months ago)
- Last Synced: 2025-07-30T03:46:01.681Z (12 months ago)
- Topics: bun, claude-api, llm-agent, machine-learning, nodejs, openai-chatgpt, react, tailwindcss, typescript
- Language: TypeScript
- Homepage:
- Size: 66.4 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PDF Summary Extraction API
This project provides an API for uploading PDF documents and extracting structured summaries using either OpenAI's GPT-4o or Anthropic's Claude models. It is optimized for environmental and agricultural reports, transforming unstructured PDF content into structured JSON for downstream use.
---
## ๐ ๏ธ Tech Stack
- **Framework**: Node.js with Express
- **PDF Parsing**: `pdf-parse`
- **LLM Integration**: OpenAI GPT-4o and Claude Opus 4
- **Storage**: In-memory via Multer
- **Language**: TypeScript
---
## ๐ Features
- Upload a PDF and extract structured data in a single API call
- Choose between OpenAI or Claude as LLM provider
- Validates and cleans JSON response for consistent schema
- Returns fallback empty structure in case of model or parsing failure
---
## ๐ฆ Setup Instructions
1. **Clone the Repository**
```bash
git clone https://github.com/your-org/pdf-extractor.git
cd pdf-extractor
```
2. **Install Dependencies**
```bash
npm install
```
3. **Environment Configuration**
Create a `.env` file:
```
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_claude_key
```
4. **Run the Server**
```bash
npm run dev
```
---
## ๐งช API Usage
### POST `/upload`
Upload a PDF and extract a summary:
#### Form Data:
- `file`: PDF file (multipart/form-data)
#### Optional Query:
- `provider`: `openai` (default) or `claude`
#### Example with cURL:
```bash
curl -X POST http://localhost:3000/upload?provider=claude -F "file=@./sample.pdf"
```
---
## ๐ Folder Structure
```
โโโ routes/
โ โโโ upload.ts โ Express route for file upload
โโโ services/
โ โโโ pdfService.ts โ PDF parsing logic
โ โโโ llmService.ts โ LLM integration (OpenAI & Claude)
โโโ utils/
โ โโโ types.ts โ ExtractedReport interface
โ โโโ constants.ts โ Prompt templates
โโโ .env
โโโ README.md
```