Skip to main content
This reference documents the Python SDK methods for Scale’s Dex document understanding capability.

DexClient

The main client for interacting with the Dex service.

Project Management

  • create_project(name, configuration) - Create a new project with optional configuration
  • list_projects() - List all accessible projects
  • get_project(project_id) - Retrieve a specific project
  • update_project(project_id, project_data) - Update project name, configuration, or status
Example:

Project

Represents a Dex project with isolated data and credentials.

File Operations

  • upload_file(file_path) - Upload a document to the project
  • list_files(pagination_params, filter) - List all uploaded files with optional pagination and filtering
  • get_file_by_id(file_id) - Get file metadata
Example:

Job Operations

  • list_jobs(pagination_params, filter) - List all jobs in the project with optional pagination and filtering
  • get_job(job_id) - Get job details and status
Example:

Parse Result Operations

  • list_parse_results(pagination_params, filter) - List all parse results with optional pagination and filtering
  • get_parse_result(parse_result_id) - Get parse result details
Example:

Extraction Operations

  • list_extractions(pagination_params, filter) - List all extractions with optional pagination and filtering
  • get_extraction(extraction_id) - Get extraction details
Example:

Vector Store Operations

  • create_vector_store(name, engine, embedding_model) - Create a vector store with SGP Knowledge Base engine
  • list_vector_stores(pagination_params, filter) - List all vector stores with optional pagination and filtering
  • get_vector_store_by_id(vector_store_id) - Get vector store details
  • delete() - Delete a vector store from a DexVectorStore instance
Example:

DexFile

Represents an uploaded file in Dex.

Parsing

  • parse(params) - Parse document to structured format (automatically polls for completion)
  • start_parse_job(params) - Start a parse job and return immediately (recommended for async workflows)
  • get_download_url() - Get a temporary download URL for the uploaded file
Example:

Working with Parse Results

After parsing, you can access the structured content including chunks and blocks. Example:

ParseResult

Represents the result of a document parsing operation.

Extraction

  • extract(extraction_schema, user_prompt, model, generate_citations, generate_confidence) - Extract structured data with user prompt, schema, model, and options
Parameters:
  • extraction_schema (BaseModel): Pydantic model class for extraction (pass the class directly, not model_json_schema())
  • user_prompt (str): Natural language instructions for extraction
  • model (str): LLM model to use (e.g., “openai/gpt-5.4”)
  • generate_citations (bool): Include source citations in results
  • generate_confidence (bool): Include confidence scores in results
Example:

Working with Extraction Results

After extraction, you can access the structured data, citations, and confidence scores. Example:

VectorStore

Represents a vector store for semantic search and RAG-enhanced extraction.

Indexing

  • add_parse_results(parse_result_ids) - Add parsed documents to vector store by parse result IDs
Example:
  • search(query, top_k, filters) - Semantic search across all documents in the vector store
  • search_in_file(file_id, query, top_k, filters) - Search within a specific file with optional filters
Example:

Extraction

  • extract(extraction_schema, user_prompt, model, generate_citations, generate_confidence) - Extract structured data from entire vector store with RAG context
Example:

Job Monitoring and SGP Tracing

New in v0.4.0: Enhanced async job support with SGP tracing integration for better observability and debugging.

Async Job Workflow

Use start_parse_job() for better control over async operations and access to SGP traces. Example:

Retrieving SGP Traces

Jobs are now connected to SGP traces for end-to-end observability. You can retrieve complete trace data for any job. Example:
Benefits:
  • Better observability: Track jobs through SGP’s tracing infrastructure
  • Easier debugging: Access detailed execution traces for failed jobs
  • Performance monitoring: Analyze job performance and identify bottlenecks
  • Request correlation: Connect job execution to API requests and traces

Parse Job Parameters

When parsing documents, you can specify different engines and options to customize the parsing behavior.

Iris Parse Parameters

IrisParseJobParams - Parameters for the Iris OCR engine (Default engine). Fields:
  • engine (ParseEngine): Set to ParseEngine.IRIS
  • options (IrisParseEngineOptions): Parsing options
  • vector_store_metadata (dict | None): Metadata to populate into the vector store for filtering when searching. Keys must match the vector_store_metadata_schema of the target vector store.
IrisParseEngineOptions: Example:

Reducto Parse Parameters (Legacy)

ReductoParseJobParams - Parameters for the Reducto OCR engine. Best for: English and Latin-script documents (Spanish, French, German, Italian, Portuguese, etc.) with tables, figures, and complex layouts. Fields:
  • engine (ParseEngine): Set to ParseEngine.REDUCTO
  • options (ReductoParseEngineOptions): Parsing options
  • advanced_options (dict): Advanced options for fine-tuning
  • experimental_options (dict): Experimental features
  • priority (bool): Whether to prioritize this job (default: False)
  • vector_store_metadata (dict | None): Metadata to populate into the vector store for filtering when searching. Keys must match the vector_store_metadata_schema of the target vector store.
ReductoParseEngineOptions:
  • chunking (ReductoChunkingOptions | None): Chunking configuration
ReductoChunkingOptions:
  • chunk_mode (ReductoChunkingMethod): Chunking method (default: VARIABLE)
    • DISABLED: No chunking
    • BLOCK: Block-level chunks
    • PAGE: Page-level chunks
    • PAGE_SECTIONS: Page sections
    • SECTION: Section-level chunks
    • VARIABLE: Variable-size chunks based on content
  • chunk_size (int | None): Custom chunk size
Example:

Common Types

This section documents the core data models and types used throughout the Dex SDK.

Type Categories

Importable Types - Types you can import from dex_sdk.types to configure your requests:
  • Configuration types (ProjectConfiguration, RetentionPolicy)
  • Pagination types (PaginationParams, FileListFilter, JobListFilter, ParseResultListFilter, ExtractionListFilter, VectorStoreListFilter) - New in v0.4.0
  • Parse parameter types (IrisParseJobParams, ReductoParseJobParams, etc.)
  • Enum types (ParseEngine, ReductoChunkingMethod, VectorStoreEngines, JobStatus) - JobStatus new in v0.4.0
Response Types - Types returned by the SDK, accessible via the .data attribute on wrapper objects:
  • When you call SDK methods, you get wrapper objects (DexProject, DexFile, DexParseResult, etc.)
  • Access the underlying data via .data: project.data.id, file.data.filename
  • These entities are automatically validated but don’t need to be imported

Configuration Types

ProjectConfiguration

Configuration options for a Dex project. Import: from dex_sdk.types import ProjectConfiguration Fields:
  • retention (RetentionPolicy | None): Data retention policy for the project
Example:

RetentionPolicy

Defines data retention periods for automatic cleanup of files and processing artifacts. Import: from dex_sdk.types import RetentionPolicy Fields:
  • files (timedelta | None): Retention period for uploaded files. Files older than this period are automatically deleted. If None, files are retained indefinitely.
  • result_artifacts (timedelta | None): Retention period for parse results, extraction results, and job artifacts. If None, artifacts are retained indefinitely.
Example:
Use Cases:
  • Compliance: Meet regulatory requirements (GDPR, HIPAA, etc.)
  • Cost Management: Automatically clean up old data to reduce storage costs
  • Security: Limit exposure of sensitive documents by enforcing retention limits
Note: The retention period is calculated from the creation time of the file or artifact. Retention policies can be updated at any time using update_project().

PaginationParams

New in v0.4.0: Parameters for paginated list operations. Import: from dex_sdk.types import PaginationParams Fields:
  • page_size (int | None): Number of items to return per page (default: 50, max: 100)
  • sort_by (str | None): Field name to sort by (e.g., "created_at")
  • sort_order (str | None): Sort order, either "asc" or "desc" (default: "desc")
  • continuation_token (str | None): Token for fetching next/previous page
Example:

List Filter Types

New in v0.4.0: Filter types for list operations on different entity types. Import: from dex_sdk.types import FileListFilter, JobListFilter, ParseResultListFilter, ExtractionListFilter, VectorStoreListFilter Common Fields:
  • created_at_start (datetime | None): Filter for entities created after this time
  • created_at_end (datetime | None): Filter for entities created before this time
Example:
Available Filter Types:
  • FileListFilter - Filter uploaded files
  • JobListFilter - Filter jobs
  • ParseResultListFilter - Filter parse results
  • ExtractionListFilter - Filter extractions
  • VectorStoreListFilter - Filter vector stores

ExtractionParameters

Parameters for extraction operations. Import: from dex_sdk.types import ExtractionParameters Fields:
  • model (str): LLM model to use (e.g., "openai/gpt-5.4")
  • model_kwargs (dict | None): Additional kwargs for the LLM model
  • extraction_schema (dict): JSON schema defining the desired output structure
  • system_prompt (str | None): High-level instructions for the extraction model
  • user_prompt (str | None): Specific hints about the current document
  • generate_citations (bool): Whether to return bounding boxes for extracted values (default: True)
  • generate_confidence (bool): Whether to return confidence scores (default: True)

Parse Configuration Types

ParseEngine

Enum of available OCR engines. Import: from dex_sdk.types import ParseEngine Values:
  • IRIS = “iris”
  • REDUCTO = “reducto”
  • CUSTOM = “custom”

ReductoParseJobParams (Deprecated)

Parameters for the Reducto OCR engine. Import: from dex_sdk.types import ReductoParseJobParams See the Parse Job Parameters section for detailed usage.

IrisParseJobParams

Parameters for the Iris OCR engine. Import: from dex_sdk.types import IrisParseJobParams See the Parse Job Parameters section for detailed usage.

ReductoChunkingMethod (Deprecated)

Enum of chunking methods for Reducto parser. Import: from dex_sdk.types import ReductoChunkingMethod Values:
  • DISABLED = “disabled”
  • BLOCK = “block”
  • PAGE = “page”
  • PAGE_SECTIONS = “page_sections”
  • SECTION = “section”
  • VARIABLE = “variable”

ReductoChunkingOptions (Deprecated)

Chunking configuration for Reducto parser. Import: from dex_sdk.types import ReductoChunkingOptions Fields:
  • chunk_mode (ReductoChunkingMethod): Chunking method
  • chunk_size (int | None): Custom chunk size

ReductoParseEngineOptions (Deprecated)

Options for Reducto parser. Import: from dex_sdk.types import ReductoParseEngineOptions Fields:
  • chunking (ReductoChunkingOptions | None): Chunking configuration

IrisParseEngineOptions

Options for Iris parser. Import: from dex_sdk.types import IrisParseEngineOptions Fields:
  • layout (str | None): Layout detection model
  • text_ocr (str | None): Text OCR model
  • table_ocr (str | None): Table OCR model
  • text_prompt (str | None): Custom prompt for text extraction
  • table_prompt (str | None): Custom prompt for table extraction
  • left_to_right (bool | None): Sort regions left-to-right
  • confidence_threshold (float | None): Minimum confidence threshold
  • containment_threshold (float | None): Containment threshold for filtering

Vector Store Types

VectorStoreEngines

Enum of available vector store engines. Import: from dex_sdk.types import VectorStoreEngines Values:
  • SGP_KNOWLEDGE_BASE = “sgp_knowledge_base”

VectorStoreSearchResult

Result from vector store search operations containing matching chunks. Import: from dex_sdk.types import VectorStoreSearchResult Fields:
  • chunks (list[VectorStoreChunk]): List of matching chunks with relevance scores
Example:

VectorStoreChunk

Represents a single chunk returned from vector store search operations. Fields:
  • content (str): Text content of the chunk
  • score (float): Relevance score for the search query
  • file_id (str | None): ID of the file this chunk belongs to
  • parse_result_id (str | None): ID of the parse result this chunk belongs to
  • metadata (dict[str, Any] | None): Additional metadata from the chunk, which may include information like chunk indices, embeddings metadata, or other custom fields added during indexing
  • blocks (list): List of block objects with layout information
Example:

Response Entity Types

These types are returned by SDK methods and accessed via the .data attribute on wrapper objects. You typically don’t need to import these directly.

Working with Response Data

When you call SDK methods, you receive wrapper objects with a .data attribute:

Common Response Entity Fields

ProjectEntity (accessed via project.data):
  • id (str): Project ID with proj_ prefix
  • name (str): Project readable name
  • status (str): Project status ("active" or "archived")
  • configuration (ProjectConfiguration | None): Project configuration
  • created_at (datetime): When the project was created
  • archived_at (datetime | None): When the project was archived
FileEntity (accessed via dex_file.data):
  • id (str): File ID with file_ prefix
  • project_id (str): Project ID that the file belongs to
  • filename (str): Original filename
  • size_bytes (int): File size in bytes
  • mime_type (str): MIME type of the file
  • status (str): Current file status
  • created_at (datetime): When the file was uploaded
ParseResultEntity (accessed via parse_result.data):
  • id (str): Parse result ID with pres_ prefix
  • project_id (str): Project ID
  • source_document_id (str): Source document ID that was parsed
  • engine (str): Engine used for parsing
  • parse_metadata (object): Metadata including filename, pages_processed
  • content (object): Parsed content with chunks
  • created_at (datetime): When the parse result was created
ExtractionEntity (accessed via extract_result or in extraction results):
  • id (str): Extraction result ID
  • source_id (str): Source ID that was extracted from
  • result (object): The extraction result with data and usage_info
  • parameters (ExtractionParameters): Parameters used for extraction
  • created_at (datetime): When the extraction was completed
  • processing_time_ms (int | None): Processing time in milliseconds
VectorStoreEntity (accessed via vector_store.data):
  • id (str): Vector store ID with vs_ prefix
  • project_id (str): Project ID
  • name (str): Name of the vector store
  • engine (str): Engine used for vector store
  • created_at (datetime): When the vector store was created

Deprecated Types

The following types are deprecated as of version 0.3.2 and should no longer be used:
  • ProjectCredentials - No longer used; credentials are passed to DexClient constructor
  • SGPCredentials - No longer used; credentials are passed to DexClient constructor
See the Changelog for migration instructions.

Error Handling

The SDK raises exceptions for various error conditions. For detailed troubleshooting guidance, see the Troubleshooting Guide.

Async/Await Pattern

The Dex SDK is fully async. Use await with all SDK methods:

See Also