Tavily Rust SDK
The Tavily Rust SDK is a library for interacting with the Tavily Search API. With just a few lines of code, you can perform simple or advanced search queries, customize your search options, and get relevant search results powered by LLMs 🚀.
Note: Required an api key
Functions
The Tavily Rust SDK provides three main functions:
search: Perform a simple search query with a single argument,query.
let response = tavily.search.await?;
answer: Perform an advanced search query that includes an answer to your query. This function takes a bit more time than the simple search.
let response = tavily.answer.await?;
call: Perform a custom search query using theSearchRequeststruct. This struct provides a range of options for customizing your search:
let mut request = new;
request.search_depth; // "basic" or "advanced"
request.topic; // "general" or "news"
request.days; // Only for "news" topic
request.include_answer;
request.include_images;
request.include_image_descriptions;
request.include_raw_content;
request.max_results;
request.include_domains;
request.exclude_domains;
let response = tavily.call.await?;
Getting Started
To get started with the Tavily Rust SDK, add the following to your Cargo.toml
file:
tavily = "^1.0.0"
Then, import the library in your Rust code:
use ;
Here's a simple example of how to use the library to perform a search query:
async
You can also customize the search options by using the SearchRequest struct:
async
Error Codes
The Tavily Search API may return various HTTP status codes. For a complete list and their meanings, please refer to the official documentation.
Local Testing and Examples
The SDK includes example code in the examples/ directory. To run the examples:
- Set your Tavily API key as an environment variable:
- Run an example using cargo:
Disclaimer
This is an unofficial SDK for the Tavily Search API. For the official documentation and support, please visit Tavily Search API.