---
title: "Summarise Supabase Docs with Vercel AI SDK | EnConvert"
description: "Summarise Supabase documentation pages inside a Vercel AI SDK agent with EnConvert Distill, which returns schema-defined fields for up to 50 URLs in one call"
canonical: "https://www.enconvert.com/solutions/summarise-supabase-docs-with-vercel-ai-sdk-enconvert"
locale: "en"
---

# How to Summarise Supabase Docs with Vercel AI SDK

A developer building with the Vercel AI SDK who wants an agent to read Supabase documentation needs clean structured content before the agent can answer questions or generate code from those pages. Supabase docs pages serve navigation sidebars, version selectors, API reference tables, and inline code examples alongside the content, and fetching the page directly returns HTML that mixes layout markup with documentation text. EnConvert Distill accepts the Supabase docs URL and a schema the agent defines, and returns structured fields in one synchronous call. The agent gets schema-defined documentation content ready for downstream reasoning with no HTML parsing.

## Example

```typescript
import { openai } from "@ai-sdk/openai";
import { generateText, isStepCount, tool } from "ai";
import { z } from "zod";

const BASE_URL = "https://api.enconvert.com/v2";
const ENCONVERT_API_KEY = process.env.ENCONVERT_API_KEY!;
// The @ai-sdk/openai provider reads OPENAI_API_KEY from the environment

// The fields the agent receives. The response keys match these names exactly.
const DOCS_SCHEMA = {
  title: "The page title",
  summary: "A three sentence summary of what the page explains, using only text on the page",
  key_concepts: "The main concepts or features the page covers, as a list",
  code_examples_summary:
    "A one or two sentence description of what the code examples on the page do. Return an empty string if the page has no code examples.",
  related_docs:
    "The titles of related documentation pages linked from the main content, as a list. Return an empty list if there are none.",
};

interface DistillResult {
  url: string;
  status: "completed" | "failed";
  render_quality?: number;
  data?: Record<string, unknown>;
}

const asText = (value: unknown): string =>
  Array.isArray(value)
    ? value.join("; ") || "none stated"
    : value
      ? String(value)
      : "none stated";

const summariseSupabaseDocs = tool({
  description:
    "Reads Supabase documentation pages and returns structured fields for each page: " +
    "title, summary, key concepts, a description of its code examples, and related docs.",
  inputSchema: z.object({
    urls: z.array(z.string().url()).max(50).describe("Supabase docs page URLs to read, at most 50"),
  }),
  execute: async ({ urls }) => {
    // One synchronous call: no job_id, no polling, no download step
    const response = await fetch(`${BASE_URL}/distill`, {
      method: "POST",
      headers: {
        "X-API-Key": ENCONVERT_API_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ urls, schema: DOCS_SCHEMA }),
      signal: AbortSignal.timeout(300_000),
    });

    // Distill runs on paid plans only, and the free tier returns 402
    if (response.status === 402) {
      return "Distill requires a paid plan.";
    }
    if (!response.ok) {
      throw new Error(`Distill request failed with status ${response.status}`);
    }

    const { results } = (await response.json()) as { results: DistillResult[] };

    const pages = results.map((result) => {
      // Failed pages come back as rows with a failed status, not as errors
      if (result.status !== "completed" || !result.data) {
        return `Source: ${result.url}\nCould not be read (${result.status}).`;
      }

      // A render_quality below 0.5 may mean a login wall or challenge page
      const renderQuality = result.render_quality ?? 1.0;
      if (renderQuality < 0.5) {
        return `Source: ${result.url}\nLow render quality (${renderQuality}), skipped.`;
      }

      const data = result.data; // keys match DOCS_SCHEMA exactly
      return [
        `Source: ${result.url}`,
        `Title: ${asText(data.title)}`,
        `Key concepts: ${asText(data.key_concepts)}`,
        `Related docs: ${asText(data.related_docs)}`,
        `Code examples: ${asText(data.code_examples_summary)}`,
        `Summary: ${asText(data.summary)}`,
      ].join("\n");
    });

    return pages.join("\n\n---\n\n");
  },
});

async function main() {
  const { text } = await generateText({
    model: openai("gpt-4.1"),
    tools: { summariseSupabaseDocs },
    stopWhen: isStepCount(5),
    instructions:
      "You answer questions about Supabase using only the documentation pages you read. " +
      "Use summariseSupabaseDocs to read the pages you need, and cite the page URL for every statement.",
    prompt:
      "Read https://supabase.com/docs/guides/auth/row-level-security and " +
      "https://supabase.com/docs/guides/database/postgres/row-level-security, " +
      "and explain how row level security works for an authenticated user.",
  });

  console.log(text);
}

main();
```

## Output

Distill returns schema-defined fields inline as structured JSON in the data object, with no polling and no job_id. The render_quality score lets the agent detect a challenge page before reasoning over incomplete content. Fetching Supabase docs pages directly returns HTML containing sidebar navigation, versioning controls, and API reference markup alongside the content, while a dedicated parser needs CSS selectors that break when Supabase updates its docs layout.

## 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 Google Docs with Pydantic AI](https://www.enconvert.com/solutions/summarise-google-docs-with-pydantic-ai-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)
