Sanity
On a site whose posts live in Sanity, agentprose’s tools read published content straight from your dataset’s API CDN with GROQ. No token goes in the page.
On your website
Section titled “On your website”<script src="https://cdn.jsdelivr.net/npm/agentprose@0/dist/agentprose.min.js" defer data-adapter="sanity" data-project="abc123" data-dataset="production" data-url-pattern="https://example.com/blog/{slug}/"></script>- The dataset must be public. For a private dataset, use proxy mode.
- Add your site’s origin (for example
https://example.com) to the project’s CORS origins in manage.sanity.io → API, without credentials. data-type(defaultpost) names the document type of posts;data-url-patternturns a slug into the post’s URL on your site.
The default projection fits Sanity’s blog template and the Next.js starter: title, slug, excerpt, body or content (Portable Text), publishedAt or date, author->name, categories[]->title, mainImage or coverImage. Other schemas set projection through the npm package. Search uses GROQ match with score(). Only published documents are read (perspective=published).
Studio plugin
Section titled “Studio plugin”sanity-plugin-agentprose adds an AI agents tool to Sanity Studio (v5 and v6): the posts agents will list, search the way search_posts does, each post as the markdown get_post returns, the install snippet for this project, and warnings for a private dataset or a missing CORS origin.
npm install sanity-plugin-agentproseimport {agentprose} from 'sanity-plugin-agentprose'
export default defineConfig({ // ... plugins: [agentprose({urlPattern: 'https://example.com/blog/{slug}/'})],})Options: urlPattern, type, projection, apiVersion, title. Source and tests: sanity-plugin/.