SDKs
TypeScript SDK
Everything you need to use Valyu in TypeScript
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.ts
Advanced Usage
Here’s an example using more v2 parameters for targeted searches:
Input Parameters:
Parameter | Type | Description | Default |
---|---|---|---|
query | string | The input query to be processed. | Required |
searchType | 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” |
maxNumResults | number | The maximum number of results to be returned (1-20). | 5 |
relevanceThreshold | number | The minimum relevance score required for a result to be included (0.0-1.0). | 0.5 |
maxPrice | number | Maximum cost in dollars for this search. | 20.0 |
category | string | Natural language category to guide search context (optional). | undefined |
includedSources | string[] | List of specific datasets or URLs to search within (optional). | undefined |
startDate | string | Start date for time filtering in YYYY-MM-DD format (optional). | undefined |
endDate | string | End date for time filtering in YYYY-MM-DD format (optional). | undefined |
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) |
resultsBySource | object | Count of results by source type (web/proprietary) |
totalResults | number | Total number of results returned |
totalCharacters | number | 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 | number | Cost of this specific text chunk in USD |
length | number | Character length of the content |
image_url | object | Map of image identifiers to image URLs, can be used to render in frontend AI applications |
dataType | string | Type of data, either “unstructured” or “structured”. If structured (e.g. for stock data) it will be a string JSON object |
sourceType | string | Type of source (e.g., “paper”, “data”, “web”, “book”) |
relevanceScore | number | Relevance score between 0 and 1 |
publicationDate | 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”) |
citationCount | number | Number of citations (for source_type “paper”) |
authors | string[] | List of author names (for source_type “paper” and “book”) |
references | string | References section content (for source_type “paper” and “book”) |
For detailed documentation on each feature, please refer to their respective pages: