# Plans & Pricing Source: https://docs.thedrive.ai/account/plans-pricing Compare The Drive AI plans and choose the right one for you ## Overview The Drive AI offers flexible pricing for individuals and teams. Everyone starts with a **Free** plan and can upgrade to **Premium** or **Max** for more AI power, storage, and integrations. Teams can create **Team Workspaces** for collaborative file management. ## Workspaces The Drive AI uses workspaces to organize your files. There are two types: **For individuals** * One per account (created automatically) * Single user only * Free, Premium, or Max plan * Cannot be deleted or recreated **For collaboration** * Up to 50 team members * Different access levels * Single billing account (managed by owner) * Create multiple team workspaces ### Switching Workspaces To switch between workspaces or create a new team workspace: 1. Click the **workspace name** at the top of the left sidebar 2. A dropdown shows all your workspaces 3. Select a workspace to switch, or click **Create Workspace** to create a new team workspace *** ## Personal Plans **\$0** — Free forever Get started with essential AI file management. **\$199.99/year** More AI power and storage for regular use. **\$999.99/year** Unlimited AI, all integrations, and maximum storage. ### Feature Comparison | Feature | Free | Premium | Max | | --------------------- | ------------------------ | ---------------------------------- | ------------------------------- | | **AI Steps** | 10/day, 300/month | 100/day, 3,000/month | Unlimited | | **Auto-Organization** | 5 files/month | 100 files/month | Unlimited | | **Storage** | 1 GB (up to 50 files) | 20 GB (up to 500 files) | 500 GB (unlimited files) | | **File Types** | Text files only | All formats (images, video, audio) | All formats | | **AI Models** | Standard | Multiple (GPT-5, Claude) | Multiple (GPT-5, Claude) | | **Rate Limits** | Rate limited during peak | Higher rate limits | Highest rate limits | | **Email Sync** | — | — | Gmail, Outlook, Slack, Teams | | **Cloud Storage** | — | — | Google Drive, OneDrive, Dropbox | | **E-Sign** | — | — | Included | | **File Requests** | — | — | Included | | **Support** | Community | Standard | Premium support | | **Mobile Apps** | Yes | Yes | Yes | All plans include core features: AI file agent, auto-organization, content-based search, grounded answers, mobile apps, and security (AES-256 encryption, malware detection, CASA certified). *** ## Team Workspace Pricing For teams that need to collaborate on files together. **\$500/month** per workspace Includes a **1-month free trial** for each new team workspace ### What's Included * **Up to 50 team members** per workspace * **Role-based access levels** (Owner, Admin, Member, Viewer) * **Centralized billing** managed by workspace owner * **All Max features** for every team member * **Shared file organization** across the team * **Team-wide AI capabilities** * **Multiple integrations** in a shared workspace ### Creating a Team Workspace Click the workspace name at the top of the left sidebar. Click **Create Workspace** at the bottom of the dropdown. Enter a name for your team workspace. Your 1-month free trial begins immediately. Credit card details required to start. Add team members and assign access levels. ### After the Free Trial After your 1-month free trial ends: * You will be charged. * Billing is **\$500/month** per team workspace * The workspace owner manages billing * Cancel anytime—workspace remains accessible until the end of the billing period * Workspace will be in read-only mode * Delete workspace to delete all files. You can create multiple team workspaces. Each workspace has its own 1-month free trial and separate \$500/month billing. *** ## Plan Details ### Free Plan The Free plan is perfect for: * Trying out The Drive AI * Light personal use * Text document organization Use Chat Mode and Agent Mode up to 10 times per day. Monthly cap of 300 steps. Works with PDF, DOCX, DOC, TXT, RTF, XLSX, XLS, CSV, PPTX, and PPT files. Does not include images, audio, or video. The AI can automatically organize up to 5 files per month. Manual organization is still available. Store up to 1 GB of files, with a maximum of 50 files. ### Premium Plan The Premium plan is ideal for: * Regular users with growing file collections * Professionals who work with diverse file types * Anyone who needs more AI power Significantly more AI capacity for daily use. Full support for documents, spreadsheets, presentations, images with OCR, audio with transcription, and video analysis. Organize up to 100 files per month automatically. 20x more storage than Free, with up to 500 files. Access to GPT-5, Claude, and other advanced AI models for better results. Higher rate limits and priority access during peak demand. ### Max Plan The Max plan is for power users who need everything: * Unlimited AI with no daily caps * Full integration suite (email, cloud storage, Slack, Teams) * E-Sign and File Requests * Maximum storage No daily or monthly limits. Use Chat Mode and Agent Mode as much as you need. No limits on automatic file organization. Massive storage with no file count limits. Connect Gmail, Outlook, Slack, and Microsoft Teams for automatic file imports. Import and export files with Google Drive, OneDrive, and Dropbox. Send PDFs for legally binding electronic signatures. Collect documents from anyone with checklists, reminders, and auto-organization. Priority support with faster response times. *** ## Pricing Details ### Annual Billing | Plan | Annual Price | Monthly Equivalent | Savings | | ----------- | ------------- | ------------------ | ------------------------ | | **Free** | \$0 | \$0 | — | | **Premium** | \$199.99/year | \~\$16.67/month | \$39.89 (2 months free) | | **Max** | \$999.99/year | \~\$83.33/month | \$199.89 (2 months free) | Premium and Max are billed annually. Cancel anytime—you retain access until the end of your billing period. ## How to Upgrade Log in to your The Drive AI account at [thedrive.ai](https://thedrive.ai). Click on your profile and navigate to **Settings** > **Billing**. Choose **Premium** or **Max**. Enter your payment information and confirm the subscription. Your account is upgraded immediately. All features for your plan are now available. ## Managing Your Subscription ### View Current Plan Go to **Settings** > **Billing** to see: * Your current plan * Billing cycle dates * Storage usage * AI step usage ### Cancel Subscription To cancel your subscription: 1. Go to **Settings** > **Billing** 2. Click **Cancel Subscription** 3. Confirm cancellation When you cancel, you keep access until the end of your current billing period. After that, your account reverts to the Free plan. ### What Happens When You Downgrade? If you cancel or downgrade: * Your files remain in your workspace * Files over your plan's storage limit become read-only until you delete some * Media files (images, audio, video) become inaccessible on the Free plan * AI steps and auto-organization revert to the lower plan's limits * Integrations exclusive to your previous plan are paused ## Frequently Asked Questions There is no free trial for personal plans. However, the Free plan lets you experience core features before upgrading. We accept all major credit cards (Visa, Mastercard, American Express) and PayPal. Yes. You can upgrade from Premium to Max or downgrade from Max to Premium at any time. Changes take effect on your next billing cycle. If you're not satisfied within the first 14 days, contact support for a full refund. Team workspaces allow up to 50 people to collaborate with different access levels. Each team workspace costs \$500/month after a 1-month free trial. The workspace owner manages billing. You can create multiple team workspaces, each with its own trial and billing. Personal workspaces are for individual use only (1 user). You get one automatically when you sign up, and it cannot be deleted. Team workspaces support up to 50 members with role-based access, making them ideal for collaboration. ## Need Help? Have questions about plans or billing? Reach out to our support team. # Analyze Document Source: https://docs.thedrive.ai/api-reference/analysis/analyze-document /openapi.json post /api/v1/analyze Analyze a document by asking questions. Unlike `/extract`, this endpoint can **compute, reason, and derive** values that aren't explicitly written in the document. Upload a file (or provide a URL) along with a typed schema. Each field must have a `type` and `description`. **Example schema**: ```json { "total_cost": {"type": "number", "description": "Sum all line item amounts"}, "is_auto_renew": {"type": "boolean", "description": "Does this contract auto-renew?"}, "risk_level": {"type": "string", "enum": ["low", "medium", "high"], "description": "Legal risk level"} } ``` **Supported types**: `string`, `number`, `integer`, `boolean`, `array`, `object` Every answer includes: - The computed answer (type-enforced) - Reasoning explaining how it was derived - Source text snippets from the document - Confidence level **Pricing**: 2 credits/page (min 5) for documents, 10 credits for websites. # Cross-Document Analysis Source: https://docs.thedrive.ai/api-reference/analysis/cross-document-analysis /openapi.json post /api/v1/analyze/cross Analyze and cross-reference multiple documents together. Unlike `/analyze` (single document) or `/analyze/batch` (many documents independently), this endpoint lets the agent reason **across** all documents simultaneously. **Use cases**: - Validate an invoice against a contract or purchase order - Check that a report's numbers match a source spreadsheet - Compare terms across multiple agreements - Reconcile data from different sources Upload 2-5 files and/or provide URLs. Each document gets a label (auto-generated from filename, or you can provide custom labels). The agent can search, read, and compare data across all documents. Provide a typed schema — each field has a type and description. **Example**: ```json { "rates_match": {"type": "boolean", "description": "Do the hourly rates on the invoice match the contract?"}, "total_valid": {"type": "boolean", "description": "Does the invoice total equal the sum of line items?"}, "correct_vendor": {"type": "boolean", "description": "Is the vendor name on the invoice the same as the contracting party?"} } ``` **Pricing**: 5 credits/document + 3 credits/page (minimum 10). # Batch Analyze Source: https://docs.thedrive.ai/api-reference/batch/batch-analyze /openapi.json post /api/v1/analyze/batch Submit multiple files or URLs for analysis with a single schema. Each item is processed concurrently. Returns a batch_id to poll. **Poll**: `GET /api/v1/jobs/batch/{batch_id}` **Limits**: Maximum 10 items per batch. # Batch Extract Source: https://docs.thedrive.ai/api-reference/batch/batch-extract /openapi.json post /api/v1/extract/batch Submit multiple files or URLs for extraction with a single schema. Each item is processed concurrently. Returns a batch_id to poll. **Poll**: `GET /api/v1/jobs/batch/{batch_id}` **Limits**: Maximum 20 items per batch. # Make a Decision Source: https://docs.thedrive.ai/api-reference/decision/make-a-decision /openapi.json post /api/v1/decide Make **one coherent decision** about a document (or pure context), guided by explicit instructions and caller-supplied context. Unlike `/analyze` — which researches each schema field independently — `/decide` answers the whole schema in a single reasoning pass with tools (reading, search, computation, vision) available on the way. Use it when the fields are facets of one judgment: where to file a document, which branch a workflow should take, what to rename a file. **Request parts**: - `instructions` (required): what decision to make and what makes it correct. - `context` (optional): JSON array of `{"label": ..., "content": ...}` blocks — folder listings, sibling decisions, established facts. Authoritative for the decision. - `schema` (required): typed schema of the decision fields. - `file`/`url` (optional): the document. Omit both for context-only decisions. **Response**: `data` (schema-shaped, enforced by structured outputs), per-field `confidence`, a single `reasoning` string for the whole decision, and `sources`. **Failures are errors**: provider overload returns `503` with `Retry-After`; provider errors return `502`. A `200` always contains a real decision. **Pricing**: 2 credits/page (min 5) for documents, 10 for websites, 5 for context-only. # Extract Structured Data Source: https://docs.thedrive.ai/api-reference/extraction/extract-structured-data /openapi.json post /api/v1/extract Extract structured data from a file or URL using AI. Upload a file (or provide a URL) along with a typed JSON schema describing the fields you want extracted. Each field must have a `type` and `description`. Returns structured data matching your schema with **guaranteed type conformance**. **Example schema**: ```json { "invoice_number": {"type": "string", "description": "The invoice number"}, "total_amount": {"type": "number", "description": "Total amount due", "required": true}, "status": {"type": "string", "enum": ["paid", "unpaid", "overdue"]}, "line_items": { "type": "array", "description": "Each line item", "items": { "type": "object", "properties": { "description": {"type": "string"}, "quantity": {"type": "integer"}, "unit_price": {"type": "number"} } } } } ``` **Supported types**: `string`, `number`, `integer`, `boolean`, `array`, `object` **Supported formats**: PDF, DOCX, XLSX, PPTX, CSV, images (JPG, PNG), and any file type supported by the markdown conversion endpoint. **Vision mode**: For images or scanned documents, set `use_vision=true` for highest accuracy on visual content. # Get Batch Status Source: https://docs.thedrive.ai/api-reference/jobs/get-batch-status /openapi.json get /api/v1/jobs/batch/{batch_id} Poll the status of a batch operation. Returns all results when complete. # Get Task Status Source: https://docs.thedrive.ai/api-reference/jobs/get-task-status /openapi.json get /api/v1/jobs/{task_id} Poll the status of an async extract or analyze task. Returns the result when complete. # Get Webhook Deliveries Source: https://docs.thedrive.ai/api-reference/jobs/get-webhook-deliveries /openapi.json get /api/v1/jobs/{task_id}/deliveries Check the delivery status of webhooks for a task. Returns a list of delivery attempts with status, response code, and timestamps. Useful for debugging "I didn't receive my webhook" scenarios. ## Webhook Verification Every webhook includes two headers for security: - **`X-TDA-Delivery-ID`** — Unique delivery ID. Use this to deduplicate retries. - **`X-TDA-Signature`** — HMAC-SHA256 signature of the raw request body. **To verify a webhook is authentic**, compute the HMAC of the raw body using your webhook signing secret and compare: ```python import hmac, hashlib def verify_webhook(raw_body: bytes, signature_header: str, secret: str) -> bool: expected = "sha256=" + hmac.new( secret.encode(), raw_body, hashlib.sha256 ).hexdigest() return hmac.compare_digest(expected, signature_header) # In your webhook handler: is_valid = verify_webhook( raw_body=request.body(), signature_header=request.headers["X-TDA-Signature"], secret="your-webhook-signing-secret", ) ``` ## Retry Policy Failed deliveries are retried automatically: 3 immediate retries, then background retries at 1m, 5m, 15m, 30m, 1h, 2h, 4h (8 total attempts). 4xx responses are treated as permanent failures and are not retried. Delivery statuses: `pending`, `delivered`, `failed` (will retry), `dead` (exhausted). # Convert to Markdown Source: https://docs.thedrive.ai/api-reference/markdown/convert-to-markdown /openapi.json post /api/v1/markdown/convert Convert a file or URL to markdown. **File Upload**: Use multipart/form-data with a `file` field. **URL Fetch**: Provide a `url` field. For websites (HTML), uses a headless browser to render the page before converting — handles JS-heavy sites. **Supported formats**: PDF, DOCX, PPTX, XLSX, CSV, HTML, images, audio, code files, and any URL via headless browser rendering. # Generate Thumbnail Source: https://docs.thedrive.ai/api-reference/thumbnails/generate-thumbnail /openapi.json post /api/v1/thumbnails/generate Generate a thumbnail from a file upload or URL. **File Upload**: Use multipart/form-data with a `file` field. **URL Fetch**: Use JSON body with `url` field. Optionally include `url_headers` for authenticated URLs. **Options**: - `width`, `height`: Max dimensions (default 600x400) - `quality`: JPEG quality 1-100 (default 95) - `sync`: Wait for result (true) or return job ID (false) - `webhook_url`: URL to POST result when complete (async only) - `response_type`: "url" returns storage URL, "base64" returns encoded image # Analyze Source: https://docs.thedrive.ai/developer/analyze Compute, reason, and derive answers from documents Unlike `/extract` which pulls explicitly stated values, `/analyze` uses a multi-step reasoning agent that can compute, infer, and derive answers that aren't written in the document. ## When to use Analyze vs Extract | Use case | Endpoint | | -------------------------------------- | -------------- | | "What is the invoice number?" | `/extract` | | "What is the sum of all line items?" | **`/analyze`** | | "Does this contract auto-renew?" | **`/analyze`** | | "Rate the legal risk: low/medium/high" | **`/analyze`** | | "Pull the vendor name and address" | `/extract` | | "Are any line items duplicated?" | **`/analyze`** | Rule of thumb: if the answer is directly stated in the document, use `/extract`. If it requires computation, comparison, or judgment, use `/analyze`. ## Example ```python Python theme={null} from thedriveai import TheDriveAI client = TheDriveAI(api_key="tda_live_...") result = client.analyze( file="contract.pdf", schema={ "total_value": { "type": "number", "description": "Total contract value (sum all payment amounts)" }, "auto_renews": { "type": "boolean", "description": "Does this contract auto-renew?" }, "termination_notice_days": { "type": "integer", "description": "How many days notice required to terminate?" }, "risk_level": { "type": "string", "enum": ["low", "medium", "high"], "description": "Overall legal risk level" }, }, ) print(result.data) # {"total_value": 250000, "auto_renews": true, "termination_notice_days": 90, "risk_level": "medium"} print(result.reasoning["auto_renews"]) # "Section 8.2 states 'This agreement shall automatically renew for successive one-year terms # unless either party provides written notice of non-renewal at least 90 days prior...'" print(result.sources["total_value"]) # ["Year 1: $100,000 (Section 4.1)", "Year 2: $150,000 (Section 4.2)"] ``` ```typescript TypeScript theme={null} import { TheDriveAI } from "@thedriveai/sdk"; import { readFileSync } from "fs"; const client = new TheDriveAI({ apiKey: "tda_live_..." }); const result = await client.analyze({ file: readFileSync("contract.pdf"), schema: { total_value: { type: "number", description: "Total contract value (sum all payment amounts)" }, auto_renews: { type: "boolean", description: "Does this contract auto-renew?" }, termination_notice_days: { type: "integer", description: "How many days notice required to terminate?" }, risk_level: { type: "string", enum: ["low", "medium", "high"], description: "Overall legal risk level" }, }, }); console.log(result.data.total_value); // 250000 console.log(result.reasoning?.auto_renews); // "Section 8.2 states..." console.log(result.sources?.total_value); // ["Year 1: $100,000...", "Year 2: $150,000..."] ``` ```bash cURL theme={null} curl -X POST https://dev.thedrive.ai/api/v1/analyze \ -H "X-API-Key: tda_live_..." \ -F file=@contract.pdf \ -F 'schema={ "total_value": {"type": "number", "description": "Total contract value"}, "auto_renews": {"type": "boolean", "description": "Does this contract auto-renew?"} }' ``` Works with Pydantic and Zod too — see [Schemas](/developer/schemas). ## Response | Field | Description | | -------------- | ---------------------------------------------------------------- | | `data` | Computed answers, type-enforced to match your schema | | `confidence` | Per-field confidence scores (0.0 - 1.0) | | `reasoning` | Per-field step-by-step explanation of how the answer was derived | | `sources` | Per-field text snippets from the document supporting the answer | | `steps` | Agent tool call trace (only when `include_steps=true`) | | `total_pages` | Number of pages in the document | | `credits_used` | Credits consumed | ### Confidence scores | Range | Meaning | | ----------- | ------------------------------------------------- | | 0.95 - 1.0 | Directly stated or computed from unambiguous data | | 0.80 - 0.94 | Clearly derivable, minor interpretation required | | 0.60 - 0.79 | Reasonably inferred, some assumptions made | | 0.30 - 0.59 | Ambiguous or indirect evidence | | 0.00 - 0.29 | Speculative or not found | ## How the agent works The analyze endpoint runs a multi-step reasoning agent that has access to: | Tool | Purpose | | ----------------- | ------------------------------------------------------------------------------------ | | `search` | Semantic + keyword search. Understands synonyms and handles typos. | | `read_pages` | Read specific pages by number | | `regex_search` | Find patterns — dates, amounts, percentages, IDs | | `compute` | Execute Python code for calculations. All math goes through code, never mental math. | | `extract_table` | Get structured table data from PDFs, CSVs, or spreadsheets | | `view_page_image` | Visual analysis of scanned pages, charts, or diagrams (PDFs only) | The agent plans its approach, navigates to relevant sections, gathers evidence, cross-references, and verifies its answer before responding. Set `include_steps=true` to see the full reasoning trace. ## Pricing | Input | Cost | | --------- | -------------------------- | | Documents | 2 credits/page (minimum 5) | | Websites | 10 credits flat | # Cross-Analyze Source: https://docs.thedrive.ai/developer/cross-analyze Validate and cross-reference across multiple documents Cross-analyze lets the agent reason **across** 2-5 documents simultaneously. Unlike `/analyze/batch` (which processes documents independently), cross-analyze compares, validates, and reconciles data between documents. ## Use cases * Validate an invoice against a contract or purchase order * Check that a report's numbers match a source spreadsheet * Compare terms across multiple agreements * Reconcile data from different sources ## Example ```python Python theme={null} from thedriveai import TheDriveAI client = TheDriveAI(api_key="tda_live_...") result = client.analyze_cross( files=["invoice.pdf", "contract.pdf"], document_labels=["invoice", "contract"], schema={ "rates_match": { "type": "boolean", "description": "Do the hourly rates on the invoice match the contract?" }, "total_valid": { "type": "boolean", "description": "Does the invoice total equal the sum of line items?" }, "correct_vendor": { "type": "boolean", "description": "Is the vendor name on the invoice the same as the contracting party?" }, }, ) print(result.data) # {"rates_match": false, "total_valid": true, "correct_vendor": true} print(result.sources["rates_match"]) # ['[invoice] "Rate: $150.00/hr"', '[contract] "Hourly rate: $125.00"'] print(result.reasoning["rates_match"]) # "Invoice hourly rate ($150) differs from contract rate ($125). Discrepancy of $25/hr." for doc in result.documents: print(f"{doc.label}: {doc.total_pages} pages") ``` ```typescript TypeScript theme={null} import { TheDriveAI } from "@thedriveai/sdk"; import { readFileSync } from "fs"; const client = new TheDriveAI({ apiKey: "tda_live_..." }); const result = await client.analyzeCross({ files: [readFileSync("invoice.pdf"), readFileSync("contract.pdf")], documentLabels: ["invoice", "contract"], schema: { rates_match: { type: "boolean", description: "Do the hourly rates on the invoice match the contract?" }, total_valid: { type: "boolean", description: "Does the invoice total equal the sum of line items?" }, correct_vendor: { type: "boolean", description: "Is the vendor name consistent?" }, }, }); console.log(result.data.rates_match); // false console.log(result.sources?.rates_match); // ['[invoice] "Rate: $150.00/hr"', '[contract] "Hourly rate: $125.00"'] ``` ```bash cURL theme={null} curl -X POST https://dev.thedrive.ai/api/v1/analyze/cross \ -H "X-API-Key: tda_live_..." \ -F files=@invoice.pdf \ -F files=@contract.pdf \ -F 'document_labels=["invoice", "contract"]' \ -F 'schema={ "rates_match": {"type": "boolean", "description": "Do hourly rates match?"}, "total_valid": {"type": "boolean", "description": "Does the total equal line item sum?"} }' ``` Works with Pydantic and Zod too — see [Schemas](/developer/schemas). ## Providing documents You can mix uploaded files and URLs in a single request: ```python Python theme={null} result = client.analyze_cross( files=["local_invoice.pdf"], urls={"contract": "https://example.com/contract.pdf"}, document_labels=["invoice"], schema={...}, ) ``` ```typescript TypeScript theme={null} const result = await client.analyzeCross({ files: [readFileSync("local_invoice.pdf")], urls: { contract: "https://example.com/contract.pdf" }, documentLabels: ["invoice"], schema: {...}, }); ``` ### URL formats | Format | Example | Label behavior | | ------ | --------------------------------------------------------- | ---------------------------- | | Array | `urls=["https://a.com/inv.pdf", "https://b.com/ctr.pdf"]` | Auto-generated from filename | | Object | `urls={"invoice": "https://a.com/inv.pdf"}` | Uses the key as the label | ### Document labels Each document gets a label used in source citations (`[invoice] "..."`, `[contract] "..."`). Labels are auto-generated from filenames, or you can set them explicitly via `document_labels` (for uploaded files) or URL object keys (for URLs). ## Response Same structure as `/analyze`, plus per-document metadata: | Field | Description | | -------------- | ------------------------------------------------------------------- | | `data` | Computed answers, type-enforced | | `confidence` | Per-field confidence scores (0.0 - 1.0) | | `reasoning` | Per-field explanation referencing specific documents | | `sources` | Per-field text snippets prefixed with `[doc_label]` | | `documents` | List of `{label, filename, content_type, total_pages, text_length}` | | `total_pages` | Combined page count across all documents | | `credits_used` | Credits consumed | ## Limits | Constraint | Value | | --------------------- | -------------------------------------- | | Documents per request | 2 - 5 | | Total combined size | 100 MB | | Fields per schema | 10 | | Timeout | 5 minutes (use `sync=false` for async) | ## Pricing 5 credits per document + 3 credits per page (minimum 10). # Decide Source: https://docs.thedrive.ai/developer/decide Make one coherent decision about a document, guided by your instructions and context `/analyze` researches each schema field independently. `/decide` answers the whole schema in a **single reasoning pass** — use it when the fields are facets of one judgment: where to file a document, which branch a workflow should take, what to rename a file. ## When to use Decide vs Analyze | Use case | Endpoint | | ------------------------------------------------------------------ | ------------- | | "Sum all line items" and "Does it auto-renew?" (independent facts) | `/analyze` | | "Which folder does this belong in, and what should it be named?" | **`/decide`** | | "Approve, reject, or escalate this claim — and why?" | **`/decide`** | | "Rate the legal risk of each clause" | `/analyze` | | "Route this ticket to the right team with a priority" | **`/decide`** | Rule of thumb: if the fields are separate questions about the document, use `/analyze`. If they describe one decision — where every field must be consistent with the others — use `/decide`. ## What makes it different * **`instructions` is a first-class parameter** — you state the task and what makes a decision correct, instead of encoding it into field descriptions. * **`context` carries your situational data** — folder trees, sibling decisions, established facts. Labeled blocks the agent treats as authoritative. * **One reasoning pass** — every field comes from the same judgment, so `reasoning` is a single string and the fields never contradict each other. * **Failures are errors** — provider overload returns `503` with `Retry-After`, provider errors return `502`. A `200` always contains a real decision, never null answers with zero confidence. * **The document is optional** — pass only `context` for pure-context decisions. ## Example ```python Python theme={null} from thedriveai import TheDriveAI client = TheDriveAI(api_key="tda_live_...") result = client.decide( file="invoice_march.pdf", instructions="Choose the best folder for this document and a clear filename.", context=[ {"label": "folders", "content": "/Finance/2025\n/Legal/Contracts\n/HR"}, {"label": "naming convention", "content": "type-year-month-vendor.pdf"}, ], schema={ "folder": {"type": "string", "description": "Destination folder path"}, "rename_to": {"type": "string", "description": "Filename following the convention"}, }, ) print(result.data) # {"folder": "/Finance/2025", "rename_to": "invoice-2025-03-acme.pdf"} print(result.reasoning) # "March invoice from Acme — belongs with the other 2025 finance documents. # Named per the type-year-month-vendor convention." print(result.confidence) # {"folder": 0.95, "rename_to": 0.9} ``` ```typescript TypeScript theme={null} import { TheDriveAI } from "@thedriveai/sdk"; import { readFileSync } from "fs"; const client = new TheDriveAI({ apiKey: "tda_live_..." }); const result = await client.decide({ file: readFileSync("invoice_march.pdf"), instructions: "Choose the best folder for this document and a clear filename.", context: [ { label: "folders", content: "/Finance/2025\n/Legal/Contracts\n/HR" }, { label: "naming convention", content: "type-year-month-vendor.pdf" }, ], schema: { folder: { type: "string", description: "Destination folder path" }, rename_to: { type: "string", description: "Filename following the convention" }, }, }); console.log(result.data.folder); // "/Finance/2025" console.log(result.reasoning); // one rationale for the whole decision ``` ```bash cURL theme={null} curl -X POST https://dev.thedrive.ai/api/v1/decide \ -H "X-API-Key: tda_live_..." \ -F file=@invoice_march.pdf \ -F 'instructions=Choose the best folder for this document and a clear filename.' \ -F 'context=[ {"label": "folders", "content": "/Finance/2025\n/Legal/Contracts\n/HR"}, {"label": "naming convention", "content": "type-year-month-vendor.pdf"} ]' \ -F 'schema={ "folder": {"type": "string", "description": "Destination folder path"}, "rename_to": {"type": "string", "description": "Filename following the convention"} }' ``` Works with Pydantic and Zod too — see [Schemas](/developer/schemas). ## Request parts | Part | Required | Description | | --------------- | -------- | ----------------------------------------------------------------------------------------------------- | | `instructions` | Yes | What decision to make, and what makes it correct. Up to 20,000 chars. | | `schema` | Yes | Typed schema of the decision fields (max 10 fields). | | `context` | No | JSON array of `{"label", "content"}` blocks, or a JSON string. Up to 50 blocks / 200,000 chars total. | | `file` / `url` | No | The document. Omit both for context-only decisions. | | `include_steps` | No | Include the agent's tool-call trace. | At least one of `file`, `url`, or `context` is required — a decision needs something to decide from. ## Response | Field | Description | | -------------- | ---------------------------------------------------------------------- | | `data` | The decision, shaped by your schema and enforced by structured outputs | | `confidence` | Per-field confidence scores (0.0 - 1.0) | | `reasoning` | A **single** rationale for the whole decision | | `sources` | Text snippets supporting the decision | | `steps` | Agent tool call trace (only when `include_steps=true`) | | `credits_used` | Credits consumed | ## Error handling A `200` always contains a real decision. Upstream AI failures surface as real HTTP errors: | Status | Meaning | What to do | | ------ | ----------------------------------- | ------------------------------------------------------------------------------------- | | `503` | Provider overloaded or rate-limited | Retry with backoff — honors the `Retry-After` header (the SDKs do this automatically) | | `502` | Provider failed (not retryable) | Surface the error | ## Pricing | Input | Cost | | ------------ | -------------------------- | | Documents | 2 credits/page (minimum 5) | | Websites | 10 credits flat | | Context-only | 5 credits flat | # Developer Platform Source: https://docs.thedrive.ai/developer/introduction Extract, analyze, and cross-reference any document with a single API call The same document intelligence that powers [The Drive AI](https://thedrive.ai), available as an API. Upload a PDF, spreadsheet, image, or URL — get back typed JSON matching your schema. This is not a full API for The Drive AI product. These are standalone document intelligence endpoints — the same ones we use internally — exposed for developers and AI agents that need to process documents programmatically. Pull structured fields from a document. Fast, schema-enforced, type-safe. Compute, reason, and derive answers that aren't explicitly written in the document. Validate and cross-reference across 2-5 documents simultaneously. ## How it works 1. Define a schema — describe the fields you want, with types 2. Send a document — upload a file or pass a URL 3. Get structured data — typed JSON, confidence scores, source citations ```python Python theme={null} from thedriveai import TheDriveAI client = TheDriveAI(api_key="tda_live_...") result = client.extract( file="invoice.pdf", schema={ "vendor": {"type": "string", "description": "Company name"}, "total": {"type": "number", "description": "Total amount due"}, "line_items": { "type": "array", "description": "Each line item", "items": { "type": "object", "properties": { "description": {"type": "string"}, "amount": {"type": "number"} } } } }, ) print(result.data["vendor"]) # "Acme Corp" print(result.data["total"]) # 1234.56 print(result.confidence["total"]) # 0.95 ``` ```typescript TypeScript theme={null} import { TheDriveAI } from "@thedriveai/sdk"; const client = new TheDriveAI({ apiKey: "tda_live_..." }); const result = await client.extract({ file: readFileSync("invoice.pdf"), schema: { vendor: { type: "string", description: "Company name" }, total: { type: "number", description: "Total amount due" }, }, }); console.log(result.data.vendor); // "Acme Corp" console.log(result.data.total); // 1234.56 ``` ## Define schemas your way Write raw JSON, or use Pydantic (Python) and Zod (TypeScript) to define schemas with the tools you already use. ```python Pydantic theme={null} from pydantic import BaseModel, Field from thedriveai import TheDriveAI class Invoice(BaseModel): vendor: str = Field(description="Company name") total: float = Field(description="Total amount due") is_paid: bool = Field(description="Whether the invoice is paid") client = TheDriveAI(api_key="tda_live_...") result = client.extract(file="invoice.pdf", schema=Invoice) ``` ```typescript Zod theme={null} import { TheDriveAI, fromZod } from "@thedriveai/sdk"; import { z } from "zod"; const Invoice = z.object({ vendor: z.string().describe("Company name"), total: z.number().describe("Total amount due"), is_paid: z.boolean().describe("Whether the invoice is paid"), }); const client = new TheDriveAI({ apiKey: "tda_live_..." }); const result = await client.extract({ file: readFileSync("invoice.pdf"), schema: fromZod(Invoice), }); ``` The SDK converts your Pydantic models and Zod schemas to the typed format automatically — including nested objects, arrays, enums, and optional fields. ## Supported formats | Category | Formats | | ------------- | ------------------------------------------------- | | Documents | PDF, DOCX, DOC, ODT, RTF | | Spreadsheets | XLSX, CSV, TSV | | Presentations | PPTX | | Data | JSON, XML | | Images | JPG, PNG, TIFF, WEBP | | Web | Any public URL (rendered with a headless browser) | ## Authentication All requests require an `X-API-Key` header. Get your key at [dev.thedrive.ai](https://dev.thedrive.ai). ```bash theme={null} curl -X POST https://dev.thedrive.ai/api/v1/extract \ -H "X-API-Key: tda_live_..." \ -F file=@invoice.pdf \ -F 'schema={"vendor": {"type": "string", "description": "Company name"}}' ``` ## Install ```bash Python theme={null} pip install thedriveai ``` ```bash TypeScript theme={null} npm install @thedriveai/sdk ``` ## Pricing | Endpoint | Cost | | ------------- | ----------------------------------------------- | | Extract | 1 credit/page (min 3), 5 credits for websites | | Analyze | 2 credits/page (min 5), 10 credits for websites | | Cross-Analyze | 5 credits/doc + 3 credits/page (min 10) | | Markdown | 1 credit | | Thumbnail | 1 credit | Free tier includes 100 credits/month. [Purchase more](https://dev.thedrive.ai/dashboard/billing). # Quickstart Source: https://docs.thedrive.ai/developer/quickstart Extract structured data from a document in under 5 minutes ## 1. Get an API key Sign up at [dev.thedrive.ai](https://dev.thedrive.ai) and create an API key from the dashboard. Free tier includes 100 credits/month. ## 2. Install the SDK ```bash Python theme={null} pip install thedriveai ``` ```bash TypeScript theme={null} npm install @thedriveai/sdk ``` ## 3. Extract data ```python Python theme={null} from thedriveai import TheDriveAI client = TheDriveAI(api_key="tda_live_...") result = client.extract( file="invoice.pdf", schema={ "invoice_number": {"type": "string", "description": "The invoice number"}, "vendor": {"type": "string", "description": "Company name"}, "total": {"type": "number", "description": "Total amount due"}, "is_paid": {"type": "boolean", "description": "Whether the invoice is marked as paid"}, }, ) print(result.data) # {"invoice_number": "INV-2024-0042", "vendor": "Acme Corp", "total": 1234.56, "is_paid": false} print(result.confidence) # {"invoice_number": 0.96, "vendor": 0.94, "total": 0.91, "is_paid": 0.85} ``` ```typescript TypeScript theme={null} import { TheDriveAI } from "@thedriveai/sdk"; import { readFileSync } from "fs"; const client = new TheDriveAI({ apiKey: "tda_live_..." }); const result = await client.extract({ file: readFileSync("invoice.pdf"), schema: { invoice_number: { type: "string", description: "The invoice number" }, vendor: { type: "string", description: "Company name" }, total: { type: "number", description: "Total amount due" }, is_paid: { type: "boolean", description: "Whether the invoice is marked as paid" }, }, }); console.log(result.data); // { invoice_number: "INV-2024-0042", vendor: "Acme Corp", total: 1234.56, is_paid: false } ``` ```bash cURL theme={null} curl -X POST https://dev.thedrive.ai/api/v1/extract \ -H "X-API-Key: tda_live_..." \ -F file=@invoice.pdf \ -F 'schema={ "invoice_number": {"type": "string", "description": "The invoice number"}, "vendor": {"type": "string", "description": "Company name"}, "total": {"type": "number", "description": "Total amount due"} }' ``` ## 4. Or use Pydantic / Zod Instead of writing raw JSON schemas, use the tools you already know. ```python Pydantic theme={null} from pydantic import BaseModel, Field from thedriveai import TheDriveAI class Invoice(BaseModel): invoice_number: str = Field(description="The invoice number") vendor: str = Field(description="Company name") total: float = Field(description="Total amount due") is_paid: bool = Field(description="Whether the invoice is marked as paid") client = TheDriveAI(api_key="tda_live_...") result = client.extract(file="invoice.pdf", schema=Invoice) print(result.data["vendor"]) # "Acme Corp" print(result.data["total"]) # 1234.56 ``` ```typescript Zod theme={null} import { TheDriveAI, fromZod } from "@thedriveai/sdk"; import { readFileSync } from "fs"; import { z } from "zod"; const Invoice = z.object({ invoice_number: z.string().describe("The invoice number"), vendor: z.string().describe("Company name"), total: z.number().describe("Total amount due"), is_paid: z.boolean().describe("Whether the invoice is marked as paid"), }); const client = new TheDriveAI({ apiKey: "tda_live_..." }); const result = await client.extract({ file: readFileSync("invoice.pdf"), schema: fromZod(Invoice), }); console.log(result.data.vendor); // "Acme Corp" console.log(result.data.total); // 1234.56 ``` Both approaches support nested objects, arrays, enums, and optional fields. See [Schemas](/developer/schemas) for the full reference. ## 5. Extract from a URL You can pass a URL instead of uploading a file. Works with any public URL — the API renders JavaScript-heavy pages with a headless browser. ```python Python theme={null} result = client.extract( url="https://example.com/pricing", schema={ "plans": { "type": "array", "description": "Available pricing plans", "items": { "type": "object", "properties": { "name": {"type": "string", "description": "Plan name"}, "price": {"type": "number", "description": "Monthly price"}, } } } }, ) ``` ```typescript TypeScript theme={null} const result = await client.extract({ url: "https://example.com/pricing", schema: { plans: { type: "array", description: "Available pricing plans", items: { type: "object", properties: { name: { type: "string", description: "Plan name" }, price: { type: "number", description: "Monthly price" }, }, }, }, }, }); ``` ## What's in the response Every extraction returns: | Field | Description | | -------------- | ---------------------------------------------------- | | `data` | Extracted values, type-enforced to match your schema | | `confidence` | Per-field confidence scores (0.0 - 1.0) | | `citations` | Per-field source text snippets from the document | | `field_status` | Per-field found/not\_found status with type info | | `credits_used` | Credits consumed for this request | ## Error handling ```python Python theme={null} from thedriveai import TheDriveAI, TheDriveAIError try: result = client.extract(file="doc.pdf", schema={...}) except TheDriveAIError as e: print(e.status_code) # 400, 413, 503, etc. print(e.detail) # Error detail from the API ``` ```typescript TypeScript theme={null} import { TheDriveAI, TheDriveAIError } from "@thedriveai/sdk"; try { const result = await client.extract({...}); } catch (e) { if (e instanceof TheDriveAIError) { console.log(e.statusCode); // 400, 413, 503, etc. console.log(e.detail); // Error detail from the API } } ``` | Status | Meaning | | ------ | ------------------------------------------------ | | `400` | Invalid schema, missing file/URL, or bad request | | `401` | Missing or invalid API key | | `413` | File too large (max 50 MB) | | `503` | AI service temporarily unavailable | ## What's next Compute and reason over documents — sums, comparisons, risk assessments. Validate an invoice against a contract, reconcile spreadsheets, compare agreements. Full type reference — arrays, nested objects, enums, required fields, Pydantic, Zod. Process documents asynchronously with webhook notifications. # Schemas Source: https://docs.thedrive.ai/developer/schemas Define what to extract with typed JSON schemas, Pydantic models, or Zod objects Every API call takes a `schema` parameter that describes the fields you want. You can define schemas three ways: raw JSON, Pydantic models (Python), or Zod objects (TypeScript). ## Typed JSON schema Each field is an object with a `type` and `description`: ```json theme={null} { "vendor": {"type": "string", "description": "Company name on the invoice"}, "total": {"type": "number", "description": "Total amount due including tax"}, "is_paid": {"type": "boolean", "description": "Whether the invoice is marked as paid"} } ``` ### Supported types | Type | Returns | Example value | | --------- | ------------- | --------------------------------------- | | `string` | Text | `"Acme Corp"` | | `number` | Float | `1234.56` | | `integer` | Whole number | `42` | | `boolean` | true/false | `true` | | `array` | List | `[{"item": "Widget", "qty": 3}]` | | `object` | Nested object | `{"street": "123 Main", "city": "NYC"}` | ### Enums Constrain a field to specific allowed values: ```json theme={null} { "status": { "type": "string", "enum": ["paid", "unpaid", "overdue"], "description": "Payment status" } } ``` ### Required fields Mark fields as required — the response will set `success: false` if any required field is missing: ```json theme={null} { "invoice_number": { "type": "string", "description": "Invoice reference number", "required": true } } ``` ### Arrays Extract lists of items with a defined shape: ```json theme={null} { "line_items": { "type": "array", "description": "Each line item on the invoice", "items": { "type": "object", "properties": { "description": {"type": "string", "description": "Item description"}, "quantity": {"type": "integer", "description": "Quantity"}, "unit_price": {"type": "number", "description": "Price per unit"} } } } } ``` ### Nested objects ```json theme={null} { "vendor": { "type": "object", "description": "Vendor information", "properties": { "name": {"type": "string", "description": "Company name"}, "address": {"type": "string", "description": "Full address"}, "tax_id": {"type": "string", "description": "Tax identification number"} } } } ``` ## Pydantic models (Python) Pass a Pydantic `BaseModel` class directly as the schema. The SDK converts it automatically — including nested models, `Optional` fields, `Literal` enums, and `Field(description=...)`. ```python theme={null} from pydantic import BaseModel, Field from typing import Optional from enum import Enum class Status(str, Enum): paid = "paid" unpaid = "unpaid" overdue = "overdue" class LineItem(BaseModel): description: str = Field(description="Item description") quantity: int = Field(description="Quantity") unit_price: float = Field(description="Price per unit") class Invoice(BaseModel): invoice_number: str = Field(description="The invoice number") vendor: str = Field(description="Company name") total: float = Field(description="Total amount due") status: Status = Field(description="Payment status") notes: Optional[str] = Field(default=None, description="Additional notes") line_items: list[LineItem] = Field(description="Invoice line items") result = client.extract(file="invoice.pdf", schema=Invoice) ``` This generates the equivalent typed JSON schema behind the scenes. Every Pydantic feature maps to a schema type: | Pydantic | Schema type | | ----------------------------- | ------------------------ | | `str` | `string` | | `float` | `number` | | `int` | `integer` | | `bool` | `boolean` | | `list[T]` | `array` with items | | Nested `BaseModel` | `object` with properties | | `Optional[T]` | Nullable field | | `Literal["a", "b"]` or `Enum` | `string` with `enum` | | `Field(description="...")` | Field description | ## Zod schemas (TypeScript) Use `fromZod()` to convert a Zod object schema. Supports `z.string()`, `z.number()`, `z.boolean()`, `z.array()`, `z.object()`, `z.enum()`, and `.describe()`. ```typescript theme={null} import { TheDriveAI, fromZod } from "@thedriveai/sdk"; import { z } from "zod"; const LineItem = z.object({ description: z.string().describe("Item description"), quantity: z.number().describe("Quantity"), unit_price: z.number().describe("Price per unit"), }); const Invoice = z.object({ invoice_number: z.string().describe("The invoice number"), vendor: z.string().describe("Company name"), total: z.number().describe("Total amount due"), status: z.enum(["paid", "unpaid", "overdue"]).describe("Payment status"), notes: z.string().optional().describe("Additional notes"), line_items: z.array(LineItem).describe("Invoice line items"), }); const result = await client.extract({ file: readFileSync("invoice.pdf"), schema: fromZod(Invoice), }); ``` | Zod | Schema type | | ------------------ | ------------------------ | | `z.string()` | `string` | | `z.number()` | `number` | | `z.boolean()` | `boolean` | | `z.array(T)` | `array` with items | | `z.object({...})` | `object` with properties | | `z.enum([...])` | `string` with `enum` | | `.optional()` | Nullable field | | `.describe("...")` | Field description | ## Type guarantees When you define a field as `"type": "number"`, the API guarantees the returned value is a JSON number — not a string like `"$1,234.56"`. The AI parses, cleans, and type-coerces values automatically. If a field can't be found in the document, it returns `null` (not an empty string or zero). ## Limits * Maximum **10 top-level fields** per request (excluding `_`-prefixed meta keys) * No limit on nested properties within arrays or objects * Descriptions improve accuracy — always include them # Async & Webhooks Source: https://docs.thedrive.ai/developer/webhooks Process documents asynchronously with webhook notifications Any endpoint that accepts `sync=false` will return immediately with a `task_id` and process in the background. When complete, the result is available via polling or delivered to your webhook URL. ## Async processing ```python Python theme={null} from thedriveai import TheDriveAI client = TheDriveAI(api_key="tda_live_...") # Submit async task = client.extract_async( file="large_report.pdf", schema={"title": {"type": "string", "description": "Document title"}}, webhook_url="https://your-app.com/webhooks/thedrive", ) print(task.task_id) # "task_a1b2c3d4e5f6" # Or poll for result result = client.wait_for_task(task.task_id, timeout=300) print(result.status) # "completed" print(result.result) # The extraction result ``` ```bash cURL theme={null} # Submit curl -X POST https://dev.thedrive.ai/api/v1/extract \ -H "X-API-Key: tda_live_..." \ -F file=@report.pdf \ -F 'schema={"title": {"type": "string", "description": "Title"}}' \ -F sync=false \ -F webhook_url=https://your-app.com/webhooks/thedrive # Response: {"task_id": "task_a1b2c3d4e5f6", "status": "pending", "poll_url": "/api/v1/jobs/task_a1b2c3d4e5f6"} # Poll curl https://dev.thedrive.ai/api/v1/jobs/task_a1b2c3d4e5f6 \ -H "X-API-Key: tda_live_..." ``` ## Webhook payload When the task completes, we POST the result to your `webhook_url`: ```json theme={null} { "task_id": "task_a1b2c3d4e5f6", "status": "completed", "created_at": "2025-06-15T10:30:00Z", "completed_at": "2025-06-15T10:30:12Z", "credits_used": 7, "result": { "success": true, "data": {"title": "Q3 Financial Report"}, "confidence": {"title": 0.96}, ... } } ``` ## Verifying webhooks Every webhook includes two security headers: | Header | Purpose | | ------------------- | --------------------------------------------- | | `X-TDA-Signature` | HMAC-SHA256 signature of the raw request body | | `X-TDA-Delivery-ID` | Unique delivery ID for deduplication | **Verify the signature** to ensure the payload is authentic and hasn't been tampered with: ```python Python theme={null} import hmac import hashlib def verify_webhook(raw_body: bytes, signature_header: str, secret: str) -> bool: expected = "sha256=" + hmac.new( secret.encode(), raw_body, hashlib.sha256 ).hexdigest() return hmac.compare_digest(expected, signature_header) # In your webhook handler (e.g. Flask/FastAPI): @app.post("/webhooks/thedrive") async def handle_webhook(request: Request): body = await request.body() signature = request.headers.get("X-TDA-Signature", "") if not verify_webhook(body, signature, "your-webhook-signing-secret"): raise HTTPException(status_code=401, detail="Invalid signature") payload = await request.json() # Process the result... ``` ```typescript TypeScript theme={null} import crypto from "crypto"; function verifyWebhook(rawBody: Buffer, signature: string, secret: string): boolean { const expected = "sha256=" + crypto .createHmac("sha256", secret) .update(rawBody) .digest("hex"); return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature)); } // In your Express handler: app.post("/webhooks/thedrive", express.raw({ type: "application/json" }), (req, res) => { const signature = req.headers["x-tda-signature"] as string; if (!verifyWebhook(req.body, signature, "your-webhook-signing-secret")) { return res.status(401).send("Invalid signature"); } const payload = JSON.parse(req.body.toString()); // Process the result... res.sendStatus(200); }); ``` Always verify the `X-TDA-Signature` header before trusting a webhook payload. Without verification, anyone who discovers your webhook URL could send forged payloads. ## Retry policy Failed webhook deliveries are retried automatically: | Phase | Timing | | ------------------ | ------------------------------------------------------- | | Inline retries | 3 attempts with exponential backoff (immediate, 2s, 4s) | | Background retries | 1min, 5min, 15min, 30min, 1hr, 2hr, 4hr | | **Total** | **8 attempts over \~8 hours** | * **4xx responses** are treated as permanent failures (not retried) * **5xx responses** and timeouts are retried * Your endpoint should return `200` to acknowledge receipt ## Checking delivery status If you didn't receive a webhook, check the delivery log: ```bash theme={null} curl https://dev.thedrive.ai/api/v1/jobs/task_a1b2c3d4e5f6/deliveries \ -H "X-API-Key: tda_live_..." ``` ```json theme={null} { "task_id": "task_a1b2c3d4e5f6", "deliveries": [ { "id": "whd_a1b2c3d4e5f6g7h8", "status": "delivered", "status_code": 200, "attempts": 1, "created_at": "2025-06-15T10:30:12Z", "delivered_at": "2025-06-15T10:30:13Z" } ] } ``` Delivery statuses: * `pending` — Not yet attempted * `delivered` — Successfully received (2xx response) * `failed` — Will be retried * `dead` — Exhausted all retry attempts or permanent 4xx failure ## Deduplication Use the `X-TDA-Delivery-ID` header to deduplicate retries. If your server crashes after processing but before responding, the retry will carry the same delivery ID. ```python theme={null} @app.post("/webhooks/thedrive") async def handle_webhook(request: Request): delivery_id = request.headers.get("X-TDA-Delivery-ID") # Check if already processed if await db.exists("processed_webhooks", delivery_id): return {"ok": True} # Already handled, just ACK # Process... await db.insert("processed_webhooks", {"id": delivery_id}) return {"ok": True} ``` # Agent Mode Source: https://docs.thedrive.ai/features/agent-mode Execute file operations using natural language commands ## Overview Agent Mode is where the real power of The Drive AI comes to life. Unlike Chat Mode which only provides answers, Agent Mode actually takes actions—creating, renaming, moving, sharing, organizing, and deleting files based on your natural language commands. Agent Mode in The Drive AI ## What is Agent Mode? **Agent Mode** is for taking actions. The AI executes file operations based on your commands—it can create, rename, move, share, organize, and delete files. Think of Agent Mode as having a capable assistant who can perform any file operation you describe, handling the tedious work while you focus on what matters. ## When to Use Agent Mode Use Agent Mode when you want to: * **Create** new files or folders * **Rename** single or multiple files * **Move** files between folders * **Organize** files into logical structures * **Delete** or archive old files * **Share** files with others * **Manipulate** files—merge PDFs, fill out forms, and more * **Browse the internet** to fetch information, research topics, and download files * **Analyze data** by running code on your files * **Generate charts** and visualizations from your data * **Perform bulk operations** across many files ## How to Use Agent Mode Click on the chat interface in your workspace. Switch to Agent Mode using the mode selector. Type your command in natural language - describe the outcome you want. The AI executes your command and confirms the actions taken. ## Understanding Scope The AI only operates within your current location and its contents - not parent folders. Your scope is determined by where you are in the workspace: | Your Location | AI Can Act On | | ----------------- | -------------------------------------- | | Workspace root | All files and folders in the workspace | | A specific folder | That folder and all its subfolders | | A specific file | Only that file | The current scope is always displayed in the input box at the bottom of the chat panel, so you know exactly what the AI can access. Navigate to a specific folder before running commands to limit the AI's scope and ensure it only affects the files you intend. ## Example Commands ### Creating Files and Folders ``` Create a new folder called "2024 Projects" ``` ``` Create a folder structure for a new client: folders for Contracts, Invoices, and Communications ``` ``` Make a new text file called "meeting-notes.txt" in the Meetings folder ``` ### Renaming Files ``` Rename all files in the Downloads folder to include today's date as a prefix ``` ``` Change "draft" to "final" in all document names in this folder ``` ``` Rename the quarterly reports to follow the pattern "Q1-2024-Report" ``` ### Moving Files ``` Move all PDFs to the Documents folder ``` ``` Move files older than 30 days to the Archive folder ``` ``` Organize the Downloads folder by moving files into subfolders based on file type ``` ### Organizing Files ``` Organize this folder by project ``` ``` Sort all invoices by client name into separate folders ``` ``` Group these files by date: monthly folders for each month ``` ### Deleting and Archiving ``` Delete all duplicate files in this folder ``` ``` Move files I haven't opened in 6 months to Archive ``` ``` Clean up empty folders in my workspace ``` ### Sharing Files ``` Share the Q4 report with the marketing team ``` ``` Create a shareable link for the project proposal ``` ### Manipulating Files ``` Merge all the PDF invoices in this folder into one document ``` ``` Fill out the W-9 form with my company information ``` ``` Combine the cover letter and resume into a single PDF ``` ### Browsing the Internet ``` Find the current exchange rate for USD to EUR ``` ``` Research the latest pricing for AWS S3 storage ``` ``` Look up the company info for Acme Corp and summarize it ``` ``` Download the PDF from this URL and save it to my Documents folder ``` ``` Fetch the latest report from [website] and add it to the Reports folder ``` ### Data Analysis and Charts ``` Analyze the sales data in this spreadsheet and show me the trends ``` ``` Create a bar chart comparing revenue by quarter from the financial report ``` ``` Run a summary analysis on this CSV and highlight any outliers ``` ### Complex Multi-Step Operations ``` Create a new project folder called "Website Redesign", add subfolders for Design, Content, and Development, then move all related files from my Desktop into the appropriate subfolders ``` ``` Find all invoices from 2023, create a folder called "2023 Invoices", move them there, and rename them to include the client name ``` ## Features ### Natural Language Understanding You don't need to use specific syntax or commands. Just describe what you want in plain English: * "Put all the spreadsheets in one place" → Moves all .xlsx and .csv files to a folder * "Clean up my downloads" → Organizes and sorts your Downloads folder * "Get rid of the old stuff" → Archives or moves older files ### Bulk Operations Agent Mode excels at operations that would take hours manually: | Manual Approach | Agent Mode | | ----------------------------- | ------------------------------------------- | | Rename 100 files one by one | "Rename all files to include the date" | | Create 20 client folders | "Create folders for each client in my list" | | Sort hundreds of documents | "Organize by topic" | | Find and move scattered files | "Move all invoices to the Finance folder" | ### Smart Context The AI understands context: * It knows what "old files" means based on your usage patterns * It understands "related files" by analyzing content * It recognizes project names, client names, and common terms in your files ### Confirmation and Feedback After executing commands, Agent Mode: * Confirms what actions were taken * Shows how many files were affected * Provides details on the changes made * Alerts you to any issues encountered ## Best Practices Specify which folder or files you're referring to. **Good:** "Move all PDFs in the Downloads folder to Documents" **Better:** "In the Downloads folder, move all PDF files to Documents/Reports" For large operations, test with a subset first. **Example:** "Move 5 of the oldest files to Archive" before "Archive all files older than 1 year" When creating folders, use clear names. **Good:** "Create a folder called 'Q1 2024 Marketing Campaign'" **Not as good:** "Create a new folder" Agent Mode handles multi-step operations well. **Example:** "Create a Projects folder, add subfolders for each client, and move their files into the appropriate subfolders" ## Chat Mode vs Agent Mode | Task | Chat Mode | Agent Mode | | ------------------------------- | ------------------- | ------------------- | | "Where is the Q4 report?" | Finds and tells you | Finds and tells you | | "Move the Q4 report to Reports" | Can't do this | Moves the file | | "What files are duplicates?" | Lists duplicates | Lists duplicates | | "Delete the duplicate files" | Can't do this | Deletes duplicates | | "Summarize this document" | Provides summary | Provides summary | | "Rename this document" | Can't do this | Renames the file | Use **Chat Mode** to explore and understand your files. Switch to **Agent Mode** when you're ready to take action. ## Safety and Control Agent Mode is powerful, but The Drive AI includes safeguards: * **Tasks panel**: View all running agent tasks from the Tasks section in the left sidebar * **Trash folder**: Deleted files go to Trash first, not permanently deleted * **Stop action**: You can stop agent anytime by clicking on stop button * **Action history**: Messages are saved, so you can see action history * **Undo action**: Soon ## What's Next? Learn about automatic file organization. Use Agent Mode from other AI tools. # Auto-Organization Source: https://docs.thedrive.ai/features/auto-organization Let AI intelligently rename and organize your files into logical folder structures ## Overview Auto-Organization is one of The Drive AI's most powerful features. Instead of manually creating folders and sorting files, the AI analyzes your file contents and automatically creates logical folder structures.