Guide2 min read

How Agents Run SEO Keyword Research Loops

Run a governed SEO keyword research loop per tenant with AgentSEO — volume, SERP competitors, and Labs insights via forUser, plan-metered and audit-logged.

Read the docs →

Guide
TL;DR
  • Keyword research loops fail in production when every tenant shares one API key and there is no audit trail of what the agent queried
  • AgentSEO (/seo) wraps Keywords Data, Backlinks, and SEO Labs so agents call searchVolume, serpCompetitors, and labs keyword-overview through one governed interface
  • Scope every loop with naive.forUser(clientId) so Client A's research never bills or logs against Client B
  • A typical loop is seed keyword → volume check → SERP competitors → Labs overview → store results in your app DB or deliver by email
  • When you sell tiers, pair the loop with Customer Billing so seo calls meter per tenant and return 429 rate_limited at quota see the usage-metered SEO SaaS guide
  • Company → Employee → Primitive: your platform defines policy, each customer's research agent acts on their behalf, /seo is the data primitive

An SEO agent that only drafts blog titles from memory misses the part buyers pay for: fresh keyword volume, live SERP competitors, and difficulty signals tied to each customer account. Naïve gives multi-tenant products the AgentSEO primitive (/seo) so a research loop runs on governed data instead of a shared scraper key in a prompt.

This guide shows a keyword research loop you can run per tenant: seed topic in, structured opportunity out — scoped with naive.forUser(clientId), compatible with usage-metered plans, and wired into the broader autonomous company model (Company → Employee → Primitive).

SEO keyword research loop scoped per tenant on Naïve

Loop architecture

StepAgentSEO callOutput
1. SeedYour app passes { seedKeyword, locale }Loop input
2. VolumesearchVolume([seed, ...variants])Monthly volume estimates
3. SERPserpCompetitors([seed])Domains ranking today
4. Labslabs("google", "keyword-overview", { keywords: [seed] })Difficulty, related terms
5. DeliverStore in DB, email brief, or hand to writer agentCustomer-facing artifact

Each step uses the same tenant scope. If you also run AEO brand tracking, add a parallel branch with /aeo after step 4.

Setup

npm install @usenaive-sdk/server
import { Naive } from "@usenaive-sdk/server";
 
const naive = new Naive({ apiKey: process.env.NAIVE_API_KEY! });

Provision the customer once:

const client = await naive.users.create({
  external_id: "acme_corp_uuid",
  email: "seo@acme.example",
  label: "Acme Corp",
});

Use naive.forUser(client.id) for every SEO call in the loop.

The loop

async function runKeywordResearchLoop(tenantId: string, seed: string) {
  const seo = naive.forUser(tenantId).seo;
 
  const volume = await seo.searchVolume([seed, `${seed} software`, `${seed} platform`]);
  const competitors = await seo.serpCompetitors([seed]);
  const overview = await seo.labs("google", "keyword-overview", { keywords: [seed] });
 
  return {
    seed,
    volume,
    competitors,
    overview,
    generatedAt: new Date().toISOString(),
  };
}
  • Signatures match the seo sub-client.
  • CLI equivalent for debugging: naive seo keywords google search-volume --keywords "<seed>" --location-code 2840.
  • Credit costs per endpoint are listed on the SEO getting-started page.

Scheduling and orchestration

Run the loop on a cron, a queue worker, or your orchestration employee:

  1. Cron — nightly refresh for every active tenant.
  2. Event-driven — customer adds a new seed keyword in your UI.
  3. CEO agent — kanban task "Research Q3 content cluster" dispatches the loop per brand.

Log each run in your app and optionally attach Naïve audit logs for compliance.

Multi-tenant and metering

For a SaaS product, the loop is identical for every customer; only tenantId changes. When you sell tiers:

  • Enable /seo per tier via Account Kits.
  • Cap calls per month via Customer Billing quotas — the 2001st searchVolume returns 429 rate_limited, not a silent overage.

See How to Build a Usage-Metered AI SEO SaaS for the full billing wiring.

Related reading

Frequently Asked Questions
What is an SEO keyword research loop for agents?+
It is a repeating workflow where an agent takes a seed topic, pulls search volume and competitor data, ranks opportunities, and writes the next action — brief, content outline, or ad copy. On Naïve the loop calls the /seo primitive (AgentSEO) instead of wiring DataForSEO keys per customer. Each iteration is scoped to one tenant user and logged like any other primitive call.
Which AgentSEO endpoints should a research loop use?+
Start with searchVolume for demand, serpCompetitors for who ranks today, and labs keyword-overview for difficulty and related terms. The CLI mirrors the SDK: naive seo keywords google search-volume and naive seo labs google keyword-overview. All live endpoints are documented at usenaive.ai/docs/getting-started/seo with credit costs per call.
How do I run the loop for many customers?+
Create one tenant user per customer with naive.users.create, assign an Account Kit that enables seo, then call naive.forUser(customerId).seo for every step. The scoped client cannot read another tenant's history or spend their quota. Store loop outputs in your database keyed by your external_id.
How does this relate to AEO and brand tracking?+
SEO loops answer what people type into Google; AEO tracks what ChatGPT and Perplexity say when asked similar questions. Many products run both: AgentSEO for classic keyword intel, AgentAEO for AI-search visibility. See how-agents-track-brand-mentions-in-ai-search for the companion loop.
How do I get started?+
Install @usenaive-sdk/server, provision tenant users and Account Kits, then implement the loop below with naive.forUser(id).seo. Full API surface: usenaive.ai/docs/getting-started/seo.
NT
Naïve Team

Building the autonomous company infrastructure.

Keep reading