Skip to main content
POST
/
api
/
v2
/
completion
Completion
curl --request POST \
  --url https://api.harvey.ai/api/v2/completion \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'prompt=In 3 sentences, can you explain how indemnity and limitation of liability clauses typically work in commercial contracts?' \
  --form stream=false \
  --form 'file=<string>' \
  --form mode=draft \
  --form client_matter_id=12345678-1234-5678-1234-567812345678 \
  --form 'knowledge_sources=[{"type":"web"}]' \
  --form file.items='@example-file'
{
  "response": "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": "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": [
    {
      "citation_num": 1,
      "document_name": "MyDocument.pdf",
      "page": 2,
      "text": "<mark>Quoted snippet...</mark>"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

include_citations
boolean
default:true

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.

Body

multipart/form-data
prompt
string
default:In 3 sentences, can you explain how indemnity and limitation of liability clauses typically work in commercial contracts?
required

A string question that you want to ask Harvey. The prompt may be up to 20,000 characters.

Maximum string length: 20000
Example:

"In 3 sentences, can you explain how indemnity and limitation of liability clauses typically work in commercial contracts?"

stream
boolean
default:false

A boolean value that lets you either stream or receive the entire output at once.

file
file[]

Files you want to upload to provide additional context for the prompt.

Cannot be used together with knowledge_sources.

mode
enum<string>
default:draft

Optional mode to specify the behavior of the completion.

Available options:
draft,
assist
Example:

"draft"

client_matter_id
string<uuid>

Optional client matter identifier to associate with this completion.

Example:

"12345678-1234-5678-1234-567812345678"

knowledge_sources
string

JSON-encoded array of 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\"}]"

Response

The response object includes the response field which is the completion of the input prompt sent to the model.

response
string

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
string | null

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
object[] | null

Contains the list of cited source snippets to support the answer. Only returned when include_citations=true and documents/knowledge sources were provided.