content-agent weekly downloads statistics
Vercel AI SDK provider for Sanity Content Agent API
content-agent has 1,445 recorded weekly downloads on npm, a decrease of 40.8% over the past 30 days, ranking #1413 of 2,391 tracked listings.
About content-agent
content-agent
Vercel AI SDK provider for Sanity Content Agent API.
Installation
npm install content-agent ai
Usage
ContentAgent extends the AI SDK's ToolLoopAgent — it inherits .generate(), .stream(), telemetry, and every other capability of the AI SDK's first-class agent abstraction. Construction is the only thing that differs: pass a provider and threadId instead of a model, and ContentAgent resolves the model for you.
import { createContentAgent } from "content-agent";
import { ContentAgent } from "content-agent/agent";
const provider = createContentAgent({
organizationId: "your-org-id",
token: "your-sanity-token",
});
const agent = new ContentAgent({
provider,
threadId: "my-thread",
});
const { text } = await agent.generate({
prompt: "What blog posts do I have?",
});
provider is reusable — create it once per organization and instantiate as many ContentAgents as you need.
Why a class instead of
streamText({ model, ... })?The AI SDK 6 explicitly invites SDK authors to ship their own
Agentimplementations: "TheAgentis now an interface instead of a class, which allows developers to implement their own agent abstractions for specific needs."ContentAgentis that implementation for the Sanity Content Agent — it preconfiguresstopWhen,prepareStep, andtoolChoicefor thefinal_answerreply pipeline so you don't have to.
Migrating from
streamText({ model: provider.agent(threadId) })? Nothing breaks — the lower-level API is still supported and works exactly as before. Switch toContentAgentto pick up the safe defaults that prevent empty responses when the model burns its step budget on client tool calls. See How replies work below.
Streaming
const result = await agent.stream({
prompt: "Summarize my latest content",
});
for await (const text of result.textStream) {
process.stdout.write(text);
}
Tools
Pass AI SDK tools to the constructor — schemas are forwarded to the agent, and execution happens locally on the client:
import { ContentAgent } from "content-agent/agent";
import { tool } from "ai";
import { z } from "zod";
const agent = new ContentAgent({
provider,
threadId: "my-thread",
tools: {
submit_for_review: tool({
description: "Submit a document for editorial review.",
inputSchema: z.object({
documentId: z.string().describe("The Sanity document _id"),
email: z.string().email().describe("Reviewer email"),
note: z.string().optional().describe("Note for the reviewer"),
}),
execute: async ({ documentId, email, note }) => {
const res = await fetch("https://workflows.example.com/api/review", {
method: "POST",
body: JSON.stringify({ documentId, email, note }),
});
return res.json();
},
}),
},
});
const result = await agent.stream({
prompt: "Find all draft blog posts and submit them for review.",
});
How replies work
Every reply is delivered through a server-side final_answer tool call. The agent streams final_answer.message to the wire as text-delta chunks (parsed incrementally from the tool-call args) and includes structured suggestions for clients that render reply buttons. There's no separate "streaming mode" — every conversation, every client follows the same path.
ContentAgent adjusts the loop control primitives to make this safe by default:
stopWhendefaults to "stop on the first step that contains afinal_answertool call," plus astepCountIs(20)safety cap. Afinal_answeraccompanied by other tool calls in the same step is the canonical act-and-answer pattern — the loop terminates without an extra round-trip.prepareStepis composed with a safety net that, on the cap step, forcestoolChoice{ type: 'tool', toolName: 'final_answer' }if the model has been calling tools without ever converging onfinal_answer. This guarantees a reply on the wire even in pathological cases where the model would otherwise burn its step budget on client-tool round-trips.- Server-side recovery (SAGE-248) — if the model fails to call
final_answernaturally on any single turn, the agent runner retries that turn with forcedtool_choice. Anthropic's API enforces forced tool choice strictly; the recovery is guaranteed to produce afinal_answerchunk.
If you pass your own stopWhen or prepareStep, they take precedence — ContentAgent doesn't reach into them.
Applications
Each application key uniquely identifies a deployed Sanity Studio workspace. Since multiple studios can share the same project ID and dataset, the application key disambiguates which one to target.
List available applications for your organization, then target one by its key:
const apps = await provider.applications();
const app = apps.find((app) => app.title === "My Studio");
const agent = new ContentAgent({
provider,
threadId: "my-thread",
application: { key: app.key },
});
You can also set a default application on the provider so every agent and .prompt() call inherits it:
const provider = createContentAgent({
organizationId: "your-org-id",
token: "your-token",
application: resolvedApp,
});
Configuration
Pass a config object to control agent behavior:…
Description from the npm listing.
- sanity
- content-agent
- ai-sdk
- vercel-ai
- provider
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (122)Similar npm AI SDKs plugins
All 20 content-agent alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/content-agent. First seen Oct 16, 2026; last successful collection Oct 21, 2026. See the methodology.