Quickstart

This quickstart guides you through setting up credentials, uploading a document, initiating an automated review, and retrieving review findings using the Deep Review API.

Before you begin

  1. Select or create a Google Cloud project in the Google Cloud Console.
  2. Ensure that billing is enabled for your Google Cloud project.
  3. Install the Google Cloud CLI, authenticate, and set your active Google Cloud project: bash gcloud auth login gcloud config set project YOUR_PROJECT_ID
  4. Enable the Deep Review API on your project: bash gcloud services enable deepreview.googleapis.com
  5. Configure Application Default Credentials (ADC) with the required scopes: bash gcloud auth application-default login --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/drive.file

Step 1: Upload a manuscript

Upload a PDF file using media streaming:

DOC_RESP=$(curl -sS -X POST "https://deepreview.googleapis.com/upload/v1/documents?uploadType=media" \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  -H "x-goog-user-project: $(gcloud config get-value project)" \
  -H "Content-Type: application/pdf" \
  --data-binary "@my_paper.pdf")

DOC_NAME=$(echo "$DOC_RESP" | jq -r 'select(type == "object" and .name != null) | .name' 2>/dev/null)
if [ -z "$DOC_NAME" ]; then
  echo "Failed to upload document:" >&2
  echo "$DOC_RESP" >&2
else
  echo "Uploaded: $DOC_NAME"
fi

Step 2: Trigger an automated review

Create a review specifying the evaluation topology:

OP_NAME=""
if [ -z "$DOC_NAME" ]; then
  echo "Missing DOC_NAME from Step 1" >&2
else
  OP_RESP=$(curl -sS -X POST "https://deepreview.googleapis.com/v1/${DOC_NAME}/reviews" \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "x-goog-user-project: $(gcloud config get-value project)" \
    -H "Content-Type: application/json" \
    -d '{
      "runConfig": {
        "topology": "MID"
      }
    }')

  OP_NAME=$(echo "$OP_RESP" | jq -r 'select(type == "object" and .name != null) | .name' 2>/dev/null)
  if [ -z "$OP_NAME" ]; then
    echo "Failed to initiate review:" >&2
    echo "$OP_RESP" >&2
  else
    echo "Operation started: $OP_NAME"
  fi
fi

Step 3: Poll for completion

The review executes asynchronously. Poll the operation until done is true:

STATUS=""
if [ -z "$OP_NAME" ]; then
  echo "Missing OP_NAME from Step 2" >&2
else
  while true; do
    if ! STATUS=$(curl -sS -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
      -H "x-goog-user-project: $(gcloud config get-value project)" \
      "https://deepreview.googleapis.com/v1/${OP_NAME}") || ! echo "$STATUS" | jq -e 'type == "object"' >/dev/null 2>&1; then
      echo "Failed to poll operation: $STATUS" >&2
      STATUS=""
      break
    fi

    if [ "$(echo "$STATUS" | jq -r '.error != null')" = "true" ]; then
      echo "Review operation failed:" >&2
      echo "$STATUS" | jq .error
      STATUS=""
      break
    fi

    if [ "$(echo "$STATUS" | jq -r '.done // false')" = "true" ]; then
      echo "Review complete!"
      echo "$STATUS" | jq .response
      break
    fi

    echo "Review in progress... checking again in 10s"
    sleep 10
  done
fi

Step 4: Inspect review comments

Fetch the completed review resource to examine the synthesized review Markdown report and anchored comments:

REVIEW_NAME=$(echo "$STATUS" | jq -r 'select(type == "object" and .response.name != null) | .response.name' 2>/dev/null)
if [ -n "$REVIEW_NAME" ]; then
  curl -sS -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "x-goog-user-project: $(gcloud config get-value project)" \
    "https://deepreview.googleapis.com/v1/${REVIEW_NAME}" | jq .
fi