Expand AI logo
DocsDocs
Glow Active
API Reference
Login

Documentation

Get Started

OverviewMCP ServerQuickstartWhy ExpandWays to Use Expand

Fetch

OverviewHow Fetch WorksOutput ModelProgressive DisclosureInclude OptionsDocumentsYouTubeBrowser BehaviorHighlightsPlayground & ReplayBatched Fetch

Reference

MCP Tools & ResourcesCLI, Skill & HooksCLI CommandsAPI ReferenceTypeScript SDK

Account & Billing

Pricing & UsageTiersFAQ

Machine-Readable Docs

start.mdllms.txtllms-full.txtDocs as Markdown
Browse docs

Get Started

OverviewMCP ServerQuickstartWhy ExpandWays to Use Expand

Fetch

OverviewHow Fetch WorksOutput ModelProgressive DisclosureInclude OptionsDocumentsYouTubeBrowser BehaviorHighlightsPlayground & ReplayBatched Fetch

Reference

MCP Tools & ResourcesCLI, Skill & HooksCLI CommandsAPI ReferenceTypeScript SDK

Account & Billing

Pricing & UsageTiersFAQ

Machine-Readable Docs

start.mdllms.txtllms-full.txtDocs as Markdown

Documents

Fetch PDFs, images, office files, ebooks, and audio, and get the same agent-ready Markdown back.

Not every URL an agent follows is a web page. Research trails end in PDFs, data links end in spreadsheets, and a citation chain will happily drop you on a scanned report.

Fetch converts those URLs on the endpoint you already call and returns the same Markdown. There is nothing to turn on. POST /v1/fetch decides for itself whether a URL is a page to render or a document to convert.

curl https://api.expand.ai/v1/fetch \
  -H "x-expand-api-key: $EXPAND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://arxiv.org/pdf/1706.03762"}'

What Fetch converts

FamilyFormatsHow it convertsMetered
PDF.pdfText layer first. Pages with no usable text go to a vision model.Pages, plus vision-model pages when there is no text layer.
Images.png, .jpg, .jpeg, , , , , ,

Everything else, including HTML and SVG, is rendered in a browser and captured as a page. See Browser Behavior.

One more kind of URL is not a page: a YouTube video, which comes back as its transcript. See YouTube.

URLs without an extension

The extension is only a hint. Fetch looks at what the origin actually serves, so https://arxiv.org/pdf/1706.03762 converts as a PDF even though the URL has no extension, and a .pdf URL that really serves a web page is captured as a page. A spreadsheet served as application/octet-stream still converts.

One exception: a URL with no recognizable extension that serves text/plain is captured as a rendered page. Give it a .txt or .md extension, or serve text/markdown, to get the text back verbatim.

What comes back

The response shape is the one you already handle. A converted document fills markdown and adds a reference to the original file:

Use POST /v1/fetch/json for structured metadata and the original-file link. POST /v1/fetch returns the converted Markdown directly.

{
  "meta": {
    "version": 1,
    "url": "https://arxiv.org/pdf/1706.03762",
    "capturedAt": "2026-09-01T00:00:00.000Z",
    "snapshotId": "0f9c3a1e-...",
    "contentType": 











FieldMeaning
markdownThe complete converted document.
meta.contentTypeThe detected content type, which can differ from the origin's header.
data.document.urlA presigned link to the stored original file.
data.document.sizeBytes

The playground previews a document when you fetch it there. A document's snapshot identity does not provide a public browser replay; use data.document.url to share its original file.

State JSON, Appendix, screenshots, and links exist only because a browser rendered something, so a document fetch has none of them. Asking for them does not fail the request. The fields are simply absent.

Conversion limits

documentConfig controls conversion and lets you set a page limit. Every field is optional. When you omit maxPages, Fetch converts the entire PDF and bills the pages it delivers.

FieldTypeDefaultRangeWhat it does
maxPagesintegerNo limitPositive integerOptional limit on the number of pages to convert.
maxAudioSecondsinteger

auto keeps readable text from each page and sends pages with missing or unreliable text to OCR. OCR runs in batches, and the result keeps the original page order.

never blocks the vision model outright. It is the cheapest and most predictable setting, and it is also the one that returns an empty document for a scanned PDF and nothing at all for an image, since an image has no text layer to fall back on.

always reads every page with the model even where a text layer exists.

curl https://api.expand.ai/v1/fetch \
  -H "x-expand-api-key: $EXPAND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.irs.gov/pub/irs-pdf/fw4.pdf",
    "documentConfig": { "maxPages": 10, "ocr": "never" }
  }'

Exceed one of these limits and Fetch refuses the request with 413 instead of truncating it. A half-converted document is worse than a clear error, because nothing in the Markdown tells you where it stopped. Refusals cost you no credits.

PDFs have no default page limit or public 50 MB transfer cap. Large PDFs are processed in batches, so the length of the original document does not need to fit one OCR request. Document processing can run for up to 55 minutes once a worker starts. Queue waits use the shorter 150-second capacity budget. Set your HTTP client timeout to allow a long conversion to finish.

Worker resource protection still applies. Resource exhaustion is a processing failure, not a 413 page-limit refusal. Image and audio conversion also depend on their providers' limits.

Pricing

Converting a document costs credits on top of the one-credit Fetch. 1,000 credits cost $1.

UnitCreditsWhen it applies
Converted page1 per pageEvery page a document fetch converts. An image counts as one page.
Vision-model page5 per page, in addition to the pageA page read by a vision model instead of a text layer.
Audio per minute

Office files, ebooks, CSV, TSV, JSON, XML, and text convert locally and add nothing. Those fetches cost the flat one credit.

A 12-page PDF with a good text layer costs 1 + 12 = 13 credits. The same document scanned, with no text layer, costs 1 + 12 + 12 × 5 = 73 credits. That gap is the reason ocr and maxPages exist. See Pricing & Usage.

Batched Fetch reports the units each item spent as data.usage, which you can price with the table above:

{ "documentPages": 12, "ocrPages": 0, "audioSeconds": 0 }

Errors

Document fetches report these outcomes:

_tagCodeMeaning
FetchUnsupportedContentType415Nothing here can be converted. An unknown format, or a file too damaged to read.
FetchOriginHttpError404, 410, or 502Missing or removed documents return or ; other origin refusals return . carries its status, and the request is refunded.

An upcoming response will report document refusals as 200 FetchOriginError with contentAvailable: false, originStatusCode, and a retryable verdict. Support both shapes during the transition. See Error Handling.

An over-limit document returns 413 FetchPageTooLarge, the same error an oversized page returns. The Errors reference has the full list and the payload shapes.

A document fetch reports the origin's status instead of converting an error page into Markdown. That is deliberately unlike a page fetch, which renders whatever the origin served and puts the status in originStatusCode. Rendering the error page is right for a caller who asked for a page. There is no rendering step here, so the only alternative would be handing you a block page and calling it your document.

Batched Fetch

Batched Fetch does not convert documents yet. Every URL in a batch goes to the browser, so a document URL comes back as a failed item rather than as Markdown. The batched endpoint accepts documentConfig but ignores it.

Send document URLs to POST /v1/fetch or POST /v1/fetch/json until this lands.

Next steps

  • Include Options: choose what a fetch returns.
  • Playground & Replay: inspect a converted document next to its original.
  • Pricing & Usage: see what converted pages and audio cost in credits.
  • Errors: handle 415, 502, and 503 in your client.
PreviousInclude Options
NextYouTube

On This Page

What Fetch convertsURLs without an extensionWhat comes backConversion limitsPricingErrorsBatched FetchNext steps
.gif
.webp
.avif
.bmp
.tif
.tiff
A vision model reads the text and describes the image.
One page, always a vision-model page.
Office.doc, .docx, .docm, .ppt, .pptx, .pptm, .pps, .ppsx, .ppsm, .pot, .xls, .xlsx, .xlsm, .xlsb, .odt, .ods, .odp, .rtfLocally. Spreadsheets become Markdown tables with their number formats intact.Nothing beyond the Fetch.
Ebooks.epubLocally, chapter by chapter.Nothing beyond the Fetch.
Data.csv, .tsv, .json, .xml, .rdfLocally. CSV and TSV become tables. JSON and XML keep their structure.Nothing beyond the Fetch.
Text.txt, .text, .md, .markdownMarkdown comes back verbatim. Plain text is fenced so its whitespace survives.Nothing beyond the Fetch.
Audio.mp3, .wav, .m4a, .aac, .ogg, .oga, .opus, .flacTranscribed to Markdown.Minutes of audio.
"application/pdf"
},
"markdown": "# Attention Is All You Need\n\n...",
"json": [],
"data": {
"document": {
"url": "https://s3.amazonaws.com/.../document/original.pdf?X-Amz-Signature=...",
"contentType": "application/pdf",
"sizeBytes": 2215244
},
"usage": { "documentPages": 15, "ocrPages": 0, "audioSeconds": 0 }
}
}
Size of the original as downloaded.
data.usageConverted pages, OCR pages, and audio seconds used to calculate the charge.
meta.snapshotIdIdentity of the stored conversion. Document results have no browser replay archive.
3600
1 to 14400
Refuse the fetch rather than transcribe audio longer than this.
ocr"auto" | "never" | "always""auto"Whether pages may go to the vision model.
10
Rounded up, one-minute minimum.
404
410
502
statusCode
FetchDocumentProcessingUnavailable503The vision or transcription provider could not finish the work. operation is "ocr" or "transcription". Retryable.