9 releases (5 stable)

new 2.0.3 Dec 7, 2024
1.0.1 Dec 6, 2024
1.0.0 Apr 24, 2024
0.2.2 Apr 24, 2024
0.1.0 Apr 24, 2024

#530 in Web programming

Download history 4/week @ 2024-09-30 4/week @ 2024-11-25 412/week @ 2024-12-02

416 downloads per month

MIT license

18KB
319 lines

Tavily Rust SDK

Unofficial (for now 🫠) Rust SDK for the Tavily Search API - the AI-powered search engine for LLM applications 🚀

[!NOTE] Requires an API key. You can get one by signing up at Tavily. The API key should be kept secure and not shared publicly.

Installation

cargo add tavily

or add it to your Cargo.toml:

[dependencies]
tavily = "^2.0.0"

Quick Start

use tavily::{Tavily, SearchRequest, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let tavily = Tavily::builder("tvly-your-api-key")
        .timeout(Duration::from_secs(60))
        .max_retries(5)
        .build()?;
    
    // Simple search
    let results = tavily.search("Latest AI developments").await?;

    // Advanced search with customization
    let mut request = SearchRequest::new("tvly-your-api-key", "Breaking tech news");
    request
        .search_depth("advanced")
        .topic("news")
        .include_answer(true)
        .max_results(10);
    
    let results = tavily.call(&request).await?;

    // Extract content from URLs
    let urls = vec![
        "https://tavily.com/",
        "https://github.com/PierreLouisLetoquart",
        "https://www.google.com/",
    ];
    let results = tavily.extract(urls).await?;

    Ok(())
}

Features

  • Simple Search: Quick search queries with minimal configuration
  • Answer Mode: Get AI-generated answers along with search results
  • Advanced Customization: Control search depth, topics, time range, and more
  • Domain Filtering: Include or exclude specific domains
  • Rich Content: Optional image results and descriptions

Documentation

For detailed examples and API documentation, check out:

License

MIT

Dependencies

~4–15MB
~199K SLoC