> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thedrive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Make a Decision

> 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.



## OpenAPI

````yaml /openapi.json post /api/v1/decide
openapi: 3.1.0
info:
  title: The Drive AI API
  description: >

    ## The Drive AI API


    One API for screenshots, markdown extraction, structured data extraction,

    and more. 107+ file formats supported.


    **[Developer Guide & SDK Docs](https://docs.thedrive.ai)** — Quickstart,
    guides, Pydantic/Zod examples, webhook verification.


    This page is the interactive API reference. For tutorials and SDK usage, see
    the developer guide.


    ## Endpoints


    | Endpoint | Credits | Description |

    |----------|---------|-------------|

    | `GET /{url}` | 1 | Screenshot any URL |

    | `GET /md/{url}` | 1 | Convert any URL to markdown |

    | `POST /api/v1/thumbnails/generate` | 1 | Generate thumbnail from file or
    URL |

    | `POST /api/v1/markdown/convert` | 1 | Convert file/URL to markdown |

    | `POST /api/v1/extract` | 1/page or 5/site | Extract structured data |

    | `POST /api/v1/analyze` | 2/page or 10/site | Analyze — compute, reason,
    derive |

    | `POST /api/v1/analyze/cross` | 5/doc + 3/page | Cross-reference multiple
    documents |


    ## Authentication


    All protected endpoints require an `X-API-Key` header:

    ```bash

    curl https://dev.thedrive.ai/stripe.com \
      -H "X-API-Key: tda_live_your_key_here"
    ```


    Get your API key at https://dev.thedrive.ai/login


    ## Pricing


    - **Free**: 100 credits/month, no card required

    - **Pro**: $0.01/credit, pay-as-you-go

    - **Enterprise**: Volume pricing, contact us
  version: 1.4.0
servers: []
security: []
tags:
  - name: screenshots
    description: Screenshot and thumbnail generation
  - name: markdown
    description: URL and document to markdown conversion
  - name: extraction
    description: Structured data extraction from documents
  - name: thumbnails
    description: Thumbnail generation via file upload or URL
  - name: health
    description: Service health and readiness probes
paths:
  /api/v1/decide:
    post:
      tags:
        - decision
      summary: Make a Decision
      description: >-
        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.
      operationId: decide_document_api_v1_decide_post
      parameters:
        - name: X-API-Key
          in: header
          required: false
          schema:
            type: string
            title: X-Api-Key
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_decide_document_api_v1_decide_post'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecideResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: File too large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '502':
          description: AI provider failed (not retryable)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: AI provider overloaded (retry with backoff)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Body_decide_document_api_v1_decide_post:
      properties:
        file:
          anyOf:
            - type: string
              contentMediaType: application/octet-stream
            - type: 'null'
          title: File
          description: Document to decide about
        url:
          anyOf:
            - type: string
            - type: 'null'
          title: Url
          description: URL to fetch the document from
        url_headers:
          anyOf:
            - type: string
            - type: 'null'
          title: Url Headers
          description: JSON-encoded headers for URL auth
        instructions:
          type: string
          title: Instructions
          description: What decision to make, and what makes it correct
        context:
          anyOf:
            - type: string
            - type: 'null'
          title: Context
          description: JSON array of {"label", "content"} context blocks
        schema:
          type: string
          title: Schema
          description: Typed schema of the decision fields
        include_steps:
          type: boolean
          title: Include Steps
          description: Include the agent's tool-call trace
          default: false
        sync:
          type: boolean
          title: Sync
          description: Set to false to process asynchronously. Returns a task_id to poll.
          default: true
        webhook_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Webhook Url
          description: URL to POST the result to when async processing completes.
      type: object
      required:
        - instructions
        - schema
      title: Body_decide_document_api_v1_decide_post
    DecideResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        data:
          additionalProperties: true
          type: object
          title: Data
          description: Decision values keyed by field name
        confidence:
          additionalProperties:
            type: number
          type: object
          title: Confidence
          description: Per-field confidence scores (0.0–1.0)
        reasoning:
          type: string
          title: Reasoning
          description: One coherent explanation of the decision as a whole
          default: ''
        sources:
          items:
            type: string
          type: array
          title: Sources
          description: Quotes from the document/context that support the decision
        steps:
          items:
            $ref: '#/components/schemas/AgentStepResponse'
          type: array
          title: Steps
          description: Agent tool-call trace. Empty unless include_steps=true.
        filename:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename
          description: Original filename or URL (null for context-only decisions)
        content_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Type
          description: Detected MIME type
        model_used:
          type: string
          title: Model Used
          description: Model used for the decision
        text_length:
          type: integer
          title: Text Length
          description: Length of extracted document text (0 for context-only)
          default: 0
        total_pages:
          type: integer
          title: Total Pages
          description: Total pages in the document (0 for non-paginated files)
          default: 0
        credits_used:
          type: integer
          title: Credits Used
          description: Credits consumed
          default: 0
        schema_format:
          anyOf:
            - $ref: '#/components/schemas/SchemaFormat'
            - type: 'null'
          description: 'Schema format: always ''typed'''
      type: object
      required:
        - data
        - model_used
      title: DecideResponse
      description: >-
        Response for /decide — ONE coherent decision over the whole schema.


        Unlike /analyze, `reasoning` is a single string and `sources` a single

        list: the fields are facets of one judgment, so they share one
        rationale.

        A failed decision is an HTTP error, never a null-with-zero-confidence.
      example:
        confidence:
          destination_path: 0.92
        content_type: application/pdf
        credits_used: 5
        data:
          destination_path: billing/Acme Corp/2026/Apr
        filename: invoice.pdf
        model_used: gpt-5.1
        reasoning: >-
          The invoice names Acme Corp and is dated April 2026; the instruction
          files by client, then year, then month, and 'billing/Acme Corp'
          already exists in the provided folder list.
        sources:
          - 'Bill To: Acme Corp'
          - 'Invoice Date: April 3, 2026'
        success: true
        text_length: 3200
        total_pages: 2
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: false
        error:
          type: string
          title: Error
          description: Error type
        detail:
          type: string
          title: Detail
          description: Human-readable error message
      type: object
      required:
        - error
        - detail
      title: ErrorResponse
      description: Standard error response.
      example:
        detail: File size exceeds maximum allowed (50MB)
        error: validation_error
        success: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentStepResponse:
      properties:
        tool:
          type: string
          title: Tool
          description: Tool that was called
        args:
          additionalProperties: true
          type: object
          title: Args
          description: Arguments passed to the tool
        result_preview:
          type: string
          title: Result Preview
          description: First 200 chars of the tool output
          default: ''
      type: object
      required:
        - tool
      title: AgentStepResponse
      description: One step in the agent's reasoning trace.
    SchemaFormat:
      type: string
      enum:
        - typed
      title: SchemaFormat
      description: Schema format used for extraction/analysis.
    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

````