Tavily Python SDK

0.7.23 · active · verified Thu Apr 09

The `tavily-python` library provides a Python wrapper for the Tavily API, enabling easy integration of web search, content extraction, crawling, mapping, and research functionalities into Python applications. It supports both synchronous and asynchronous clients. The library is under active development with frequent updates, with its current version being 0.7.23.

Warnings

Install

Imports

Quickstart

This quickstart initializes the TavilyClient with an API key from an environment variable and performs a basic search query. It includes a check to ensure the API key is provided, which is crucial for successful API calls.

import os
from tavily import TavilyClient

tavily_client = TavilyClient(api_key=os.environ.get('TAVILY_API_KEY', ''))

if not tavily_client.api_key:
    raise ValueError("TAVILY_API_KEY environment variable not set. Get your key from tavily.com.")

response = tavily_client.search("What is the capital of France?")
print(response)

view raw JSON →