Skip to main content
The Graphor SDKs provide convenient access to the Graphor REST API from Python and TypeScript/JavaScript applications. Both libraries include type definitions for all request params and response fields.
The Python SDK supports Python 3.9+ and offers both synchronous and asynchronous clients.
This page provides a comprehensive overview of the SDK. It covers the full lifecycle:
  1. Data Ingestion (Sources): Ingest, poll status, list, get elements, and manage documents by file_id
  2. Document Chat: Ask questions about your documents with conversational memory
  3. Data Extraction: Extract structured data using JSON Schema
  4. Prebuilt Retrieval: Retrieve relevant document chunks via semantic search

Python SDK Repository

View the Python SDK source code, report issues, and contribute.

TypeScript SDK Repository

View the TypeScript SDK source code, report issues, and contribute.

Installation

Install the Graphor SDK from PyPI:
Python 3.9 or higher is required.

Data Ingestion (Sources)

The Sources methods cover the full ingestion lifecycle:

Ingest Source

Ingest documents from files, URLs, GitHub, and YouTube (returns build_id; poll for file_id)

Reprocess Source

Reprocess an existing source with a different partition method

List Sources

Retrieve all sources with status and metadata

List Source Elements

Retrieve structured elements/partitions from processed sources

Delete Source

Permanently remove sources from your project

Document Chat

Once your data is ingested, use the Chat method to ask questions:

Chat with Documents

Ask natural language questions about your documents with conversational memory and structured outputs

Data Extraction

Extract specific structured data from your documents using schemas:

Extract Structured Data

Extract structured information from documents using JSON Schema and natural language instructions

Prebuilt Retrieval

Retrieve relevant document chunks via semantic search:

Retrieve Document Chunks

Retrieve relevant document chunks using semantic search for custom LLM integration

What “Data Ingestion” includes

  • Ingest: Create a new source (file, URL, GitHub, YouTube); returns build_id; poll get build status until ready, then use file_id
  • Reprocess: Reprocess an existing source with a different partition method (optional)
  • List: Monitor status and metadata; optionally filter by file_ids
  • Get elements: Retrieve structured elements/partitions by file_id after processing
  • Delete: Remove a source by file_id

Authentication

All SDK methods require authentication using API tokens. You can provide your API key in two ways: Set the GRAPHOR_API_KEY environment variable:

Direct Initialization

Learn how to generate and manage API tokens in the API Tokens guide.

Token Security

  • Never expose tokens in client-side code or public repositories
  • Use environment variables to store tokens securely
  • Rotate tokens regularly for enhanced security
  • Use different tokens for different environments (dev/staging/prod)

Async Usage

Simply import AsyncGraphor instead of Graphor and use await with each API call:

Available Methods

Sources

Chat & Extraction

Complete Workflow Example

Here’s the full “happy path”: ingest → get_build_status (poll) → list → get_elements → chat/extract/retrieve_chunks; optionally reprocess by file_id.

1. Ingest a source

2. Reprocess (optional)

3. List sources

4. Get elements (after processing)

5. Ask questions (Chat)

6. Extract data

Integration Patterns

Complete SDK Client Wrapper

Async Integration

Error Handling

The SDK provides typed exceptions for different error scenarios:

Error Types

Configuration

Retries

Certain errors are automatically retried 2 times by default with exponential backoff:

Timeouts

By default, requests time out after 1 minute:

Using aiohttp for Better Concurrency (Python only)

For high-concurrency async operations in Python, use the aiohttp client:

Rate Limits and Best Practices

Performance Guidelines

  • Batch Operations: Process multiple files sequentially or with controlled concurrency
  • Async Processing: Use AsyncGraphor (Python) or Promise.all (TypeScript) for concurrent operations
  • Retry Logic: The SDK handles retries automatically; configure max_retries / maxRetries as needed
  • Timeout Handling: Increase timeouts for large documents or complex processing

Best Practices

Common Use Cases

Document Processing Pipeline

Q&A System

Support and Resources

Getting Help

Contact Support

Direct support for technical questions and issues

API Tokens Guide

Learn how to generate and manage authentication tokens

Data Ingestion Guide

Best practices for document upload and processing

REST API Reference

Full REST API documentation for advanced use cases

Next Steps

Ready to start building with the Graphor SDK? Choose your path:

For Beginners

Ingest Sources

Ingest documents from files, URLs, GitHub, and YouTube; poll for file_id

Chat with Documents

Ask natural language questions about your documents

API Tokens

Set up authentication for API access

For Advanced Users

Data Extraction

Extract structured data using JSON Schema

Prebuilt Retrieval

Retrieve relevant chunks via semantic search

Reprocess Source

Reprocess sources with different partition methods

List Elements

Access structured document elements and metadata
The Graphor SDKs provide a powerful foundation for building intelligent, document-driven applications. With comprehensive support for document ingestion, conversational AI, structured extraction, and semantic search, both the Python and TypeScript SDKs give you the flexibility to build sophisticated AI workflows that scale from simple document search to complex analysis systems.