Looking for the Python SDK Reference? Head to our Python SDK Reference and learn how to use tavily-python.

Introduction

The Python SDK allows for easy interaction with the Tavily API, offering the full range of our search functionality directly from your Python programs. Easily integrate smart search capabilities into your applications, harnessing Tavily’s powerful search features.

GitHub

/tavily-ai/tavily-python

Dive into our source code!

Quickstart

Get started with our Python SDK in less than 5 minutes!

Get your free API key

You get 1,000 free API Credits every month. No credit card required.

Installation

You can install the Tavily Python SDK using the following:

pip install tavily-python

Usage

With Tavily’s Python SDK, you can search the web in only 4 lines of code:

from tavily import TavilyClient

tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
response = tavily_client.search("Who is Leo Messi?")

print(response)

You can also easily extract content from URLs:

from tavily import TavilyClient

tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
response = tavily_client.extract("https://en.wikipedia.org/wiki/Lionel_Messi")

print(response)

These examples are very simple, and you can do so much more with Tavily!

Features

Our Python SDK supports the full feature range of our REST API, and more. We offer both a synchronous and an asynchronous client, for increased flexibility.

  • The search function lets you harness the full power of Tavily Search.
  • The extract function allows you to easily retrieve web content with Tavily Extract.

For more details, head to the Python SDK Reference.