SDKs
Python SDK
Everything you need to use Valyu in python
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.py
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. | 10 |
similarity_threshold | float | The minimum similarity required for a result to be included. | 0.5 |
query_rewrite | bool | Enables or disables query optimisation. | True |
max_price | float | 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) |
results_by_source | object | Count of results by source type (web/proprietary) |
total_deduction_pcm | float | Estimated CPM cost (cost per 1000 queries) |
total_deduction_dollars | float | Total cost in USD |
total_characters | integer | 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 | 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 |
relevance_score | float | Relevance score between 0 and 1 |