Inferensys

Integration

AI Integration with Relativity APIs and Scripts

A technical guide for developers and architects on connecting custom AI models and LLMs to Relativity's extensible platform via its REST API, Event Handlers, and Relativity Scripts for automated document intelligence and workflow enrichment.
ML engineer developing custom LLM, model architecture diagrams on screens, technical deep work environment.
ARCHITECTURE & INTEGRATION POINTS

Where AI Connects to Relativity's Extensible Platform

A technical blueprint for injecting AI directly into Relativity's data model, automation layer, and user workflows via its core extensibility surfaces.

Relativity's architecture is built for extension, providing three primary surfaces for AI integration: its REST API for programmatic data access and object manipulation, Event Handlers for triggering AI workflows on data changes, and Relativity Scripts for executing custom logic within the application context. This means AI can be wired to act on specific objects—like documents, fields, or custom objects—at defined moments in a review workflow, such as after ingestion, on field update, or before production.

For a production implementation, you typically architect a middleware service (often using Python or .NET) that listens for webhooks from Relativity Event Handlers. This service calls your AI models—for summarization, classification, or entity extraction—and then uses the Relativity API to write results back as field values, apply tags, or create related custom object records. Common integration patterns include:

  • Batch Enrichment: Processing a saved search of documents via the API, applying AI analysis, and populating a custom field for reviewer guidance.
  • Real-time Trigger: An Event Handler on a Document field change fires a webhook to an AI service that analyzes the new text and updates a Risk Score field.
  • Agent Workflow: A Relativity Script presents a UI button for reviewers; when clicked, it calls an external API to summarize the current document and displays the result inline.

Governance is critical. All integrations should leverage Relativity's native audit trails and RBAC. AI services should be deployed as containerized microservices with their own logging, and prompts, model versions, and confidence scores should be stored in a dedicated Relativity custom object for traceability. Rollout follows a phased approach: start with a pilot workspace, use the API for non-destructive field writes, and implement human-in-the-loop review steps before full automation. This ensures the AI augments—rather than disrupts—the rigorous legal process Relativity is designed to support.

ARCHITECTURAL BLUEPRINTS

Primary Integration Surfaces in Relativity

Programmatic Data Enrichment

The Relativity REST API provides the most direct path for integrating external AI services. Core integration patterns involve using the /workspace/{workspaceArtifactId}/object endpoints to create, read, update, and delete custom objects that store AI-generated insights.

Key Use Cases:

  • Batch Processing: After an AI service analyzes a document set, results (like extracted entities, summaries, or classification scores) are written back to Relativity as fields on the Document object or a related custom object (e.g., AI_Analysis).
  • Real-time Enrichment: For user-triggered actions, a middleware service calls the AI model and immediately updates the document's layout with the result via a PATCH request.

Example Payload for Adding an AI-Generated Summary:

json
{
  "ArtifactTypeID": 10, // Document Artifact Type
  "ArtifactID": 1023456,
  "FieldValues": [
    {
      "Field": {"Name": "AI_Summary"},
      "Value": "This email chain discusses Q4 budget projections, with key figures proposed by John Smith (Finance)."
    }
  ]
}

This enables AI outputs to become first-class, searchable data within the platform's ecosystem.

INTEGRATION PATTERNS

High-Value AI Use Cases for Relativity

Connect custom AI models and LLMs directly into Relativity's core workflows via its REST API, Event Handlers, and Relativity Scripts. These patterns extend native analytics, automate manual review tasks, and create intelligent custom objects for faster, more consistent legal outcomes.

01

Automated Privilege Log Generation

Deploy an AI agent that analyzes document content and metadata to identify privileged communications (attorney-client, work product). The agent uses Relativity's API to tag documents, populate a custom object with privilege rationale, and auto-generate a privilege log spreadsheet, reducing manual review from days to hours.

Days -> Hours
Log preparation
02

Dynamic Concept Clustering & Tagging

Augment keyword search by integrating a semantic AI model via a Relativity Script or Event Handler. As documents are ingested, the model creates dynamic conceptual clusters (e.g., 'regulatory compliance discussions', 'pricing negotiations') and applies them as Smart Fields, enabling reviewers to pivot instantly to thematic document groups.

Batch -> Real-time
Concept analysis
03

AI-Powered Production QC Agent

Build a pre-export QC workflow using an AI agent triggered via Relativity's Event Handler system. The agent validates Bates numbering consistency, checks for broken family relationships, and flags potential redaction errors by comparing native files to produced images, catching costly mistakes before delivery.

High-Risk -> Low-Risk
Production errors
04

Deposition Transcript Summarization

Integrate an LLM via the REST API to process loaded deposition transcripts. The AI generates concise summaries with speaker-specific Q&A, extracts key factual assertions, and creates linked Relativity Custom Objects for chronology building. Reviewers can query the transcript via natural language directly in the workspace.

Hours -> Minutes
Review per transcript
05

Predictive Custodian Ranking

Leverage communication pattern analysis AI to score and rank custodians at case onset. The model analyzes To/From/CC metadata and content themes via the API, outputting results to a Custom Object for custodian management. This guides legal hold and collection strategy, focusing resources on the most relevant individuals.

1 sprint
Collection scoping
06

Continuous Active Learning (CAL) Enhancement

Extend Relativity Assisted Review (RAR) by integrating a custom machine learning model via Relativity Scripts. The external model provides additional scoring signals (e.g., sentiment, specific clause detection) that are fed back into the review queue as weighted fields, improving prioritization for complex document sets.

Higher Precision
Review prioritization
ARCHITECTURAL PATTERNS

Example AI-Enhanced Workflows

These workflows demonstrate how to connect custom AI services to Relativity's extensibility points, automating review tasks and enriching case data. Each pattern includes the trigger, data flow, AI action, and system update.

Trigger: A Relativity Saved Search is executed on a document set marked for privilege review.

Data Flow:

  1. A Relativity Script or external service polls for new results in the saved search via the REST API (/Relativity.REST/api/Relativity.Objects/workspace/{workspaceId}/object/query).
  2. For each document, the system retrieves key metadata (Control Number, Family ID, Custodian) and the extracted text field via the API.
  3. This payload is batched and sent to a privilege classification AI service.

AI Action: The AI model analyzes each document's text and metadata to:

  • Classify the privilege type (e.g., Attorney-Client, Work Product).
  • Extract the basis for the claim (e.g., "Communication seeking legal advice").
  • Identify the privileged participants.

System Update:

  1. Results are posted back to Relativity using the API to update a custom object type (e.g., "Privilege Log Entry"), linking to the source document.
  2. A CSV report is auto-generated via the Relativity Scripts API and attached to the workspace.
  3. The source document's "Privilege Status" choice field is updated.

Human Review Point: The generated log is routed to a senior reviewer's queue in Relativity for final approval before production.

CONNECTING AI TO RELATIVITY'S AUTOMATION LAYER

Implementation Architecture and Data Flow

A technical blueprint for wiring custom AI services into Relativity's extensible framework using its REST API, Event Handlers, and Relativity Scripts.

A production-grade AI integration for Relativity typically follows an event-driven, asynchronous pattern to avoid blocking core review workflows. The architecture centers on Relativity's REST API for CRUD operations on documents, fields, and custom objects, and its Event Handler system for triggering AI processing. Common entry points include:

  • /Relativity.REST/api/ endpoints to push enriched data back into workspace fields or custom objects.
  • Post-Save Event Handlers on the Document object or a custom "AI Processing Queue" object to trigger analysis when new data arrives or statuses change.
  • Relativity Scripts executed via the API or console for batch operations, such as sending a set of prioritized documents to an external AI service for summarization or issue coding.

The data flow for an AI-assisted review agent often looks like this:

  1. Trigger: A document is saved with a PENDING_AI_REVIEW status (set by a reviewer or an ingestion script). A Post-Save Event Handler fires.
  2. Extract & Queue: The handler bundles the document's extracted text, metadata (Author, Sent Date), and Relativity Artifact ID into a JSON payload, posting it to an external message queue (e.g., AWS SQS, RabbitMQ) or directly to an AI orchestration service. This keeps Relativity responsive.
  3. Process: The AI service (hosted on your infrastructure or a cloud provider) retrieves the payload, runs the document through configured models (e.g., for privilege detection, concept tagging), and generates results.
  4. Write Back: Using a service account with appropriate permissions, the AI service calls the Relativity REST API to update the source document. This involves:
    • Patching choice fields (e.g., AI_Issue_Codes) with multi-select values.
    • Updating long text fields with generated summaries or extracted clauses.
    • Creating related custom object records (e.g., AI_Extracted_Entities) to store structured findings without altering the native document table.
  5. Audit: All API calls and field changes are logged within Relativity's native audit trail, and the external service maintains its own execution logs for traceability.

Governance and rollout require careful planning. Start with a single-workspace pilot, using a dedicated custom object as a processing queue for better control and error handling. Implement rate limiting and retry logic in your external service to respect Relativity API thresholds. For sensitive data, ensure your AI service is deployed in a compliant environment and that prompts are configured to avoid generating sensitive information. Use Relativity's RBAC to restrict which users can trigger AI jobs or view AI-generated fields, and establish a human-in-the-loop review step for critical tags like privilege before they are used in production sets. This architecture provides the foundation for scalable, maintainable AI enhancements that feel native to legal teams.

REAL-WORLD INTEGRATION PATTERNS

Code and Payload Examples

Creating Custom Tags via Relativity REST API

Use Relativity's REST API to programmatically create and apply tags based on AI analysis. This pattern is ideal for batch processing after an external AI service analyzes a document set. The API call creates a Tag object associated with specific documents.

Example Payload (POST to /Relativity.Rest/api/Relativity.Objects/workspace/{workspaceId}/object/create)

json
{
  "objectType": {
    "artifactTypeID": 1000017
  },
  "fieldValues": [
    {
      "field": {
        "name": "Name",
        "artifactID": 1003667
      },
      "value": "AI-Privilege-Review"
    },
    {
      "field": {
        "name": "Documents",
        "artifactID": 1003668
      },
      "value": [
        {
          "artifactID": 10234567
        },
        {
          "artifactID": 10234568
        }
      ]
    }
  ]
}

This creates a new tag named "AI-Privilege-Review" and applies it to two specific documents. You would populate the document artifactID array from your AI service's output.

AI-ENHANCED WORKFLOWS

Realistic Time Savings and Operational Impact

This table illustrates the operational impact of integrating AI with Relativity via its APIs and Scripts, focusing on specific review and data management tasks. Metrics are based on typical pilot implementations and assume proper integration with existing Relativity objects and workflows.

Workflow / TaskBefore AI IntegrationAfter AI IntegrationImplementation Notes

Initial Document Triage & Tagging

Manual review for responsiveness; 2-4 hours per GB

AI pre-tags for responsiveness & issues; QC review in 30-60 min per GB

Uses Relativity Event Handlers to trigger AI on ingestion; outputs to custom objects or choice fields.

Privilege Log Generation

Manual extraction of key fields and descriptions; 8-12 hours per case

AI drafts privilege descriptions & extracts metadata; attorney review in 2-3 hours

Scripts call AI service via REST API, populate a custom Relativity object; final export to spreadsheet.

Email Thread Analysis

Reviewer manually identifies root emails and key messages

AI identifies root messages, summarizes threads, flags sentiment shifts

Analysis runs via background agent; results stored as thread-level custom fields for reviewer sorting.

Concept Clustering & Search

Keyword-based searches; manual review of results for relevance

Semantic search finds conceptually related docs; dynamic clusters created on-the-fly

Integrates with Relativity's search index via API; clusters appear as saved searches or dynamic folders.

Production Set Quality Control

Manual spot-check of Bates ranges, families, and redactions

AI agent validates numbering, checks family integrity, flags potential errors

Runs as a pre-production Relativity Script; generates a QC report within the workspace.

Deposition Transcript Summarization

Manual reading and highlighting of key testimony

AI generates summary with Q&A, key quotes, and speaker attribution

Transcript load file triggers processing; summary and tags are imported as a related document set.

Custodian Communication Pattern Analysis

Manual review of To/From fields and date ranges

AI maps communication networks, identifies central custodians, ranks by relevance

Leverages Relativity's communication data model; outputs visualizations and custodian ranking reports.

ARCHITECTING CONTROLLED DEPLOYMENT

Governance, Security, and Phased Rollout

A production-ready AI integration for Relativity requires a structured approach to security, data governance, and incremental rollout.

Integrations should leverage Relativity's robust security model. AI services are invoked via the Relativity REST API using service accounts with role-based access control (RBAC) scoped to specific workspaces. All data exchanges are encrypted in transit, and sensitive PII/PHI can be processed in a private, VPC-isolated AI environment. Audit trails are maintained by logging all AI actions—such as tag creation via Relativity Scripts or object updates via Event Handlers—back to Relativity's audit system, ensuring a complete chain of custody for AI-assisted decisions.

A phased rollout mitigates risk and builds stakeholder trust. Start with a non-production workspace to validate API calls, prompt effectiveness, and output formatting. Phase 1 often targets a single, high-volume workflow like email threading analysis or initial batch tagging for a defined custodian set. Use Relativity's batch processing capabilities to queue documents for AI review, allowing for human QC of the AI's output before tags are committed. Phase 2 expands to real-time processing via Event Handlers for new document ingestion, and Phase 3 introduces more complex, multi-step agent workflows for timeline generation or privilege prediction.

Governance is maintained through a feedback loop. Establish a review committee to approve AI use cases and monitor performance metrics like precision/recall on a sample set. Implement a human-in-the-loop approval step for critical actions, such as applying Privileged tags, which can be managed through a custom Relativity object and workflow. Regular reviews ensure the AI agents align with matter strategy and evolving review protocols. This structured approach allows legal teams to harness AI's efficiency while maintaining the defensibility and control required for complex litigation and investigations.

IMPLEMENTATION AND ARCHITECTURE

Frequently Asked Questions

Technical questions for developers and architects planning to connect AI services to Relativity via its REST API, Event Handlers, and Relativity Scripts.

You can integrate AI at three main layers within Relativity:

  1. REST API: For external orchestration. Use it to:

    • Pull document text and metadata in batches for processing by an external AI service.
    • Push AI-generated tags, summaries, or custom object data back into Relativity fields.
    • Trigger workflows or check job statuses programmatically.
  2. Event Handlers: For real-time, in-platform reactions. Deploy a custom Event Handler to:

    • Intercept events like Document Saved or Field Updated.
    • Call an AI model synchronously or asynchronously via an HTTP request.
    • Immediately update the document with AI-derived insights (e.g., auto-tagging for PII upon upload).
  3. Relativity Scripts: For user-initiated, batch AI operations. Write scripts that:

    • Operate on a saved search or selection of documents.
    • Call out to your AI endpoint, handle pagination and rate limits.
    • Update fields and provide progress feedback to the reviewer in the UI.

Key Consideration: The REST API is best for high-volume, scheduled batch jobs. Event Handlers enable real-time automation but must be performant. Scripts offer user control and are ideal for on-demand analysis.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.