Crates.io | tavily |
lib.rs | tavily |
version | 2.0.3 |
source | src |
created_at | 2024-04-24 17:36:49.648537 |
updated_at | 2024-12-07 06:06:50.509136 |
description | A tiny tool for calling Tavily's REST API in the simplest way! |
homepage | |
repository | https://github.com/PierreLouisLetoquart/tavily-rs |
max_upload_size | |
id | 1219342 |
size | 53,006 |
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.
cargo add tavily
or add it to your Cargo.toml
:
[dependencies]
tavily = "^2.0.0"
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(())
}
For detailed examples and API documentation, check out: