Skip to main content
The extract.run() method pulls specific fields from documents as structured JSON. You define a JSON schema with the fields you need, and Extract returns values matching that schema.

Basic Usage


Method Signature

Parameters

Settings Options


Schema Definition

The instructions parameter requires a schema field with a JSON schema:

Field Descriptions

Field descriptions are critical for accurate extraction. Be specific:

System Prompt

Add document-level context with system_prompt:

Input Options

Extract accepts multiple input formats:

Deep Extract

For documents with repeating data (line items, transactions) or complex/long extractions, enable Deep Extract (higher cost and latency). It supersedes the deprecated array_extract:

Array Extraction Guide

Detailed guide to array extraction configuration.

Citations

Enable citations to get source locations for each extracted value:
Citations cannot be used with chunking. If you enable citations, chunking is automatically disabled.

Parsing Configuration

Since Extract runs Parse internally, you can configure parsing:
These options are ignored if your input is a jobid:// reference.

Response Structure

With Citations

When citations are enabled, the response format changes. Instead of a list, result.result is a dict with values wrapped in citation objects:

Schemaless Extraction

You can also extract without a schema using only a system prompt:

Error Handling


Complete Example


Best Practices

Write Clear Descriptions

Field descriptions directly impact extraction quality. Be specific about location and format.

Use Deep Extract

Enable deep_extract for complex documents or many repeating items (transactions, line items). Higher cost/latency. Supersedes the deprecated array_extract.

Enable Citations for Verification

Use citations to verify extracted values and show users source locations.

Debug with Parse First

If extraction fails, check the Parse output first. Extract can only find what Parse sees.

Troubleshooting

If expected fields are empty:
  1. Check the Parse output: client.parse.run(input=upload.file_id)
  2. Verify the value appears in the parsed content
  3. Improve field descriptions to match how values appear
  4. Try enabling deep_extract for long or complex documents
Extract only returns what’s on the document. If you need computed values, extract raw data and compute in your code:

Next Steps