---
title: "Summarise Google Docs with Pydantic AI | EnConvert"
description: "Google Docs summarisation in Pydantic AI: EnConvert Distill returns schema-defined fields from up to 50 shared URLs in one synchronous call, no Drive API setup"
canonical: "https://www.enconvert.com/solutions/summarise-google-docs-with-pydantic-ai-enconvert"
locale: "en"
---

# How to Summarise Google Docs with Pydantic AI

A developer building a Pydantic AI agent that reads shared Google Docs needs clean document content before reasoning or summarising. Google Docs shared via “anyone with the link” serve a full Drive UI with comment sidebars, suggestion overlays, and navigation chrome that obscure the document body, and the Drive API requires OAuth and project setup before a single document can be read. EnConvert Distill accepts the shared Google Doc URL, applies a schema the agent defines, and returns structured fields in one synchronous call. The agent gets schema-defined document content ready for downstream reasoning with no Drive API credentials.

## Example

```python
import os

import requests
from pydantic_ai import Agent, RunContext

# Pydantic AI's OpenAI provider reads OPENAI_API_KEY from the environment
GOOGLE_DOC_URL = os.environ["GOOGLE_DOC_URL"]  # a Google Doc shared as "Anyone with the link can view"

BASE_URL = "https://api.enconvert.com/v2"
headers = {
    "X-API-Key": os.environ["ENCONVERT_API_KEY"],
    "Content-Type": "application/json",
}

DOC_SCHEMA = {
    "title": "The document title",
    "summary": "A three sentence summary of what the document covers",
    "key_points": "The main points or decisions in the document, as a list",
    "author": "The document owner or author, if the page shows one",
    "last_edited": "The date the document was last edited, if the page shows one",
}

agent = Agent(
    "openai:gpt-4.1",
    system_prompt=(
        "You summarise shared Google Docs. Use summarise_google_docs to read the documents "
        "you need, answer only from what it returns, and cite the document URL for every statement."
    ),
)

@agent.tool
def summarise_google_docs(ctx: RunContext[None], urls: list[str]) -> str:
    """Reads shared Google Docs and returns structured fields for each document:
    title, summary, key points, author, and last edited date."""
    if len(urls) > 50:
        return "Too many URLs. Distill accepts at most 50 per call."

    # One synchronous call: no job_id, no polling, no download step
    response = requests.post(
        f"{BASE_URL}/distill",
        headers=headers,
        json={"urls": urls, "schema": DOC_SCHEMA},
        timeout=300,
    )

    # Distill runs on paid plans only, and the free tier returns 402
    if response.status_code == 402:
        return "Distill requires a paid plan."
    response.raise_for_status()

    documents = []
    for result in response.json()["results"]:
        if result["status"] != "completed":
            documents.append(f"Source: {result['url']}\nCould not be read ({result['status']}).")
            continue

        render_quality = result.get("render_quality", 1.0)
        if render_quality < 0.5:
            documents.append(
                f"Source: {result['url']}\nLow render quality ({render_quality}), skipped."
            )
            continue

        data = result["data"]  # keys match DOC_SCHEMA exactly
        points = data["key_points"]
        documents.append(
            f"Source: {result['url']}\n"
            f"Title: {data['title']}\n"
            f"Author: {data['author']}\n"
            f"Last edited: {data['last_edited']}\n"
            f"Key points: {'; '.join(points) if isinstance(points, list) else points}\n"
            f"Summary: {data['summary']}"
        )
    return "\n\n---\n\n".join(documents)

result = agent.run_sync(
    f"Read {GOOGLE_DOC_URL} "
    "and summarise it, listing its key points."
)
print(result.output)
```

## Output

Distill returns the requested fields inline as structured JSON in the data object, with no polling, no job_id, and no signed URL to fetch. The render_quality score lets the agent detect a login wall or challenge page before reasoning over incomplete content. The Google Drive API requires OAuth 2.0 credentials, a Google Cloud project, and a separate export call to retrieve document content, while Distill requires only the shared link and an API key.

## Get started

[Get free API key — 500 ops per month, no card required. Note: Distill runs on paid plans. Free tier returns 402.](https://www.enconvert.com/auth?mode=signup)

## Related solutions

- [How to Summarise GitHub with Pydantic AI](https://www.enconvert.com/solutions/summarise-github-with-pydantic-ai-enconvert.md)
- [How to Summarise Google Docs with LangGraph](https://www.enconvert.com/solutions/summarise-google-docs-with-langgraph-enconvert.md)
- [How to Summarise GitHub with LlamaIndex](https://www.enconvert.com/solutions/summarise-github-with-llamaindex-enconvert.md)
- [How to Summarise YouTube Transcripts with LlamaIndex](https://www.enconvert.com/solutions/summarise-youtube-transcripts-with-llamaindex-enconvert.md)
- [How to Summarise GitHub Issues with CrewAI](https://www.enconvert.com/solutions/summarise-github-issues-with-crewai-enconvert.md)
- [How to Summarise GitHub Issues with LlamaIndex](https://www.enconvert.com/solutions/summarise-github-issues-with-llamaindex-enconvert.md)
