Build a research agent that searches the web and cites its sources

An agent that looks things up live, reads the results and answers with numbered sources.

Make an API keyCreate free account

Uses

SearchSmart modelPeople building AI agents

How it works

  1. Make an account and approve a daily spending limit in Billing.
  2. Make an API key and keep it in an environment variable.
  3. Search, then hand the results to the Smart model and ask it to cite them.

The code

TypeScript, with the Zuzo SDK. Your API key and spending limit come from the console; the docs cover every option.

import { Zuzo } from "@zuzo/sdk";

const zuzo = new Zuzo({ apiKey: process.env.ZUZO_API_KEY! });

const question = "What are the main open-source AI agent frameworks?";
const { results } = await zuzo.search(question);
const sources = results
  .slice(0, 5)
  .map((r, i) => `[${i + 1}] ${r.title} (${r.url})\n${r.snippet}`)
  .join("\n\n");

const { text, charge } = await zuzo.chat(
  [
    { role: "system", content: "Answer only from the sources. Cite them like [1]. Say if they don't cover it." },
    { role: "user", content: `${question}\n\nSources:\n${sources}` },
  ],
  { model: "smart" },
);
console.log(text);
console.log(`Cost: $${charge.usd}`);

Questions

Are my searches private?

No. Search queries go to a search provider, so don't put anything confidential in them. The answer step can run in Private mode.

What does it cost?

You pay per search and per model call, and every answer says what it cost. See the pricing page for current prices.

More for agent builders