SDKs
TypeScript SDK
Everything you need to use Valyu in TypeScript
The Valyu SDK provides access to the following features:
1. Deep Search - Search and retrieve relevant content from proprietary and public sources 2. Feedback - Submit feedback on search results using transaction IDs
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 context search feature with a simple example:
main.ts
Input Parameters:
Parameter | Type | Description | Default |
---|---|---|---|
query | string | 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” |
maxNumResults | number | The maximum number of results to be returned. | 10 |
similarityThreshold | number | The minimum similarity required for a result to be included. | 0.5 |
queryRewrite | boolean | Enables or disables query optimisation. | true |
maxPrice | number | Maximum price per thousand queries (CPM). | Required |
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) |
totalDeductionPcm | number | Estimated CPM cost (cost per 1000 queries) |
totalDeductionDollars | number | Total cost in USD |
totalCharacters | number | Total number of characters in results |
Results Object:
Parameter | Type | Description |
---|---|---|
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, either proprietary or web |
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 |
relevanceScore | number | Relevance score between 0 and 1 |
For detailed documentation on each feature, please refer to their respective pages: