How to Summarise Stripe Docs with OpenAI Agents SDK

How to summarise Stripe docs inside an OpenAI Agents SDK agent with EnConvert Distill, returning a clean LLM-ready summary of any docs page in one call

Get API key

An OpenAI Agents SDK agent that reads Stripe documentation needs a summary of the page, not the page chrome around it. Stripe docs pages carry navigation sidebars, version selectors, language switchers, feedback widgets, and embedded code tabs, and all of it lands in the output when you fetch a URL directly. The docs are public, but their structure makes raw HTML extraction unreliable: much of the content is rendered client-side, and what you get back mixes documentation prose with UI chrome in a way that degrades the context your agent reasons over. EnConvert’s Distill endpoint takes a Stripe docs URL and returns a clean summary of the page content in one API call, ready to pass into an OpenAI Agents SDK tool.

Example

python
import os

import requests
from agents import Agent, Runner, function_tool

ENCONVERT_API_KEY = os.environ["ENCONVERT_API_KEY"]
# The Agents SDK reads OPENAI_API_KEY from the environment on its own.


@function_tool
def summarise_stripe_docs(url: str) -> str:
    """Takes a Stripe documentation URL (API reference, integration guide,
    changelog entry, or error code page) and returns a clean summary.

    Args:
        url: The Stripe documentation page to summarise.
    """
    # Step 1: Distill the page into a summary
    response = requests.post(
        "https://api.enconvert.com/v2/distill",
        headers={
            "X-API-Key": ENCONVERT_API_KEY,
            "Content-Type": "application/json",
        },
        json={
            "urls": [url],
            "schema": {
                "summary": (
                    "a thorough summary of the documentation page, covering "
                    "its main concepts, parameters, states and error codes"
                ),
            },
        },
        timeout=120,
    )
    response.raise_for_status()

    # Distill reports failures per URL, so check the item itself
    item = response.json()["results"][0]
    summary = (item.get("data") or {}).get("summary")
    if item.get("error") or not summary:
        raise RuntimeError(
            f"Distill failed for {url}: {item.get('error') or item.get('warnings')}"
        )
    return summary


# Step 2: Give the summary tool to an OpenAI Agents SDK agent
agent = Agent(
    name="Stripe Docs Assistant",
    instructions=(
        "You help engineers understand Stripe documentation. "
        "Use the summarise_stripe_docs tool to read a page before answering."
    ),
    tools=[summarise_stripe_docs],
)

result = Runner.run_sync(
    agent,
    "Summarise https://docs.stripe.com/payments/payment-intents "
    "and explain the lifecycle of a PaymentIntent.",
)
print(result.final_output)

What you get back

Distill returns the page title and documentation content as clean prose, with navigation sidebars, version selectors, language tabs, and feedback widgets stripped before the response comes back. Fetching the raw HTML instead returns client-side rendered markup with UI chrome embedded in the text. The output degrades further on JavaScript-heavy pages, where the documentation content is not present in the initial HTML response at all.

Get free API key — 500 ops per month, no card required.