---
title: "Create text embeddings with OpenAI"
description: "Generate vector embeddings for text data to enable semantic search and similarity matching."
url: "https://www.pixeltable.com/notebooks/embed-text-openai"
updated: "2026-09-03"
---

# Create text embeddings with OpenAI

Generate vector embeddings for text data to enable semantic search and similarity matching.

- **Type:** Notebook
- **Group:** Search & Embeddings

## How it works

You add an embedding column that automatically generates vectors for new rows. The embeddings are cached and only recomputed when the source text changes.

## What it covers

- Generate embeddings with OpenAI's models
- Store embeddings as computed columns
- Use embeddings for similarity queries

## What it uses

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

## A look at the code

```python
# Add embedding column using OpenAI's text-embedding-3-small
docs.add_computed_column(
    embedding=embeddings(docs.content, model='text-embedding-3-small')
)
```

## Open it

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