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

# Document summary

> Learn how to use the AI-powered Document summary API to create summaries for PDF documents uploaded to CDF.

Document summary is an AI-powered assistant that helps you create a summary for one or a maximum of 100 documents in .pdf format. You can upload PDF files to Cognite Data Fusion (CDF) and use the Document summary API to create a document summary.

<Steps>
  <Step title="Upload PDF">
    You can upload a PDF file to CDF one of the following ways:

    * Go to ***CDF*** > ***Industrial tools*** > ***Canvas*** and drag your PDF file to the canvas or upload existing files by selecting ***+ Add data***.

    * Go to ***CDF*** > ***Industrial tools*** > ***Data explorer*** > ***Files*** and select ***Upload***.

    * Use the Python code.

    ```python wrap theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
    response1 = client.files.upload(path="./well_report.pdf")
    document_id = response1.id
    print(document_id)
    ```
  </Step>

  <Step title="Create summary">
    Once the document is uploaded, we can start creating the summary.

    It may take some time before the document has been fully processed and ready,
    so we wrap the API call in a while-loop, so that we can retry until we get our answer.

    ```python wrap theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
    import json
    import time

    ask_path = f"/api/v1/projects/{client.config.project}/ai/tools/documents/summarize"

    body = {
        "items": [
            {
                "id": document_id
            }
        ]
    }

    while True:
        try:
            response2 = client.post(ask_path, json=body).json()
            break

        except CogniteAPIError as e:
            if e.code == 422 and len(e.missing) > 0:
                print("Not ready yet, waiting 5 seconds...")
                time.sleep(5)
                continue

            # re-raise any unexpected exceptions
            raise

    print(json.dumps(response2, indent=2))
    ```

    See the result of the test file.

    ```json wrap theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
    {
      "items": [
        {
          "id": 6716860071641521,
          "summary": "This document is a well summary report for the Volve F well in Norway. It provides information on the site position, well position, wellpath survey depths, and wellpath plan depths. The report includes details such as latitude, longitude, position uncertainty, water depth, wellhead depth, and survey dates. It also mentions the survey tools used for each survey. The document is dated April 11, 2018."
        }
      ]
    }
    ```
  </Step>
</Steps>
