tavily_dart 0.1.0+1 copy "tavily_dart: ^0.1.0+1" to clipboard
tavily_dart: ^0.1.0+1 copied to clipboard

Dart Client for the Tavily API (a search engine optimized for LLMs and RAG).

Tavily Dart Client #

tests tavily_dart MIT

Dart Client for the Tavily API (a search engine optimized for LLMs and RAG).

Features #

  • Fully type-safe, documented and tested
  • All platforms supported
  • Custom base URL, headers and query params support (e.g. HTTP proxies)
  • Custom HTTP client support (e.g. SOCKS5 proxies or advanced use cases)

Supported endpoints:

  • Search

Table of contents #

Usage #

Refer to the documentation for more information about the API.

Authentication #

The Tavily API uses API keys for authentication. Visit the Tavily console to retrieve the API key you'll use in your requests.

Remember that your API key is a secret!
Do not share it with others or expose it in any client-side code (browsers, apps). Production requests must be routed through your own backend server where your API key can be securely loaded from an environment variable or key management service.

final apiKey = Platform.environment['TAVILY_API_KEY'];
final client = TavilyClient();

Search for data based on a query.

Basic search:

final res = await client.search(
  request: SearchRequest(
    apiKey: apiKey,
    query: 'Should I invest in Apple right now?',
  ),
);
print(res);

Advanced search:

final res = await client.search(
  request: SearchRequest(
    apiKey: apiKey,
    query: 'Should I invest in Apple right now?',
    searchDepth: SearchRequestSearchDepth.advanced,
  ),
);
print(res);

See the API documentation for more information on all supported search parameters.

Advance Usage #

Custom HTTP client #

You can always provide your own implementation of http.Client for further customization:

final client = TavilyClient(
  client: MyHttpClient(),
);

Using a proxy #

HTTP proxy

You can use your own HTTP proxy by overriding the baseUrl and providing your required headers:

final client = TavilyClient(
  baseUrl: 'https://my-proxy.com',
  headers: {
      'x-my-proxy-header': 'value',
  },
);

If you need further customization, you can always provide your own http.Client.

SOCKS5 proxy

To use a SOCKS5 proxy, you can use the socks5_proxy package:

final baseHttpClient = HttpClient();
SocksTCPClient.assignToHttpClient(baseHttpClient, [
  ProxySettings(InternetAddress.loopbackIPv4, 1080),
]);
final httpClient = IOClient(baseClient);

final client = TavilyClient(
  client: httpClient,
);

Acknowledgements #

The generation of this client was made possible by the openapi_spec package.

License #

Tavily Dart Client is licensed under the MIT License.

2
likes
160
points
104
downloads

Publisher

verified publisherlangchaindart.dev

Weekly Downloads

Dart Client for the Tavily API (a search engine optimized for LLMs and RAG).

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#ai #llms #search #rag

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

fetch_client, freezed_annotation, http, json_annotation, meta

More

Packages that depend on tavily_dart