---
title: "Extract fields from LLM JSON responses"
description: "Parse and access specific fields from structured JSON responses returned by language models."
url: "https://www.pixeltable.com/notebooks/workflow-json-extraction"
updated: "2026-04-10"
---

# Extract fields from LLM JSON responses

Parse and access specific fields from structured JSON responses returned by language models.

- **Type:** Notebook
- **Group:** Core Operations

## How it works

You use JSON path notation to extract specific fields from API responses and store them in computed columns.

## What it covers

- Extract text content from chat completions
- Access nested JSON fields
- Create separate columns for different fields

## 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
# Add computed column for API response (returns full JSON)
t.add_computed_column(
    response=openai.chat_completions(
        messages=[{'role': 'user', 'content': t.prompt}],
        model='gpt-4o-mini',
    )
)
```

## Open it

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