メインコンテンツへスキップ
Last verified: 2026-06-03

Overview

Add live web search and page extraction to a Cartesia Line voice agent using loopback tools backed by Tavily. The agent can answer questions about current events, fresh facts, and specific URLs mid-call.

Prerequisites

  • Python 3.10+
  • A Cartesia API key (CARTESIA_API_KEY) from Cartesia keys
  • A Tavily API key (TAVILY_API_KEY) from the Tavily dashboard
  • An LLM provider key — OPENAI_API_KEY for the example below
  • The Cartesia CLI for local chat testing (Line quickstart)

Installation

Set the three keys in your environment before running the agent:

Quick start

Define two loopback tools backed by AsyncTavilyClient — one for search, one for full-page extraction — and pass them to an LlmAgent. Run the file, then connect with cartesia chat 8000.
Run it:
You’ll hear: “Hey! I’m your research assistant, powered by Tavily and Cartesia…” Try asking about recent news or pointing it at a specific URL.

Configuration

Both tools accept the standard Tavily parameters — these are the ones worth tuning for a voice agent:
ParameterTypeDefaultDescription
search_depthstring"fast""fast" for voice latency; "advanced" for deeper retrieval at higher latency.
max_resultsint5Number of search results returned to the LLM.
time_rangestringNoneRecency filter — "day", "week", "month", "year".
EXTRACT_MAX_CHARSint3000Local cap on extracted page content to keep the LLM context tight.
See the Tavily Search API reference for the full parameter set, including topic, include_domains, and country.

Resources