### Quick Start and Parsing Source: https://docs.reducto.ai/cli Install the CLI, authenticate, and parse local files or directories. ```bash pip install reducto-cli reducto login curl -L -o fidelity-example.pdf https://cdn.reducto.ai/samples/fidelity-example.pdf reducto parse ./fidelity-example.pdf ``` ```bash reducto parse ./document.pdf ``` ```bash reducto parse ./documents ``` -------------------------------- ### Install Reducto Go SDK Source: https://docs.reducto.ai/sdk/go/overview Command to install the SDK via go get. ```bash go get github.com/reductoai/reducto-go-sdk ``` -------------------------------- ### Complete pipeline example Source: https://docs.reducto.ai/sdk/python/pipeline A full workflow example from client initialization to file upload. ```python from pathlib import Path from reducto import Reducto client = Reducto() # Upload upload = client.upload(file=Path("fidelity-example.pdf")) ``` -------------------------------- ### Install Reducto SDK Source: https://docs.reducto.ai/sdk/javascript/overview Commands to install the SDK using npm or yarn. ```bash npm install reductoai ``` ```bash yarn add reductoai ``` -------------------------------- ### Complete Multimodal RAG Pipeline (JavaScript) Source: https://docs.reducto.ai/cookbooks/multimodal-rag-image-results This JavaScript example outlines the setup for a multimodal RAG pipeline, including initializing Reducto, AWS S3, Pinecone, and Voyage AI clients. It shows how to configure S3 bucket region and prepare for image uploads. Note: The code is incomplete, showing only the initialization and the start of the `indexDocument` function. ```JavaScript import fs from "fs"; import Reducto from "reductoai"; import { S3Client, PutObjectCommand, GetBucketLocationCommand } from "@aws-sdk/client-s3"; import { Pinecone } from "@pinecone-database/pinecone"; import { VoyageAIClient } from "voyageai"; // Initialize clients const reducto = new Reducto(); const s3 = new S3Client({ region: "us-east-1" }); const pc = new Pinecone({ apiKey: process.env.PINECONE_API_KEY }); const voyage = new VoyageAIClient(); const bucketName = process.env.S3_BUCKET_NAME; const indexName = "multimodal-rag"; // Get bucket region for S3 URLs const locationResponse = await s3.send(new GetBucketLocationCommand({ Bucket: bucketName })); const region = locationResponse.LocationConstraint || "us-east-1"; async function uploadImageToS3(imageUrl, s3Key) { const response = await fetch(imageUrl); if (!response.ok) throw new Error(`Failed to fetch: ${response.status}`); const imageBuffer = Buffer.from(await response.arrayBuffer()); await s3.send(new PutObjectCommand({ Bucket: bucketName, Key: s3Key, Body: imageBuffer, ContentType: "image/png" })); return `https://${bucketName}.s3.${region}.amazonaws.com/${s3Key}`; } async function indexDocument(filePath) { // Parse with image extraction const upload = await reducto.upload({ file: fs.createReadStream(filePath) }); const result = await reducto.parse.run({ input: upload.file_id, settings: { return_images: ["figure", "table"] }, retrieval: { chunking: { chunk_mode: "section" } } }); // Process chunks and upload images ``` -------------------------------- ### Install package Source: https://docs.reducto.ai/components/spreadsheet-viewer Install the component library using your preferred package manager. ```bash npm install @reductoai-collab/components ``` ```bash yarn add @reductoai-collab/components ``` ```bash pnpm add @reductoai-collab/components ``` -------------------------------- ### Split Configuration Examples Source: https://docs.reducto.ai/sdk/javascript/split Examples demonstrating advanced split configurations, including custom split rules and table settings. ```APIDOC ## Advanced Split Configurations ### Using `split_rules` Control the page classification logic with natural language prompts. ```javascript const result = await client.split.run({ input: upload.file_id, split_description: [ { name: "Summary", description: "Executive summary" }, { name: "Details", description: "Detailed content" } ], split_rules: "Pages can belong to multiple sections if they contain content from both." }); ``` ### Using `settings.table_cutoff` Configure how table rows are handled during the split process. ```javascript const result = await client.split.run({ input: upload.file_id, split_description: [ { name: "Tables", description: "Data tables" } ], settings: { table_cutoff: "preserve" // Keep all table rows (default: "truncate") } }); ``` ``` -------------------------------- ### Complete Example Source: https://docs.reducto.ai/sdk/python/extract A comprehensive example demonstrating the entire workflow, from uploading a file and defining a schema to running the extraction and accessing the results. ```APIDOC ## Complete Reducto AI Extraction Example ### Description This example illustrates a full workflow using the Reducto client, including file upload, schema definition, data extraction, and accessing basic response information. ### Method POST ### Endpoint /api/extract/run ### Code Example ```python from pathlib import Path from reducto import Reducto # Initialize the Reducto client client = Reducto() # Upload a file (replace 'fidelity-example.pdf' with your file path) # The upload object contains the file_id needed for subsequent calls upload = client.upload(file=Path("fidelity-example.pdf")) # Define the JSON schema for data extraction schema = { "type": "object", "properties": { "portfolio_value": { "type": "number", "description": "Total portfolio value at the end of the period" }, "total_income_ytd": { "type": "number", "description": "Total income year-to-date" }, "top_holdings": { "type": "array", "items": {"type": "string"}, "description": "Names of the top 5 holdings" } } } # Run the extraction process # The 'input' parameter uses the file_id from the upload object # The 'instructions' parameter includes the defined schema result = client.extract.run( input=upload.file_id, instructions={"schema": schema} ) # Accessing top-level response fields print(f"Job ID: {result.job_id}") print(f"Pages Processed: {result.usage.num_pages}") print(f"Credits Used: {result.usage.credits}") print(f"Studio Link: {result.studio_link}") # Accessing extracted data # 'result.result' is a list of extracted objects based on the schema extracted_data = result.result # Example: Accessing data from the first extracted object if extracted_data: first_result = extracted_data[0] print(f"Portfolio Value: {first_result.get('portfolio_value')}") print(f"Total Income YTD: {first_result.get('total_income_ytd')}") print(f"Top Holdings: {first_result.get('top_holdings')}") ``` ``` -------------------------------- ### Complete Document Splitting Example Source: https://docs.reducto.ai/sdk/python/split A full example demonstrating document upload, defining split descriptions, running the split operation, and processing the results. ```python from pathlib import Path from reducto import Reducto client = Reducto() # Upload upload = client.upload(file=Path("fidelity-example.pdf")) # Define sections to find split_description = [ { "name": "Account Summary", "description": "Overview of account balances and holdings" }, { "name": "Holdings Detail", "description": "Detailed list of individual holdings with values" }, { "name": "Transaction History", "description": "Recent transactions and activity" } ] # Split the document result = client.split.run( input=upload.file_id, split_description=split_description ) # Process results print(f"Found {len(result.result.splits)} sections") for split in result.result.splits: print(f"\n=== {split.name} ===") print(f"Pages: {split.pages}") print(f"Confidence: {split.conf}") ``` -------------------------------- ### Install Reducto CLI Source: https://docs.reducto.ai/cli Install the package using pip. ```bash pip install reducto-cli ``` -------------------------------- ### Initialize Stagehand and Start Session Source: https://docs.reducto.ai/cookbooks/web-browsing-browserbase Initialize the Browserbase client and the Stagehand asynchronous client, then start a new session. ```python import os from browserbase import Browserbase from stagehand import AsyncStagehand bb = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"]) client = AsyncStagehand( browserbase_api_key=os.environ["BROWSERBASE_API_KEY"], browserbase_project_id=os.environ["BROWSERBASE_PROJECT_ID"], model_api_key=os.environ["GOOGLE_API_KEY"], ) start_response = await client.sessions.start(model_name="google/gemini-2.5-pro") session_id = start_response.data.session_id ``` -------------------------------- ### Quick Start with Reducto SDK Source: https://docs.reducto.ai/sdk/python/overview Initializes the client, uploads a document, and iterates through extracted content chunks. ```python from pathlib import Path from reducto import Reducto # Initialize the client (reads REDUCTO_API_KEY from environment) client = Reducto() # Upload a document upload = client.upload(file=Path("invoice.pdf")) # Parse the document result = client.parse.run(input=upload.file_id) # Access the extracted content for chunk in result.result.chunks: print(chunk.content) ``` -------------------------------- ### Input Configuration Examples Source: https://docs.reducto.ai/parse Code examples for providing input to the parse endpoint using various methods across different languages. ```python # From upload result = client.parse.run(input=upload.file_id) # Public URL result = client.parse.run(input="https://example.com/doc.pdf") # Presigned S3 URL result = client.parse.run(input="https://bucket.s3.amazonaws.com/doc.pdf?X-Amz-...") # Reprocess previous job result = client.parse.run(input="jobid://7600c8c5-a52f-49d2-8a7d-d75d1b51e141") ``` ```javascript // From upload const result = await client.parse.run({ input: upload.file_id }); // Public URL const result = await client.parse.run({ input: 'https://example.com/doc.pdf' }); // Presigned S3 URL const result = await client.parse.run({ input: 'https://bucket.s3.amazonaws.com/doc.pdf?X-Amz-...' }); // Reprocess previous job const result = await client.parse.run({ input: 'jobid://7600c8c5-a52f-49d2-8a7d-d75d1b51e141' }); ``` ```go // From upload result, _ := client.Parse.Run(context.Background(), reducto.ParseRunParams{ ParseConfig: reducto.ParseConfigParam{ DocumentURL: reducto.F[reducto.ParseConfigDocumentURLUnionParam]( shared.UnionString(upload.FileID), ), }, }) // Public URL result, _ := client.Parse.Run(context.Background(), reducto.ParseRunParams{ ParseConfig: reducto.ParseConfigParam{ DocumentURL: reducto.F[reducto.ParseConfigDocumentURLUnionParam]( shared.UnionString("https://example.com/doc.pdf"), ), }, }) ``` ```bash # From upload curl -X POST https://platform.reducto.ai/parse \ -H "Authorization: Bearer $REDUCTO_API_KEY" \ -H "Content-Type: application/json" \ -d '{"input": "reducto://your-file-id"}' # Public URL curl -X POST https://platform.reducto.ai/parse \ -H "Authorization: Bearer $REDUCTO_API_KEY" \ -H "Content-Type: application/json" \ -d '{"input": "https://example.com/doc.pdf"}' # Reprocess previous job curl -X POST https://platform.reducto.ai/parse \ -H "Authorization: Bearer $REDUCTO_API_KEY" \ -H "Content-Type: application/json" \ -d '{"input": "jobid://7600c8c5-a52f-49d2-8a7d-d75d1b51e141"}' ``` -------------------------------- ### Install Reducto SDK Source: https://docs.reducto.ai/cookbooks/redlined-legal-contracts Install the Reducto AI SDK for Python or JavaScript using pip or npm. Ensure you have the 'requests' library for Python. ```bash pip install reductoai requests ``` ```bash npm install reductoai ``` -------------------------------- ### Complete JavaScript workflow Source: https://docs.reducto.ai/quickstart A full example demonstrating the end-to-end process from initialization to content extraction. ```javascript import Reducto from 'reductoai'; import fs from 'fs'; const client = new Reducto(); async function main() { const upload = await client.upload({ file: fs.createReadStream("fidelity-example.pdf") }); const result = await client.parse.run({ input: upload.file_id }); console.log(`Processed ${result.usage.num_pages} pages`); for (const chunk of result.result.chunks) { console.log(chunk.content); for (const block of chunk.blocks) { if (block.type === "Table") { console.log(`Found table on page ${block.bbox.page}`); } } } } main(); ``` -------------------------------- ### Install Reducto SDK Source: https://docs.reducto.ai/sdk/python Command to install the Reducto Python package via pip. ```bash pip install reductoai ``` -------------------------------- ### Initialize and use AsyncReducto Source: https://docs.reducto.ai/sdk/python/async Basic setup for the async client, requiring the await keyword for all operations. ```python import asyncio from pathlib import Path from reducto import AsyncReducto async def main(): client = AsyncReducto() # Same initialization as sync upload = await client.upload(file=Path("document.pdf")) result = await client.parse.run(input=upload.file_id) for chunk in result.result.chunks: print(chunk.content) asyncio.run(main()) ``` -------------------------------- ### Install Dataset Dependencies Source: https://docs.reducto.ai/cookbooks/batch-processing Install the required libraries for interacting with Hugging Face datasets. ```bash pip install datasets ``` ```bash npm install @huggingface/hub ``` -------------------------------- ### Install uv Source: https://docs.reducto.ai/mcp-server Install the uv package manager required for running the local MCP server. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install and use Reducto MCP server Source: https://docs.reducto.ai/quickstart Installation command for the MCP server and the corresponding tool call syntax for coding agents. ```bash uvx mcp-server-reducto --login ``` ```text parse_document(document_url="https://cdn.reducto.ai/samples/fidelity-example.pdf") ``` -------------------------------- ### Complete Document Parsing Example Source: https://docs.reducto.ai/sdk/python/parse A comprehensive example demonstrating file upload, parsing with custom enhancements and formatting, and processing the results including usage statistics and chunk content. ```python from pathlib import Path from reducto import Reducto client = Reducto() # Upload upload = client.upload(file=Path("fidelity-example.pdf")) # Parse with configuration result = client.parse.run( input=upload.file_id, enhance={ "agentic": [{"scope": "table"}], "summarize_figures": True }, formatting={ "table_output_format": "html" }, retrieval={ "chunking": {"chunk_mode": "variable"} }, settings={ "page_range": {"start": 1, "end": 5} } ) # Process results print(f"Processed {result.usage.num_pages} pages") print(f"Used {result.usage.credits} credits") print(f"View in Studio: {result.studio_link}") for i, chunk in enumerate(result.result.chunks): print(f"\n=== Chunk {i + 1} ===") print(chunk.content[:500]) # First 500 chars # Count block types block_types = {} for block in chunk.blocks: block_types[block.type] = block_types.get(block.type, 0) + 1 print(f"Block types: {block_types}") ``` -------------------------------- ### Complete Parsing Workflow (Python) Source: https://docs.reducto.ai/quickstart A full example demonstrating the complete document parsing workflow. ```python from pathlib import Path from reducto import Reducto client = Reducto() upload = client.upload(file=Path("fidelity-example.pdf")) result = client.parse.run(input=upload.file_id) print(f"Processed {result.usage.num_pages} pages") for chunk in result.result.chunks: print(chunk.content) for block in chunk.blocks: if block.type == "Table": print(f"Found table on page {block.bbox.page}") ``` -------------------------------- ### Examples of edit command usage Source: https://docs.reducto.ai/cli Provides practical examples of applying specific edits to PDF and document files using natural language instructions. ```bash reducto edit contract.pdf -i "Fill in the client name as 'Acme Corporation' and set the contract date to January 15, 2024" reducto edit document.pdf -i "Fill out the form with: Name: John Doe, Email: john@example.com, Select 'Yes' for newsletter subscription" ``` -------------------------------- ### Complete Extraction Workflow Source: https://docs.reducto.ai/sdk/python/extract A full example demonstrating file upload, schema definition, and extraction execution. ```python from pathlib import Path from reducto import Reducto client = Reducto() # Upload upload = client.upload(file=Path("fidelity-example.pdf")) # Define schema schema = { "type": "object", "properties": { "portfolio_value": { "type": "number", "description": "Total portfolio value at the end of the period" }, "total_income_ytd": { "type": "number", "description": "Total income year-to-date" }, "top_holdings": { "type": "array", "items": {"type": "string"}, "description": "Names of the top 5 holdings" } } } ``` -------------------------------- ### Complete Document Edit Workflow Source: https://docs.reducto.ai/sdk/python/edit A full example demonstrating upload, editing, and downloading the resulting file. ```python from pathlib import Path from reducto import Reducto import requests client = Reducto() # Upload form upload = client.upload(file=Path("job-application.pdf")) # Fill form with instructions result = client.edit.run( document_url=upload.file_id, edit_instructions=""" Fill in the job application with: - Applicant Name: Jane Smith - Email: jane@example.com - Phone: 555-1234 - Date: 12/25/2024 - Check the signature checkbox """, edit_options={ "color": "#000000" } ) # Download filled form response = requests.get(result.document_url) with open("filled-application.pdf", "wb") as f: f.write(response.content) print("Form filled and saved!") ``` -------------------------------- ### Quick start implementation Source: https://docs.reducto.ai/components/spreadsheet-viewer A minimal implementation of the SpreadsheetViewer component requiring a parent container with defined dimensions. ```tsx import { SpreadsheetViewer } from '@reductoai-collab/components'; import '@reductoai-collab/components/styles/spreadsheet-viewer.css'; function App() { return (
{ console.log(`Loaded ${metadata.sheetCount} sheets`); }} onError={(error) => { console.error(`Error: ${error.message}`); }} />
); } ``` -------------------------------- ### Initialize and Use Reducto Go SDK Source: https://docs.reducto.ai/sdk/go/overview A complete example demonstrating client initialization, file upload, and document parsing. ```go package main import ( "context" "fmt" "io" "os" reducto "github.com/reductoai/reducto-go-sdk" "github.com/reductoai/reducto-go-sdk/option" "github.com/reductoai/reducto-go-sdk/shared" ) func main() { // Initialize the client (reads REDUCTO_API_KEY from environment) client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY"))) // Upload a document file, _ := os.Open("invoice.pdf") defer file.Close() upload, _ := client.Upload(context.Background(), reducto.UploadParams{ File: reducto.F[io.Reader](file), }) // Parse the document result, _ := client.Parse.Run(context.Background(), reducto.ParseRunParams{ ParseConfig: reducto.ParseConfigParam{ DocumentURL: reducto.F[reducto.ParseConfigDocumentURLUnionParam]( shared.UnionString(upload.FileID), ), }, }) // Access the extracted content using union type if result.Result.Type == shared.ParseResponseResultTypeFull { fullResult := result.Result.AsUnion().(shared.ParseResponseResultFullResult) for _, chunk := range fullResult.Chunks { fmt.Println(chunk.Content) } } } ``` -------------------------------- ### Complete Go SDK workflow Source: https://docs.reducto.ai/quickstart A full example demonstrating client initialization, file upload, parsing, and content extraction. ```go package main import ( "context" "fmt" "io" "os" reducto "github.com/reductoai/reducto-go-sdk" "github.com/reductoai/reducto-go-sdk/option" "github.com/reductoai/reducto-go-sdk/shared" ) func main() { client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY"))) file, _ := os.Open("fidelity-example.pdf") defer file.Close() upload, _ := client.Upload(context.Background(), reducto.UploadParams{ File: reducto.F[io.Reader](file), }) result, _ := client.Parse.Run(context.Background(), reducto.ParseRunParams{ ParseConfig: reducto.ParseConfigParam{ DocumentURL: reducto.F[reducto.ParseConfigDocumentURLUnionParam]( shared.UnionString(upload.FileID), ), }, }) fmt.Printf("Processed %d pages\n", result.Usage.NumPages) if result.Result.Type == shared.ParseResponseResultTypeFull { chunks, _ := result.Result.Chunks.([]shared.ParseResponseResultFullResultChunk) for _, chunk := range chunks { fmt.Println(chunk.Content) } } } ``` -------------------------------- ### Clone Reducto Hybrid Infrastructure Repository Source: https://docs.reducto.ai/onprem/hybrid-vpc-azure Clone the official Reducto hybrid infrastructure repository to access the Terraform examples for Azure setup. Navigate into the Azure examples directory. ```bash git clone https://github.com/reductoai-collab/reducto-hybrid-infra.git cd reducto-hybrid-infra/examples/azure ``` -------------------------------- ### Initialize and Use Reducto SDK Source: https://docs.reducto.ai/sdk/javascript/overview Demonstrates the full workflow of initializing the client, uploading a file, and parsing its content. ```javascript import Reducto from 'reductoai'; import fs from 'fs'; // Initialize the client (reads REDUCTO_API_KEY from environment) const client = new Reducto(); // Upload a document const upload = await client.upload({ file: fs.createReadStream("invoice.pdf") }); // Parse the document const result = await client.parse.run({ input: upload.file_id }); // Access the extracted content for (const chunk of result.result.chunks) { console.log(chunk.content); } ``` -------------------------------- ### Guide Chart Processing with Custom Prompts (cURL) Source: https://docs.reducto.ai/configs/parse/chart-extraction Use custom prompts to guide the chart agent's focus. This example instructs the agent to prioritize the primary trend line and ignore confidence intervals. ```bash curl -X POST https://platform.reducto.ai/parse \ -H "Authorization: Bearer $REDUCTO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ \ "input": "reducto://your-file-id", \ "enhance": { \ "agentic": [ \ {"scope": "figure", "prompt": "Focus on the primary trend line, ignore confidence intervals"} \ ] \ } \ }' ``` -------------------------------- ### Guide Chart Processing with Custom Prompts (Node.js) Source: https://docs.reducto.ai/configs/parse/chart-extraction Use custom prompts to guide the chart agent's focus. This example instructs the agent to prioritize the primary trend line and ignore confidence intervals. ```javascript const result = await client.parse.run({ input: upload.file_id, enhance: { agentic: [ { scope: 'figure', prompt: 'Focus on the primary trend line, ignore confidence intervals' } ] } }); ``` -------------------------------- ### Guide Chart Processing with Custom Prompts (Python) Source: https://docs.reducto.ai/configs/parse/chart-extraction Use custom prompts to guide the chart agent's focus. This example instructs the agent to prioritize the primary trend line and ignore confidence intervals. ```python result = client.parse.run( input=upload.file_id, enhance={ "agentic": [ {"scope": "figure", "prompt": "Focus on the primary trend line, ignore confidence intervals"} ] } ) ``` -------------------------------- ### Basic Go SDK Upload Example Source: https://docs.reducto.ai/sdk/go/upload Demonstrates the basic usage of the Reducto Go SDK to upload a file. Ensure the REDUCTO_API_KEY environment variable is set. The file is opened, uploaded, and the resulting file ID is printed. ```go package main import ( "context" "fmt" "io" "os" reducto "github.com/reductoai/reducto-go-sdk" "github.com/reductoai/reducto-go-sdk/option" ) func main() { client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY"))) // Open file file, err := os.Open("document.pdf") if err != nil { fmt.Printf("Error opening file: %v\n", err) return } defer file.Close() // Upload upload, err := client.Upload(context.Background(), reducto.UploadParams{ File: reducto.F[io.Reader](file), }) if err != nil { fmt.Printf("Upload error: %v\n", err) return } // Use the file_id in other operations fmt.Printf("Uploaded: %s\n", upload.FileID) } ``` -------------------------------- ### Initialize Go client Source: https://docs.reducto.ai/quickstart Configure the Reducto client using an API key from the environment. ```go package main import ( "context" "fmt" "io" "os" reducto "github.com/reductoai/reducto-go-sdk" "github.com/reductoai/reducto-go-sdk/option" "github.com/reductoai/reducto-go-sdk/shared" ) func main() { // Initialize client with API key from environment client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY"))) } ``` -------------------------------- ### Markdown Hyperlink Example Source: https://docs.reducto.ai/configs/parse/additional-document-data Example of how extracted hyperlinks are formatted in markdown. ```markdown For more details, see [our methodology paper](https://example.com/methodology.pdf). ``` -------------------------------- ### Initialize and Use Async Client Source: https://docs.reducto.ai/sdk/python/overview Demonstrates how to initialize an async client and perform upload and parse operations asynchronously. Requires `asyncio` for execution. ```python import asyncio from reducto import AsyncReducto async def main(): client = AsyncReducto() upload = await client.upload(file=Path("document.pdf")) result = await client.parse.run(input=upload.file_id) return result # Run the async function result = asyncio.run(main()) ``` -------------------------------- ### Install Required Packages Source: https://docs.reducto.ai/cookbooks/web-browsing-browserbase Install the necessary Python packages for browser automation and document processing. ```bash pip install browserbase stagehand reductoai python-dotenv ``` -------------------------------- ### Initialize Reducto Client Source: https://docs.reducto.ai/cookbooks/form-filling Import the Reducto library and create a client instance. The client automatically reads the API key from the REDUCTO_API_KEY environment variable. ```python from reducto import Reducto client = Reducto() ``` ```javascript import Reducto from "reductoai"; const client = new Reducto(); ``` ```bash # Set your API key as an environment variable export REDUCTO_API_KEY="your-api-key-here" ``` -------------------------------- ### Install Required Packages Source: https://docs.reducto.ai/cookbooks/multimodal-rag-image-results Install necessary dependencies for the multimodal RAG pipeline in Python or JavaScript. ```bash pip install reductoai pinecone voyageai requests boto3 ``` ```bash npm install reductoai @aws-sdk/client-s3 @pinecone-database/pinecone voyageai ``` -------------------------------- ### HTML Highlight Example Source: https://docs.reducto.ai/configs/parse/additional-document-data Example of how highlighted text is represented in HTML using the `` tag. ```html The key finding was that revenue increased 47% year-over-year despite market headwinds. ``` -------------------------------- ### Initialize the Reducto Client Source: https://docs.reducto.ai/cookbooks/multimodal-rag-image-results Create a client instance using an API key from environment variables. ```python import os from reducto import Reducto client = Reducto(api_key=os.environ["REDUCTO_API_KEY"]) ``` ```javascript import Reducto from "reductoai"; const client = new Reducto({ apiKey: process.env.REDUCTO_API_KEY }); ``` -------------------------------- ### Configure Authentication Source: https://docs.reducto.ai/sdk/go/overview Set the API key environment variable and initialize the client. ```bash export REDUCTO_API_KEY="your_api_key_here" ``` ```go import ( "os" reducto "github.com/reductoai/reducto-go-sdk" "github.com/reductoai/reducto-go-sdk/option" ) // Recommended: pass explicitly for clarity client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY"))) ``` -------------------------------- ### Complete Reducto Workflow Source: https://docs.reducto.ai/upload/large-files A full end-to-end example demonstrating how to request a presigned URL, upload a file, and process it with Reducto. ```python import os import requests from reducto import Reducto # Step 1: Get presigned URL response = requests.post( "https://platform.reducto.ai/upload", headers={"Authorization": f"Bearer {os.environ.get('REDUCTO_API_KEY')}"} ) data = response.json() file_id = data["file_id"] presigned_url = data["presigned_url"] # Step 2: Upload to presigned URL with open("large_document.pdf", "rb") as f: requests.put(presigned_url, data=f) # Step 3: Process with Reducto client = Reducto() result = client.parse.run(input=file_id) print(f"Successfully processed {result.usage.num_pages} pages") for chunk in result.result.chunks: print(chunk.content[:200]) ``` ```javascript import Reducto from 'reductoai'; import fs from 'fs'; // Step 1: Get presigned URL const uploadResponse = await fetch('https://platform.reducto.ai/upload', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.REDUCTO_API_KEY}` }, }); const { file_id: fileId, presigned_url: presignedUrl } = await uploadResponse.json(); // Step 2: Upload to presigned URL await fetch(presignedUrl, { method: 'PUT', body: fs.readFileSync('large_document.pdf'), }); // Step 3: Process with Reducto const client = new Reducto(); const result = await client.parse.run({ input: fileId }); console.log(`Successfully processed ${result.usage.num_pages} pages`); ``` ```bash #!/bin/bash # Step 1: Get presigned URL UPLOAD_RESPONSE=$(curl -s -X POST https://platform.reducto.ai/upload \ -H "Authorization: Bearer $REDUCTO_API_KEY") FILE_ID=$(echo $UPLOAD_RESPONSE | jq -r '.file_id') PRESIGNED_URL=$(echo $UPLOAD_RESPONSE | jq -r '.presigned_url') # Step 2: Upload to presigned URL curl -X PUT "$PRESIGNED_URL" -T large_document.pdf # Step 3: Process with Reducto curl -X POST https://platform.reducto.ai/parse \ -H "Authorization: Bearer $REDUCTO_API_KEY" \ -H "Content-Type: application/json" \ -d "{\"input\": \"$FILE_ID\"}" ``` -------------------------------- ### Get Jobs OpenAPI Specification Source: https://docs.reducto.ai/api-reference/get-jobs Defines the GET /jobs endpoint, including query parameters for pagination and response structures. ```yaml openapi: 3.1.0 info: title: Reducto API version: v1.11.81-297-g4204a908d servers: - url: https://platform.reducto.ai security: [] paths: /jobs: get: summary: Get Jobs operationId: get_jobs_jobs_get parameters: - name: exclude_configs in: query required: false schema: type: boolean description: Exclude raw_config from response to reduce size default: false title: Exclude Configs description: Exclude raw_config from response to reduce size - name: cursor in: query required: false schema: anyOf: - type: string - type: 'null' description: >- Cursor for pagination. Use the next_cursor from the previous response to fetch the next page. title: Cursor description: >- Cursor for pagination. Use the next_cursor from the previous response to fetch the next page. - name: limit in: query required: false schema: type: integer maximum: 500 minimum: 1 description: >- Maximum number of jobs to return per page. Defaults to 100, max 500. default: 100 title: Limit description: Maximum number of jobs to return per page. Defaults to 100, max 500. responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/JobsResponse' '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' security: - SkippableHTTPBearer: [] components: schemas: JobsResponse: properties: jobs: items: $ref: '#/components/schemas/SingleJob' type: array title: Jobs description: >- List of jobs with their job_id, status, type, raw_config, created_at, num_pages and duration next_cursor: anyOf: - type: string - type: 'null' title: Next Cursor description: >- Cursor to fetch the next page of results. If null, there are no more results. type: object required: - jobs title: JobsResponse HTTPValidationError: properties: detail: items: $ref: '#/components/schemas/ValidationError' type: array title: Detail type: object title: HTTPValidationError SingleJob: properties: job_id: type: string title: Job Id status: type: string enum: - Pending - Completed - Failed - Idle - InProgress - Completing - Cancelled title: Status type: type: string enum: - Parse - Extract - Split - Edit - Pipeline - Classify title: Type raw_config: type: string title: Raw Config created_at: type: string format: date-time title: Created At source: anyOf: - {} - type: 'null' title: Source num_pages: anyOf: - type: integer - type: 'null' title: Num Pages total_pages: anyOf: - type: integer - type: 'null' title: Total Pages duration: anyOf: - type: number - type: 'null' title: Duration bucket: anyOf: - {} - type: 'null' title: Bucket type: object required: - job_id - status - type - raw_config - created_at - num_pages - total_pages - duration title: SingleJob ValidationError: properties: loc: items: anyOf: - type: string - type: integer type: array title: Location msg: type: string title: Message type: type: string title: Error Type input: title: Input ctx: type: object title: Context type: object required: - loc - msg - type title: ValidationError securitySchemes: SkippableHTTPBearer: type: http scheme: bearer ``` -------------------------------- ### Basic Document Parsing Source: https://docs.reducto.ai/sdk/go/parse Demonstrates the full workflow of initializing the client, uploading a file, and parsing it into structured chunks. ```go package main import ( "context" "fmt" "io" "os" reducto "github.com/reductoai/reducto-go-sdk" "github.com/reductoai/reducto-go-sdk/option" "github.com/reductoai/reducto-go-sdk/shared" ) func main() { client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY"))) // Upload file, _ := os.Open("invoice.pdf") defer file.Close() upload, _ := client.Upload(context.Background(), reducto.UploadParams{ File: reducto.F[io.Reader](file), }) // Parse result, err := client.Parse.Run(context.Background(), reducto.ParseRunParams{ ParseConfig: reducto.ParseConfigParam{ DocumentURL: reducto.F[reducto.ParseConfigDocumentURLUnionParam]( shared.UnionString(upload.FileID), ), }, }) if err != nil { fmt.Printf("Parse error: %v\n", err) return } // Access results using union type if result.Result.Type == shared.ParseResponseResultTypeFull { fullResult := result.Result.AsUnion().(shared.ParseResponseResultFullResult) for _, chunk := range fullResult.Chunks { fmt.Println(chunk.Content) for _, block := range chunk.Blocks { fmt.Printf(" %s on page %d\n", block.Type, block.Bbox.Page) } } } else if result.Result.Type == shared.ParseResponseResultTypeURL { urlResult := result.Result.AsUnion().(shared.ParseResponseResultURLResult) fmt.Printf("Large document - fetch from URL: %s\n", urlResult.URL) } } ``` -------------------------------- ### Initialize S3 client Source: https://docs.reducto.ai/cookbooks/multimodal-rag-image-results Set up the AWS S3 client using environment variables for the bucket name. ```python import boto3 s3 = boto3.client("s3") bucket_name = os.environ["S3_BUCKET_NAME"] ``` ```javascript import { S3Client, PutObjectCommand, GetBucketLocationCommand } from "@aws-sdk/client-s3"; const s3 = new S3Client({ region: "us-east-1" }); // Will be updated after getting bucket region const bucketName = process.env.S3_BUCKET_NAME; ``` -------------------------------- ### Initialize Pinecone and VoyageAI Clients Source: https://docs.reducto.ai/cookbooks/multimodal-rag-image-results Set up the necessary clients for Pinecone vector storage and VoyageAI embedding generation. ```python from pinecone import Pinecone import voyageai pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"]) index = pc.Index("multimodal-rag") vo = voyageai.Client(api_key=os.environ["VOYAGEAI_API_KEY"]) ``` ```javascript import { Pinecone } from "@pinecone-database/pinecone"; import { VoyageAIClient } from "voyageai"; const pc = new Pinecone({ apiKey: process.env.PINECONE_API_KEY }); const index = pc.index("multimodal-rag"); const vo = new VoyageAIClient({ apiKey: process.env.VOYAGEAI_API_KEY }); ``` -------------------------------- ### Markdown Table Output Example Source: https://docs.reducto.ai/configs/parse/chart-extraction Example of data extracted from a chart and formatted as a markdown table. This is the standard output for processed chart data. ```markdown | Date | Revenue ($M) | Expenses ($M) | | --- | --- | --- | | 2020-01 | 125.4 | 98.2 | | 2020-02 | 142.8 | 105.1 | | 2020-03 | 168.5 | 112.7 | ``` -------------------------------- ### Parse Input Options Examples Source: https://docs.reducto.ai/sdk/javascript/parse Illustrates various ways to provide input to the `client.parse.run()` method, including file IDs from uploads, public URLs, S3 presigned URLs, and reprocessing previous job IDs. ```javascript // From upload const result = await client.parse.run({ input: upload.file_id }); // Public URL const result = await client.parse.run({ input: "https://example.com/doc.pdf" }); // Presigned S3 URL const result = await client.parse.run({ input: "https://bucket.s3.amazonaws.com/doc.pdf?X-Amz-..." }); // Reprocess previous job const result = await client.parse.run({ input: "jobid://7600c8c5-a52f-49d2-8a7d-d75d1b51e141" }); ``` -------------------------------- ### Clone the infrastructure repository Source: https://docs.reducto.ai/onprem/hybrid-vpc-aws Initializes the local environment by cloning the required infrastructure repository. ```bash git clone https://github.com/reductoai-collab/reducto-hybrid-infra.git cd reducto-hybrid-infra ``` -------------------------------- ### Example API Response with Extracted Data Source: https://docs.reducto.ai/extract/overview This is an example of the JSON response received after successfully calling the /extract API. It contains the extracted financial data, job ID, usage details, and a studio link. ```json { "result": [ { "portfolio_increase": 21000.37, "total_income_ytd": 23278.62, "top_holdings": [ "Johnson & Johnson (JNJ)", "Apple Inc (AAPL)", "NH Portfolio 2015 Delphi", "Corp Jr Sb Nt Slm Corp", "Spi Lkd Nt (OSM)" ] } ], "job_id": "9531166f-9725-4854-8096-459785a33972", "usage": {"num_fields": 7, "num_pages": 3, "credits": 10.0}, "studio_link": "https://studio.reducto.ai/job/9531166f-..." } ``` -------------------------------- ### Configuration Examples for Parse API Source: https://docs.reducto.ai/sdk/javascript/parse Provides examples of how to configure various aspects of the parsing process, including chunking, table output format, agentic mode, figure summaries, page ranges, and block filtering. ```APIDOC ## Configuration Examples ### Chunking By default, Parse returns the entire document as one chunk. For RAG applications, use variable chunking: ```javascript const result = await client.parse.run({ input: upload.file_id, retrieval: { chunking: { chunk_mode: "variable" // Options: "disabled", "variable", "page", "section" } } }); ``` ### Table Output Format Control how tables appear in the output: ```javascript const result = await client.parse.run({ input: upload.file_id, formatting: { table_output_format: "html" // Options: "dynamic", "html", "md", "json", "csv" } }); ``` ### Agentic Mode Use LLM to review and correct parsing output: ```javascript const result = await client.parse.run({ input: upload.file_id, enhance: { agentic: [ { scope: "text" }, // For OCR correction { scope: "table" }, // For table structure fixes { scope: "figure" } // For chart extraction ] } }); ``` ### Figure Summaries Generate descriptions for charts and images: ```javascript const result = await client.parse.run({ input: upload.file_id, enhance: { summarize_figures: true } }); ``` ### Page Range Process only specific pages: ```javascript const result = await client.parse.run({ input: upload.file_id, settings: { page_range: { start: 1, end: 10 } } }); ``` ### Filter Blocks Remove specific content types from output: ```javascript const result = await client.parse.run({ input: upload.file_id, retrieval: { filter_blocks: ["Header", "Footer", "Page Number"] } }); ``` ``` -------------------------------- ### Initialize Go SDK Client Source: https://docs.reducto.ai/agent-guide Explicitly initialize the Go client using the API key from environment variables. ```go client := reducto.NewClient(option.WithAPIKey(os.Getenv("REDUCTO_API_KEY"))) ``` -------------------------------- ### GET /version Source: https://docs.reducto.ai/api-reference/get-version Retrieves the current version string of the Reducto API. ```APIDOC ## GET /version ### Description Retrieves the current version of the Reducto API. ### Method GET ### Endpoint /version ### Response #### Success Response (200) - **version** (string) - The current version of the API. #### Response Example "v1.11.81-297-g4204a908d" ```