How to Use the PDF.ai Extract API
Publish date
Sep 13, 2026
AI summary
The Extract API lets you send a JSON schema to /v2/extract to receive named fields, tables, or invoice lines as JSON with citations back to the source PDF; it can reuse a cached docId to avoid parse credits, charges credits based on page count and field count (≤5 fields uses 2 credits/page, >5 uses 4 credits/page), and requires an API key. Use it for automated data extraction when the next step is a structured database row, not for free‑form chat answers.
Language
People look up an Extract API when a PDF is not the final answer. They need named fields, tables, or invoice lines as JSON — with a schema, citations back to the page, and a
docId they can reuse.This page is the schema → fields path on the PDF.ai API v2 Extract endpoint. It does not replace the API Hub (keys and plan live there). It does not re-rank the head term pdf api. For the first-request path (key + first Parse), see How to Get Started with the PDF.ai API. For the browser extract job (not code), see Extract Data from PDF: Get Fields and Tables Out.
What Extract is for
After a clean Extract call on PDF.ai API v2, three things should be true:
- You sent a JSON schema that names the fields you want
- The response includes
data.resultshaped like that schema, plusdata.citationsthat point each field back to source segments
- You know whether parse credits applied (new
file/url) or you reused a cacheddocId
Docs: Extract. Playground (no article needed to try the shape): https://pdf.ai/extract.
Practical rule: Extract answers "give me these fields." Ask answers a free-form question. Parse turns the PDF into markdown/contents first. Use Extract when your next step is a database row, not a chat reply.
Browser extract vs Extract API
Path | Best when | What you get |
Web extract UI | One file, no code | Fields in the browser |
API POST /v2/extract | Automation, your product, batches | JSON ( result • citations) with an X-API-Key |
Credits before you scale a schema
From the live Extract and credit usage docs:
- Extraction credits: 2 credits × page count when the schema has ≤5 fields; 4 credits × page count when the schema has >5 fields
- Parse credits: apply when you send a
fileorurland there is no cached parse; 0 when you pass a cacheddocId
- Total: parse credits + extraction credits
Examples from the Extract docs:
- 10-page PDF, not cached, advanced parse quality, schema with 3 fields → parse 20 + extract 20 = 40 credits
- 5-page PDF, cached
docId, schema with 8 fields → parse 0 + extract 20 = 20 credits
API plan examples on credit usage:
- Free: $0/month for 200 credits/month, no credit card required
- Paid examples: $49 / 3,000, $99 / 10,000, $249 / 30,000, $599 / 100,000 credits per month
Generate the key and manage the plan on https://pdf.ai/developer. The docs say the key is shown only once when generated.
Practical rule: keep schemas ≤5 fields while you are proving the pipeline. Crossing 5 fields doubles extract credits per page.
How to call Extract
1. Have an API key
Open https://pdf.ai/developer, generate a key, store it as a secret. Send it as the
X-API-Key header on every call.2. Prefer a cached docId when you already parsed
If you already ran
POST https://pdf.ai/api/v2/parse, keep the docId. Passing that docId into Extract skips parse credits for that call.If you have not parsed yet, you can still send
file or url on Extract; parse credits will apply during that call, and the response returns a docId for later reuse.3. POST a schema
Endpoint from the docs:
POST https://pdf.ai/api/v2/extractContent type:
multipart/form-data.Required:
schema— JSON Schema string defining the structure to extract
Optional (from Extract):
system_prompt— default"Be precise and thorough."
docId, orurl, orfile
quality:standard(default) oradvanced
lang_list: languages for standard OCR (default["en"])
Example shape (Python), matching the docs sample:
import requests
import json
url = "https://pdf.ai/api/v2/extract"
headers = {"X-API-Key": "YOUR_API_KEY"}
schema = {
"type": "object",
"properties": {
"title": {"type": "string"},
"author": {"type": "string"}
},
"required": ["title"]
}
data = {
"docId": "your-document-id",
"schema": json.dumps(schema),
"system_prompt": "Extract document metadata accurately."
}
response = requests.post(url, headers=headers, data=data)
print(response.json())A successful response includes
success, data.result, data.citations (each with content, pageNumber, schemaLink), and docId.4. Check the output before you trust it
- Confirm
successand thatdata.resultkeys match your schema
- Open at least one
citations[].pageNumberin the source PDF and compare the citedcontentto the field value
- If you get
Invalid API key/No API key present, fix the header before you change the schema
- If fields are empty on a scanned PDF, parse first with
quality=standard(or setqualityon Extract when sendingfile/url) and retry with the returneddocId
Practical rule: a non-emptyresultobject is not a verified invoice. Read the citation for every field you will write to a database.
When Extract is the wrong tool
- You only need one chat answer in a browser. Use How to Chat with a PDF. No API key required for that job.
- You need a free-form answer in code. Use
POST https://pdf.ai/api/v2/askwith a priordocId(Ask). Ask is 3 credits × total page count across thedocIdsyou query.
- You only need searchable markdown / contents. Prefer Parse first (How to Get Started with the PDF.ai API).
- You wanted a generic “pdf api” category hub. Stay on https://pdf.ai/developer. This page is the Extract how-to, not a replacement hub.
A short action plan
- Open https://pdf.ai/developer, create a key, store it once.
- Check credit usage against page count and field count (≤5 vs >5).
- Parse a short PDF (or reuse a
docId), thenPOST https://pdf.ai/api/v2/extractwith a tight schema.
- Verify
data.resultagainstdata.citationsand the source PDF before you wire production.
Sibling guides: How to Get Started with the PDF.ai API, PDF OCR API: Run OCR from Your Code, How to Parse a PDF, Extract Data from PDF: Get Fields and Tables Out.
If you want the rest of the PDF workflow after the fields are clean, start at PDF.ai. Use the Extract API when the next step is your schema, not a single upload box.