> For the complete documentation index, see [llms.txt](https://docs.overflowcms.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overflowcms.com/webflow-integration/ai-search-and-related-items.md).

# AI Search & Related Items

## AI Search & Related Items

### AI Search & Related Items

**Pro plan and above.** Semantic search and "related items" for your published content — matching by meaning, not just keyword, powered by Workers AI embeddings and a shared vector index.

#### How it works

Whenever an item publishes, its text/richText/option fields are embedded into a vector and stored alongside the item. Searching (or asking for "related items") compares vectors by similarity, so a search for "budgeting tips for freelancers" can surface an article titled "How to manage irregular income" even though none of the words match. Unpublishing or deleting an item removes its vector automatically.

#### Search box

```html
<div data-oc-search="blog" data-oc-limit="10">
  <input data-oc-search-input type="search" placeholder="Search…">
  <div data-oc-item>
    <h3 data-oc-field="title"></h3>
    <div data-oc-field="excerpt"></div>
    <a data-oc-link href="/blog/">Read more</a>
  </div>
  <div data-oc-empty>No results.</div>
</div>
```

* **`data-oc-search="<slug>"`** — scopes search to one collection. Leave the value empty to search every collection on the site.
* **`data-oc-search-input`** — the `<input>` the visitor types into. Search fires automatically about 250ms after typing stops, once at least 2 characters are entered; shorter queries just clear the results.
* Everything else — `[data-oc-item]`, `[data-oc-empty]`, field binding, `data-oc-loading`/`data-oc-error` — follows the same contract as a list block (see Embed Script Basics).

#### Related items

```html
<div data-oc-related="blog" data-oc-limit="4">
  <div data-oc-item>
    <h3 data-oc-field="title"></h3>
    <div data-oc-field="excerpt"></div>
    <a data-oc-link href="/blog/">Read more</a>
  </div>
  <div data-oc-empty>Nothing related yet.</div>
</div>
```

* **`data-oc-related="<slug>"`** — the collection the *current* item belongs to.
* The widget needs to know which item it's finding related content *for*. By default it reads the last segment of the current page's URL as that item's slug — so it only does anything on a real item detail page (e.g. `/blog/how-to-brew-the-perfect-cup-of-pour-over-coffee`), not on a listing page or the homepage. If your detail page URL doesn't end in the item's slug, set it explicitly with **`data-oc-item-slug="<slug>"`**.

{% hint style="warning" %}
Placing `data-oc-related` on a page with no item context (the homepage, a listing page) is a no-op by design — there's nothing to be "related to," so the widget does nothing rather than fetch and render garbage. If the block looks empty while testing, check you're on a URL that actually identifies an item.
{% endhint %}

#### Plan tiers

Both widgets require Pro or above (`flags.aiSearch`) — see Plans & Billing. Below that tier the underlying endpoints return `403 plan_required`, and these widgets simply render nothing (their `[data-oc-empty]` block, if you have one) rather than showing visitors an error.

Full request/response shapes, the relevance-score cutoff, and error codes are in the API Reference's Search & Related Items page.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.overflowcms.com/webflow-integration/ai-search-and-related-items.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
