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

# Completion

> Harvey's Completion API provides access to Harvey's models via our orchestration engine, allowing users to ask complex, freeform questions and receive detailed legal-grade responses programmatically. It can also be used in conjunction with files attached to the request, Vaults, and Regional Knowledge Sources. 

<Info>Access to this API requires `Assistant access via API` permission, which is only available in your workspace with an additional purchase. To get started, contact your Account Manager or reach out to us at support@harvey.ai to discuss an agreement.</Info>

### Permissions

Requires `Assistant access via API` and `Assistant access` permission.


## OpenAPI

````yaml /v2_completion_api.json post /api/v2/completion
openapi: 3.0.1
info:
  title: v2 - Harvey Assistant Completion API
  description: >-
    Harvey's Completion API provides access to Harvey's models via our
    orchestration engine, allowing users to ask complex, freeform questions and
    receive detailed legal-grade responses programmatically. It can also be used
    in conjunction with files attached to the request, Vaults, and Regional
    Knowledge Sources.
  version: 1.0.0
  contact:
    email: support@harvey.ai
servers:
  - url: https://api.harvey.ai
    description: Harvey API server
security: []
paths:
  /api/v2/completion:
    post:
      tags:
        - Completion
      summary: Completion
      description: >-
        Harvey's Completion API provides access to Harvey's models via our
        orchestration engine, allowing users to ask complex, freeform questions
        and receive detailed legal-grade responses programmatically. It can also
        be used in conjunction with files attached to the request, Vaults, and
        Regional Knowledge Sources. 


        <Info>Access to this API requires `Assistant access via API` permission,
        which is only available in your workspace with an additional purchase.
        To get started, contact your Account Manager or reach out to us at
        support@harvey.ai to discuss an agreement.</Info>
      operationId: completion
      parameters:
        - name: include_citations
          in: query
          description: >-
            Whether to include citations in the response output. When set to
            false, citations are skipped and the response is returned more
            quickly. Defaults to true.
          required: false
          schema:
            type: boolean
            default: true
          example: true
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - prompt
              properties:
                prompt:
                  type: string
                  description: |
                    A string question that you want to ask Harvey.
                    The prompt may be up to 20,000 characters.
                  example: >-
                    In 3 sentences, can you explain how indemnity and limitation
                    of liability clauses typically work in commercial contracts?
                  default: >-
                    In 3 sentences, can you explain how indemnity and limitation
                    of liability clauses typically work in commercial contracts?
                  maxLength: 20000
                stream:
                  type: boolean
                  description: >
                    A boolean value that lets you either stream or receive the
                    entire output at once.
                  default: false
                file:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: >
                    Files you want to upload to provide additional context for
                    the prompt.


                    Cannot be used together with `knowledge_sources`.
                mode:
                  type: string
                  enum:
                    - draft
                    - assist
                  description: Optional mode to specify the behavior of the completion.
                  default: draft
                  example: draft
                client_matter_id:
                  type: string
                  format: uuid
                  description: >-
                    Optional client matter identifier to associate with this
                    completion.
                  example: 12345678-1234-5678-1234-567812345678
                knowledge_sources:
                  type: string
                  description: >-
                    JSON-encoded array of knowledge sources such as Vaults or
                    Regional Knowledge Sources.


                    Cannot be used together with `file`.


                    All objects must include a `type` field. Additional fields
                    depend on the `type`.


                    **Vault example with file_ids:**

                    [{"type":"vault","folder_id":"12345678-1234-5678-1234-567812345678","file_ids":["87654321-8765-4321-8765-432187654321"]}]


                    **Vault example without file_ids (queries entire folder):**

                    [{"type":"vault","folder_id":"12345678-1234-5678-1234-567812345678"}]


                    **Web example:**

                    [{"type":"web"}]
                  example: '[{"type":"web"}]'
                model:
                  type: string
                  description: >-
                    Optional model selector. Pass a customer-facing model slug
                    to use a specific model for this request. Omit this
                    parameter to use your workspace's default model.
                  example: gpt-5
                  enum:
                    - gpt-5
                    - gpt-5-1
                    - gpt-5-2
                    - gpt-5-4
                    - gpt-5-4-mini
                    - gpt-5-5
                    - gpt-4-1
                    - claude-opus-4-5
                    - claude-sonnet-4-5
                    - claude-opus-4-6
                    - claude-opus-4-7
      responses:
        '200':
          description: >
            The response object includes the response field which is the
            completion of the input prompt sent to the model.
          content:
            application/json:
              schema:
                type: object
                properties:
                  response:
                    type: string
                    description: The completion of the input prompt.
                    example: >-
                      Indemnity clauses in commercial contracts require one
                      party to compensate the other for certain losses or
                      damages arising from specified events, such as breaches or
                      third-party claims. Limitation of liability clauses cap
                      the amount or types of damages one party can recover from
                      the other, often excluding indirect or consequential
                      losses. Together, these clauses allocate and manage risk
                      between the parties, providing predictability and
                      protecting against potentially catastrophic financial
                      exposure.
                  response_with_citations:
                    type: string
                    nullable: true
                    description: >-
                      The completion with inline citations, e.g. `[1][2]`, which
                      correspond to the sources below. Only returned when
                      `include_citations=true`.
                    example: >-
                      Indemnity clauses in commercial contracts require one
                      party to compensate the other for certain losses or
                      damages arising from specified events, such as breaches or
                      third-party claims.[1] Limitation of liability clauses cap
                      the amount or types of damages one party can recover from
                      the other, often excluding indirect or consequential
                      losses.[2]
                  sources:
                    type: array
                    nullable: true
                    description: >-
                      Contains the list of cited source snippets to support the
                      answer. Only returned when `include_citations=true` and
                      documents/knowledge sources were provided.
                    items:
                      type: object
                      properties:
                        citation_num:
                          type: integer
                          example: 1
                        document_name:
                          type: string
                          example: MyDocument.pdf
                        page:
                          type: integer
                          nullable: true
                          example: 2
                        text:
                          type: string
                          example: <mark>Quoted snippet...</mark>
            text/event-stream:
              schema:
                type: string
                description: >-
                  When `stream=true`, the endpoint returns Server-Sent Events
                  (SSE). Each event is a line starting with `data: ` followed by
                  a JSON object (e.g. `{ "response": "..." }`). The stream ends
                  with `data: [DONE]`.
              example: >+
                data: {"response":"Hello"}


                data: {"response":" world"}


                data: {"response":"","response_with_citations":"Hello
                world.[1]","sources":[{"citation_num":1,"document_name":"MyDocument.pdf","page":2,"text":"<mark>Quoted
                snippet...</mark>"}]}


                data: [DONE]

        '400':
          description: Bad request.
        '401':
          description: Unauthorized.
        '429':
          description: Rate limit exceeded.
        '500':
          description: Internal server error.
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````