SDKs & Libraries

SDKs & Libraries

Use official client libraries to integrate Sapphire Legal AI into your applications quickly and securely.

Overview

Official SDKs provide pre-built functionality for common API operations, handle authentication, manage rate limiting, and provide type safety for your preferred programming language.

Available SDKs

JavaScript/TypeScript

Our flagship SDK with full TypeScript support and comprehensive feature coverage.

Installation

# Using npm
npm install @sapphirelegal/ai-sdk

# Using yarn
yarn add @sapphirelegal/ai-sdk

# Using pnpm
pnpm add @sapphirelegal/ai-sdk

Basic usage

import { SapphireClient } from '@sapphirelegal/ai-sdk';

const client = new SapphireClient({
  apiKey: 'your_api_key_here',
  // or use JWT token
  // token: 'your_jwt_token_here'
});

// Create a new case
const case = await client.cases.create({
  title: 'Smith v. Johnson',
  case_number: 'CV-2025-001',
  case_type: 'litigation',
  jurisdiction: 'federal'
});

// Upload a document
const document = await client.documents.upload(case.id, {
  file: fileBuffer,
  title: 'Complaint',
  document_type: 'pleading'
});

// Search cases
const cases = await client.cases.search({
  query: 'contract dispute',
  status: 'active',
  limit: 20
});

Advanced features

  • TypeScript support: Full type definitions for all API operations
  • Error handling: Comprehensive error classes and handling
  • Rate limiting: Automatic rate limit management and retry logic
  • Webhook handling: Built-in webhook signature verification
  • Streaming: Support for streaming responses and real-time updates

Python

Python SDK with async support and comprehensive documentation.

Installation

# Using pip
pip install sapphire-legal-ai

# Using poetry
poetry add sapphire-legal-ai

# Using conda
conda install -c conda-forge sapphire-legal-ai

Basic usage

from sapphire_legal_ai import SapphireClient

# Initialize client
client = SapphireClient(api_key="your_api_key_here")

# Create a case
case = client.cases.create(
    title="Smith v. Johnson",
    case_number="CV-2025-001",
    case_type="litigation",
    jurisdiction="federal"
)

# Upload document
with open("complaint.pdf", "rb") as f:
    document = client.documents.upload(
        case_id=case.id,
        file=f,
        title="Complaint",
        document_type="pleading"
    )

# Search cases
cases = client.cases.search(
    query="contract dispute",
    status="active",
    limit=20
)

Java

Enterprise-grade Java SDK with Spring Boot integration support.

Installation (Maven)

<dependency>
    <groupId>ai.sapphirelegal</groupId>
    <artifactId>sapphire-ai-sdk</artifactId>
    <version>1.0.0</version>
</dependency>

Installation (Gradle)

implementation 'ai.sapphirelegal:sapphire-ai-sdk:1.0.0'

Basic usage

import ai.sapphirelegal.SapphireClient;
import ai.sapphirelegal.models.Case;
import ai.sapphirelegal.models.Document;

// Initialize client
SapphireClient client = new SapphireClient.Builder()
    .apiKey("your_api_key_here")
    .build();

// Create a case
Case case = client.cases().create(Case.builder()
    .title("Smith v. Johnson")
    .caseNumber("CV-2025-001")
    .caseType("litigation")
    .jurisdiction("federal")
    .build());

// Upload document
Document document = client.documents().upload(case.getId(), 
    Document.builder()
        .file(fileBytes)
        .title("Complaint")
        .documentType("pleading")
        .build());

Go

High-performance Go SDK with context support and idiomatic Go patterns.

Installation

go get github.com/sapphirelegal/ai-sdk-go

Basic usage

package main

import (
    "context"
    "log"
    
    "github.com/sapphirelegal/ai-sdk-go"
)

func main() {
    ctx := context.Background()
    
    // Initialize client
    client := sapphire.NewClient("your_api_key_here")
    
    // Create a case
    case, err := client.Cases.Create(ctx, &sapphire.CaseRequest{
        Title:        "Smith v. Johnson",
        CaseNumber:   "CV-2025-001",
        CaseType:     "litigation",
        Jurisdiction: "federal",
    })
    if err != nil {
        log.Fatal(err)
    }
    
    // Upload document
    document, err := client.Documents.Upload(ctx, case.ID, &sapphire.DocumentRequest{
        File:         fileBytes,
        Title:        "Complaint",
        DocumentType: "pleading",
    })
    if err != nil {
        log.Fatal(err)
    }
}

Version support matrix

SDKCurrent VersionAPI VersionStatusEOL Date
JavaScript/TypeScript1.5.0v1Active-
Python1.3.0v1Active-
Java1.2.0v1Active-
Go1.1.0v1Active-

SDK features

Common capabilities

  • Authentication: Automatic token management and refresh
  • Rate limiting: Built-in rate limit handling and backoff
  • Error handling: Consistent error types and retry logic
  • Logging: Configurable logging and debugging
  • Testing: Mock clients and testing utilities

Advanced features

  • Webhook handling: Built-in webhook signature verification
  • Streaming: Support for real-time data streams
  • Batching: Efficient batch operations for multiple items
  • Caching: Intelligent caching for frequently accessed data
  • Metrics: Built-in performance monitoring and metrics

Getting started

Quick start guide

  1. Choose your preferred programming language
  2. Install the SDK using your package manager
  3. Get your API key from the Sapphire Legal AI dashboard
  4. Initialize the client with your credentials
  5. Start making API calls using the SDK methods

Authentication setup

All SDKs support both API key and JWT token authentication:

  • API Key: Long-term access for service-to-service communication
  • JWT Token: User-based authentication with automatic refresh
  • OAuth2: Enterprise SSO integration (JavaScript SDK only)

Examples and tutorials

Common use cases

  • Case management: Create, update, and search cases
  • Document handling: Upload, process, and manage documents
  • User management: Manage users and permissions
  • Webhook integration: Set up event-driven workflows
  • Bulk operations: Process multiple items efficiently

Integration patterns

  • Web applications: Frontend integration with JavaScript SDK
  • Backend services: Server-side integration with Python/Java/Go
  • Mobile apps: Cross-platform mobile integration
  • Automation scripts: CLI tools and scheduled tasks
  • Data pipelines: ETL and analytics integration

Support and resources

Documentation

  • API Reference: Complete endpoint documentation
  • SDK Guides: Language-specific tutorials and examples
  • Code Samples: Ready-to-use code examples
  • Best Practices: Integration patterns and recommendations

Community and support

  • GitHub: Open source SDK repositories
  • Discord: Community discussions and support
  • Stack Overflow: Q&A and troubleshooting
  • Support tickets: Enterprise support and assistance
Tip
Pro tip: Start with the JavaScript/TypeScript SDK for the most comprehensive feature coverage and active development.

What's next