pdf_text_extraction
PDF Text Extraction
Extract selectable text from a PDF (pdf-parse). Optional useAI=true runs Gemini cleanup on the extracted text (not OCR).
Fields API: GET /v1/tools/pdf_text_extraction/fields · public GET /api/developer/tools/public/pdf_text_extraction/fields
Price: 50 API credits ($0.005) per successful_execution
Version: 1
Accepted types: application/pdf
Max file: 80 MB
Max pages: 250
Timeout: 120000 ms
Batch jobs: supported · max 10 files · job ≤ 200 MB · docs
This tool extracts selectable text via pdf-parse. It does not perform OCR on scanned pages. is_scanned may hint when little text was found.
Multipart fields
Normalized catalog for agents and UIs (same as the sandbox field picker). Send each name as a multipart form key with tool and file.
| Name | Type | Default | Notes |
|---|---|---|---|
| useAI | boolean | false | AI-related · When true, run Gemini text cleanup on extracted text (max 450k chars). No extra AI fields — send the PDF file. Billed via ai_pricing (API credits). |
Output schema
{
"text": "string",
"page_count": "number",
"is_scanned": "boolean",
"used_ai": "boolean",
"ai_text": "string|null"
}cURL
curl -X POST "$TOOLGRID_API_BASE/v1/execute" \
-H "Authorization: Bearer tg_api_YOUR_SECRET" \
-H "Idempotency-Key: YOUR_UNIQUE_KEY" \
-F "tool=pdf_text_extraction" \
-F "file=@document.pdf"Node.js (FormData)
Requires Node.js 18+ (global fetch/FormData/Blob). Set TOOLGRID_API_BASE and TOOLGRID_API_KEY.
import { readFile } from 'node:fs/promises';
import { randomUUID } from 'node:crypto';
const API_BASE = process.env.TOOLGRID_API_BASE || 'http://localhost:5000';
const API_KEY = process.env.TOOLGRID_API_KEY; // tg_api_… — never log this
if (!API_KEY) {
throw new Error('Set TOOLGRID_API_KEY');
}
const form = new FormData();
form.set('tool', 'pdf_text_extraction');
form.set('file', new Blob([await readFile('./document.pdf')]), 'document.pdf');
const res = await fetch(`${API_BASE}/v1/execute`, {
method: 'POST',
headers: {
Authorization: `Bearer ${API_KEY}`,
'Idempotency-Key': randomUUID(),
},
body: form,
});
const body = await res.json();
if (!res.ok || !body.success) {
console.error(body.error?.code, body.error?.message, body.request_id);
process.exit(1);
}
console.log('request_id', body.request_id);
console.log('billing', body.billing);
console.log('pages', body.result.page_count, 'scanned?', body.result.is_scanned);
console.log(body.result.text.slice(0, 500));