Provider configuration including organization ID, token, and optional overrides.
import { createContentAgent } from 'content-agent'
const contentAgent = createContentAgent({
organizationId: 'your-org-id',
token: 'your-sanity-token',
})
import { createContentAgent } from 'content-agent'
import { generateText, streamText } from 'ai'
const contentAgent = createContentAgent({
organizationId: 'your-org-id',
token: 'your-sanity-token',
})
const model = contentAgent.agent('my-thread-id', {
application: { key: 'projectId.datasetName' },
config: {
capabilities: { read: true, write: false },
},
})
// Non-streaming
const { text } = await generateText({ model, prompt: 'What blog posts do I have?' })
// Streaming
const { textStream } = await streamText({ model, prompt: 'Summarize my content' })
for await (const chunk of textStream) {
process.stdout.write(chunk)
}
Creates a Content Agent provider instance.
The provider is the main entry point for interacting with the Sanity Content Agent API. It returns an object with methods for conversation threads and one-shot prompts.