---
title: "Summarize text with LLMs"
description: "Generate concise summaries of long text, articles, or documents using large language models."
url: "https://www.pixeltable.com/notebooks/text-summarize"
updated: "2026-09-03"
---

# Summarize text with LLMs

Generate concise summaries of long text, articles, or documents using large language models.

- **Type:** Notebook
- **Group:** Text

## How it works

You add a computed column that calls an LLM to generate summaries. When you insert new text, summaries are generated automatically.

## What it covers

- Summarize text using OpenAI GPT models
- Customize summary style with prompts
- Process multiple documents automatically

## What it uses

- **Install:** `pip install pixeltable openai`
- **Environment variables it names:** `OPENAI_API_KEY`
- **Pixeltable calls:** `openai.chat_completions()`, `pxt.create_table()`, `insert()`, `add_computed_column()`

## A look at the code

```python
# Create prompt template for summarization
prompt = (
    'Summarize the following article in 2-3 sentences:\n\n'
    + articles.content
)

# Add computed column for LLM response
articles.add_computed_column(
    response=openai.chat_completions(
        messages=[{'role': 'user', 'content': prompt}],
        model='gpt-4o-mini',
    )
)
```

## Open it

- **Open in Colab:** https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/text/text-summarize.ipynb
- **Docs page:** https://docs.pixeltable.com/howto/cookbooks/text/text-summarize
- **Source on GitHub:** https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/text/text-summarize.ipynb
