SDKs
Python SDK
Everything you need to use Valyu in python
The Valyu SDK provides access to the following features:
- Deep Search - Search and retrieve relevant content from proprietary and public sources
Getting Started
Install the Valyu SDK
And then instantiate the Valyu client - you can obtain your API key here ($10 free credits cus we are legends)
Quick Start
Let’s see how to use the deep search feature with a simple example:
main.py
Advanced Usage
Here’s an example using more v2 parameters for targeted searches:
Input Parameters:
Parameter | Type | Description | Default |
---|---|---|---|
query | str | The input query to be processed. | Required |
search_type | Literal[‘all’, ‘proprietary’, ‘web’] | Specifies the type of search to be performed. ‘all’ includes both proprietary and web sources, ‘proprietary’ searches over Valyu indices, and ‘web’ is just web search. | ”all” |
max_num_results | int | The maximum number of results to be returned (1-20). | 5 |
relevance_threshold | float | The minimum relevance score required for a result to be included (0.0-1.0). | 0.5 |
max_price | float | Maximum cost in dollars for this search. | 20.0 |
category | str | Natural language category to guide search context (optional). | None |
included_sources | List[str] | List of specific datasets or URLs to search within (optional). | None |
start_date | str | Start date for time filtering in YYYY-MM-DD format (optional). | None |
end_date | str | End date for time filtering in YYYY-MM-DD format (optional). | None |
Example Response:
Output Parameters:
Parameter | Type | Description |
---|---|---|
success | boolean | Indicates if the request was successful |
error | string | Error message if any |
tx_id | string | Unique transaction ID for the request |
query | string | The processed query string |
results | array | Array of result objects (see Results Object table below) |
results_by_source | object | Count of results by source type (web/proprietary) |
total_results | integer | Total number of results returned |
total_characters | integer | Total number of characters in results |
Results Object:
Parameter | Type | Description |
---|---|---|
id | string | Unique identifier for the result (optional) |
title | string | Title of the result |
url | string | URL of the source |
content | string | The actual text chunk of the result |
source | string | Source identifier (e.g., “valyu/valyu-arxiv”, “valyu/valyu-stocks-US”) |
price | float | Cost of this specific text chunk in USD |
length | integer | Character length of the content |
image_url | object | Map of image identifiers to image URLs, can be used to render in frontend AI applications |
data_type | string | Type of data, either “unstructured” or “structured”. If structured (e.g. for stock data) it will be a string JSON object |
source_type | string | Type of source (e.g., “paper”, “data”, “web”, “book”) |
relevance_score | float | Relevance score between 0 and 1 |
publication_date | string | Publication date in YYYY-MM-DD format (for source_type “paper” and “book”) |
doi | string | Digital Object Identifier (for source_type “paper” and “book”) |
citation | string | Formatted citation string (for source_type “paper”) |
citation_count | integer | Number of citations (for source_type “paper”) |
authors | array | List of author names (for source_type “paper” and “book”) |
references | string | References section content (for source_type “paper” and “book”) |