valyu-js 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Valyu SDK
2
2
 
3
- **DeepSearch API for AI**
3
+ **Search for AIs**
4
4
 
5
5
  Valyu's Deepsearch API gives AI the context it needs. Integrate trusted, high-quality public and proprietary sources, with full-text multimodal retrieval.
6
6
 
@@ -10,7 +10,7 @@ Get **$10 free credits** for the Valyu API when you sign up at [Valyu](https://p
10
10
 
11
11
  ## How does it work?
12
12
 
13
- We do all the heavy lifting for you - through a single API we provide:
13
+ We do all the heavy lifting for you - one unified API for all data:
14
14
 
15
15
  - **Academic & Research Content** - Access millions of scholarly papers and textbooks
16
16
  - **Real-time Web Search** - Get the latest information from across the internet
@@ -36,7 +36,11 @@ const { Valyu } = require('valyu');
36
36
  const valyu = new Valyu("your-api-key-here");
37
37
 
38
38
  const response = await valyu.search(
39
- "Implementation details of agentic search-enhanced large reasoning models"
39
+ "Implementation details of agentic search-enhanced large reasoning models",
40
+ {
41
+ maxNumResults: 5, // Limit to top 5 results
42
+ maxPrice: 10 // Maximum price per thousand queries (CPM)
43
+ }
40
44
  );
41
45
 
42
46
  console.log(response);
@@ -81,7 +85,7 @@ valyu.search(
81
85
  | `relevanceThreshold` | `number` | `0.5` | Minimum relevance score for results (0.0-1.0) |
82
86
  | `maxPrice` | `number` | `30` | Maximum price per thousand queries in CPM |
83
87
  | `includedSources` | `string[]` | `[]` | Specific data sources or URLs to search |
84
- | `excludeSources` | `string[]` | `[]` | List of URLs/domains to exclude from search results |
88
+ | `excludeSources` | `string[]` | `[]` | Data sources or URLs to exclude from search |
85
89
  | `category` | `string` | `null` | Category filter for results |
86
90
  | `startDate` | `string` | `null` | Start date filter in YYYY-MM-DD format |
87
91
  | `endDate` | `string` | `null` | End date filter in YYYY-MM-DD format |
@@ -126,6 +130,67 @@ Each `SearchResult` contains:
126
130
  }
127
131
  ```
128
132
 
133
+ ### Contents Method
134
+
135
+ The `contents()` method extracts clean, structured content from web pages with optional AI-powered data extraction and summarization. It accepts an array of URLs as the first parameter, followed by optional configuration parameters.
136
+
137
+ ```javascript
138
+ valyu.contents(
139
+ urls, // Array of URLs to process (max 10)
140
+ {
141
+ summary: false, // AI processing: false, true, string, or JSON schema
142
+ extractEffort: "normal", // Extraction effort: "normal" or "high"
143
+ responseLength: "short", // Content length control
144
+ maxPriceDollars: null // Maximum cost limit in USD
145
+ }
146
+ )
147
+ ```
148
+
149
+ ### Parameters
150
+
151
+ | Parameter | Type | Default | Description |
152
+ |-----------|------|---------|-------------|
153
+ | `urls` | `string[]` | *required* | Array of URLs to process (maximum 10 URLs per request) |
154
+ | `summary` | `boolean \| string \| object` | `false` | AI summary configuration: `false` (raw content), `true` (auto summary), string (custom instructions), or JSON schema (structured extraction) |
155
+ | `extractEffort` | `string` | `"normal"` | Extraction thoroughness: `"normal"` (fast) or `"high"` (more thorough but slower) |
156
+ | `responseLength` | `string \| number` | `"short"` | Content length per URL: `"short"` (25k chars), `"medium"` (50k), `"large"` (100k), `"max"` (no limit), or custom number |
157
+ | `maxPriceDollars` | `number` | `null` | Maximum cost limit in USD |
158
+
159
+ ### Contents Response Format
160
+
161
+ The contents method returns a `ContentsResponse` object with the following structure:
162
+
163
+ ```javascript
164
+ {
165
+ success: boolean, // Request success status
166
+ error: string | null, // Error message if any
167
+ tx_id: string, // Transaction ID for tracking
168
+ urls_requested: number, // Total URLs requested
169
+ urls_processed: number, // Successfully processed URLs
170
+ urls_failed: number, // Failed URL count
171
+ results: ContentResult[], // Array of processed results
172
+ total_cost_dollars: number, // Actual cost charged
173
+ total_characters: number // Total characters extracted
174
+ }
175
+ ```
176
+
177
+ Each `ContentResult` contains:
178
+
179
+ ```javascript
180
+ {
181
+ url: string, // Source URL
182
+ title: string, // Page/document title
183
+ content: string | number, // Extracted content
184
+ length: number, // Content length in characters
185
+ source: string, // Data source identifier
186
+ summary?: string | object, // AI-generated summary (if enabled)
187
+ summary_success?: boolean, // Whether summary generation succeeded
188
+ data_type?: string, // Type of data extracted
189
+ image_url?: Record<string, string>, // Extracted images
190
+ citation?: string // APA-style citation
191
+ }
192
+ ```
193
+
129
194
  ## Examples
130
195
 
131
196
  ### Basic Search
@@ -135,24 +200,22 @@ const { Valyu } = require('valyu');
135
200
 
136
201
  const valyu = new Valyu("your-api-key");
137
202
 
138
- // Simple search with no search parameters
139
- const response = await valyu.search("what is trans-applifying mRNA");
140
- console.log(response);
203
+ // Simple search across all sources
204
+ const response = await valyu.search("What is machine learning?");
205
+ console.log(`Found ${response.results.length} results`);
141
206
  ```
142
207
 
143
208
  ### Academic Research
144
209
 
145
210
  ```javascript
146
- // Deep search over academic papers
211
+ // Search academic papers on arXiv
147
212
  const response = await valyu.search(
148
- "implementation details of agentic search-enhanced large reasoning models",
213
+ "transformer architecture improvements",
149
214
  {
150
215
  searchType: "proprietary",
151
- maxNumResults: 10,
152
- relevanceThreshold: 0.6,
153
216
  includedSources: ["valyu/valyu-arxiv"],
154
- category: "agentic RAG",
155
- startDate: "2024-12-01"
217
+ relevanceThreshold: 0.7,
218
+ maxNumResults: 10
156
219
  }
157
220
  );
158
221
  ```
@@ -160,62 +223,29 @@ const response = await valyu.search(
160
223
  ### Web Search with Date Filtering
161
224
 
162
225
  ```javascript
163
- // Web search with date range
226
+ // Search recent web content
164
227
  const response = await valyu.search(
165
- "what are the grok 4 benchmark results",
228
+ "AI safety developments",
166
229
  {
167
230
  searchType: "web",
168
- maxNumResults: 7,
169
- relevanceThreshold: 0.5,
170
- startDate: "2025-06-01",
171
- endDate: "2025-07-25"
231
+ startDate: "2024-01-01",
232
+ endDate: "2024-12-31",
233
+ maxNumResults: 5
172
234
  }
173
235
  );
174
236
  ```
175
237
 
176
- ### Country-Specific Search
238
+ ### Hybrid Search
177
239
 
178
240
  ```javascript
179
- // Web search with country filtering
241
+ // Search both web and proprietary sources
180
242
  const response = await valyu.search(
181
- "what is the weather where i am?",
182
- {
183
- searchType: "web",
184
- maxNumResults: 2,
185
- countryCode: "UK",
186
- responseLength: "short"
187
- }
188
- );
189
- ```
190
-
191
- ### Search with Source Exclusion
192
-
193
- ```javascript
194
- // Hybrid search excluding specific sources
195
- const response = await valyu.search(
196
- "quantum computing applications in cryptography",
243
+ "quantum computing breakthroughs",
197
244
  {
198
245
  searchType: "all",
199
- maxNumResults: 8,
200
- relevanceThreshold: 0.5,
201
- maxPrice: 40,
202
- excludeSources: ["paperswithcode.com", "wikipedia.org"],
203
- responseLength: "large",
204
- isToolCall: true
205
- }
206
- );
207
- ```
208
-
209
- ### Custom Response Length
210
-
211
- ```javascript
212
- // Search with custom character count
213
- const response = await valyu.search(
214
- "State of video generation AI models",
215
- {
216
- maxNumResults: 10,
217
- category: "vLLMs",
218
- responseLength: 1000 // Limit to 1000 characters per result
246
+ category: "technology",
247
+ relevanceThreshold: 0.6,
248
+ maxPrice: 50
219
249
  }
220
250
  );
221
251
  ```
@@ -240,6 +270,94 @@ if (response.success) {
240
270
  }
241
271
  ```
242
272
 
273
+ ### Content Extraction Examples
274
+
275
+ #### Basic Content Extraction
276
+
277
+ ```javascript
278
+ // Extract raw content from URLs
279
+ const response = await valyu.contents(
280
+ ["https://techcrunch.com/2025/08/28/anthropic-users-face-a-new-choice-opt-out-or-share-your-data-for-ai-training/"]
281
+ );
282
+
283
+ if (response.success) {
284
+ response.results.forEach(result => {
285
+ console.log(`Title: ${result.title}`);
286
+ console.log(`Content: ${result.content.substring(0, 500)}...`);
287
+ });
288
+ }
289
+ ```
290
+
291
+ #### Content with AI Summary
292
+
293
+ ```javascript
294
+ // Extract content with automatic summarization
295
+ const response = await valyu.contents(
296
+ ["https://docs.python.org/3/tutorial/"],
297
+ {
298
+ summary: true,
299
+ responseLength: "max"
300
+ }
301
+ );
302
+
303
+ response.results.forEach(result => {
304
+ console.log(`Summary: ${result.summary}`);
305
+ });
306
+ ```
307
+
308
+ #### Structured Data Extraction
309
+
310
+ ```javascript
311
+ // Extract structured data using JSON schema
312
+ const companySchema = {
313
+ type: "object",
314
+ properties: {
315
+ company_name: { type: "string" },
316
+ founded_year: { type: "integer" },
317
+ key_products: {
318
+ type: "array",
319
+ items: { type: "string" },
320
+ maxItems: 3
321
+ }
322
+ }
323
+ };
324
+
325
+ const response = await valyu.contents(
326
+ ["https://en.wikipedia.org/wiki/OpenAI"],
327
+ {
328
+ summary: companySchema,
329
+ responseLength: "max"
330
+ }
331
+ );
332
+
333
+ if (response.success) {
334
+ response.results.forEach(result => {
335
+ if (result.summary) {
336
+ console.log(`Structured data: ${JSON.stringify(result.summary, null, 2)}`);
337
+ }
338
+ });
339
+ }
340
+ ```
341
+
342
+ #### Multiple URLs
343
+
344
+ ```javascript
345
+ // Process multiple URLs with a cost limit
346
+ const response = await valyu.contents(
347
+ [
348
+ "https://www.valyu.network/",
349
+ "https://docs.valyu.network/overview",
350
+ "https://www.valyu.network/blogs/why-ai-agents-and-llms-struggle-with-search-and-data-access"
351
+ ],
352
+ {
353
+ summary: "Provide key takeaways in bullet points, and write in very emphasised singaporean english"
354
+ }
355
+ );
356
+
357
+ console.log(`Processed ${response.urls_processed}/${response.urls_requested} URLs`);
358
+ console.log(`Cost: $${response.total_cost_dollars.toFixed(4)}`);
359
+ ```
360
+
243
361
  ## Authentication
244
362
 
245
363
  Set your API key in one of these ways:
@@ -277,11 +395,20 @@ if (!response.success) {
277
395
  The SDK includes full TypeScript support with type definitions for all parameters:
278
396
 
279
397
  ```typescript
280
- import { Valyu, SearchOptions, SearchResponse, CountryCode, ResponseLength } from 'valyu';
398
+ import {
399
+ Valyu,
400
+ SearchOptions,
401
+ SearchResponse,
402
+ ContentsOptions,
403
+ ContentsResponse,
404
+ CountryCode,
405
+ ResponseLength
406
+ } from 'valyu';
281
407
 
282
408
  const valyu = new Valyu("your-api-key");
283
409
 
284
- const options: SearchOptions = {
410
+ // Search API with types
411
+ const searchOptions: SearchOptions = {
285
412
  searchType: "proprietary",
286
413
  maxNumResults: 10,
287
414
  relevanceThreshold: 0.6,
@@ -290,7 +417,20 @@ const options: SearchOptions = {
290
417
  responseLength: "medium" as ResponseLength
291
418
  };
292
419
 
293
- const response: SearchResponse = await valyu.search("machine learning", options);
420
+ const searchResponse: SearchResponse = await valyu.search("machine learning", searchOptions);
421
+
422
+ // Contents API with types
423
+ const contentsOptions: ContentsOptions = {
424
+ summary: true,
425
+ extractEffort: "high",
426
+ responseLength: "medium",
427
+ maxPriceDollars: 0.10
428
+ };
429
+
430
+ const contentsResponse: ContentsResponse = await valyu.contents(
431
+ ["https://example.com"],
432
+ contentsOptions
433
+ );
294
434
  ```
295
435
 
296
436
  ## Backward Compatibility
@@ -321,7 +461,7 @@ const response = await valyu.context(
321
461
 
322
462
  ## Getting Started
323
463
 
324
- 1. Sign up for a free account at [Valyu](https://exchange.valyu.network)
464
+ 1. Sign up for a free account at [Valyu](https://platform.valyu.network)
325
465
  2. Get your API key from the dashboard
326
466
  3. Install the SDK: `npm install valyu`
327
467
  4. Start building with the examples above
@@ -334,10 +474,16 @@ Run the integration tests:
334
474
  npm run test:integration
335
475
  ```
336
476
 
337
- Run the v2 API examples:
477
+ Run the Search API examples:
478
+
479
+ ```bash
480
+ node examples/search-examples.js
481
+ ```
482
+
483
+ Run the Contents API examples:
338
484
 
339
485
  ```bash
340
- node examples/v2-api-examples.js
486
+ node examples/contents-examples.js
341
487
  ```
342
488
 
343
489
  ## Support
package/dist/index.d.mts CHANGED
@@ -46,6 +46,38 @@ interface FeedbackResponse {
46
46
  success: boolean;
47
47
  error?: string;
48
48
  }
49
+ type ExtractEffort = "normal" | "high";
50
+ type ContentResponseLength = "short" | "medium" | "large" | "max" | number;
51
+ interface ContentsOptions {
52
+ summary?: boolean | string | object;
53
+ extractEffort?: ExtractEffort;
54
+ responseLength?: ContentResponseLength;
55
+ maxPriceDollars?: number;
56
+ }
57
+ interface ContentResult {
58
+ url: string;
59
+ title: string;
60
+ content: string | number;
61
+ length: number;
62
+ source: string;
63
+ summary?: string | object;
64
+ summary_success?: boolean;
65
+ data_type?: string;
66
+ image_url?: Record<string, string>;
67
+ citation?: string;
68
+ }
69
+ interface ContentsResponse {
70
+ success: boolean;
71
+ error?: string | null;
72
+ tx_id?: string;
73
+ urls_requested?: number;
74
+ urls_processed?: number;
75
+ urls_failed?: number;
76
+ results?: ContentResult[];
77
+ total_cost_dollars?: number;
78
+ total_characters?: number;
79
+ isProvisioning?: boolean;
80
+ }
49
81
 
50
82
  declare class Valyu {
51
83
  private baseUrl;
@@ -74,6 +106,17 @@ declare class Valyu {
74
106
  * @returns Promise resolving to search results
75
107
  */
76
108
  search(query: string, options?: SearchOptions): Promise<SearchResponse>;
109
+ /**
110
+ * Extract content from URLs with optional AI processing
111
+ * @param urls - Array of URLs to process (max 10)
112
+ * @param options - Content extraction configuration options
113
+ * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema
114
+ * @param options.extractEffort - Extraction thoroughness: "normal" or "high"
115
+ * @param options.responseLength - Content length per URL
116
+ * @param options.maxPriceDollars - Maximum cost limit in USD
117
+ * @returns Promise resolving to content extraction results
118
+ */
119
+ contents(urls: string[], options?: ContentsOptions): Promise<ContentsResponse>;
77
120
  }
78
121
 
79
- export { type CountryCode, type FeedbackResponse, type FeedbackSentiment, type ResponseLength, type SearchOptions, type SearchResponse, type SearchType, Valyu };
122
+ export { type ContentResponseLength, type ContentResult, type ContentsOptions, type ContentsResponse, type CountryCode, type ExtractEffort, type FeedbackResponse, type FeedbackSentiment, type ResponseLength, type SearchOptions, type SearchResponse, type SearchType, Valyu };
package/dist/index.d.ts CHANGED
@@ -46,6 +46,38 @@ interface FeedbackResponse {
46
46
  success: boolean;
47
47
  error?: string;
48
48
  }
49
+ type ExtractEffort = "normal" | "high";
50
+ type ContentResponseLength = "short" | "medium" | "large" | "max" | number;
51
+ interface ContentsOptions {
52
+ summary?: boolean | string | object;
53
+ extractEffort?: ExtractEffort;
54
+ responseLength?: ContentResponseLength;
55
+ maxPriceDollars?: number;
56
+ }
57
+ interface ContentResult {
58
+ url: string;
59
+ title: string;
60
+ content: string | number;
61
+ length: number;
62
+ source: string;
63
+ summary?: string | object;
64
+ summary_success?: boolean;
65
+ data_type?: string;
66
+ image_url?: Record<string, string>;
67
+ citation?: string;
68
+ }
69
+ interface ContentsResponse {
70
+ success: boolean;
71
+ error?: string | null;
72
+ tx_id?: string;
73
+ urls_requested?: number;
74
+ urls_processed?: number;
75
+ urls_failed?: number;
76
+ results?: ContentResult[];
77
+ total_cost_dollars?: number;
78
+ total_characters?: number;
79
+ isProvisioning?: boolean;
80
+ }
49
81
 
50
82
  declare class Valyu {
51
83
  private baseUrl;
@@ -74,6 +106,17 @@ declare class Valyu {
74
106
  * @returns Promise resolving to search results
75
107
  */
76
108
  search(query: string, options?: SearchOptions): Promise<SearchResponse>;
109
+ /**
110
+ * Extract content from URLs with optional AI processing
111
+ * @param urls - Array of URLs to process (max 10)
112
+ * @param options - Content extraction configuration options
113
+ * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema
114
+ * @param options.extractEffort - Extraction thoroughness: "normal" or "high"
115
+ * @param options.responseLength - Content length per URL
116
+ * @param options.maxPriceDollars - Maximum cost limit in USD
117
+ * @returns Promise resolving to content extraction results
118
+ */
119
+ contents(urls: string[], options?: ContentsOptions): Promise<ContentsResponse>;
77
120
  }
78
121
 
79
- export { type CountryCode, type FeedbackResponse, type FeedbackSentiment, type ResponseLength, type SearchOptions, type SearchResponse, type SearchType, Valyu };
122
+ export { type ContentResponseLength, type ContentResult, type ContentsOptions, type ContentsResponse, type CountryCode, type ExtractEffort, type FeedbackResponse, type FeedbackSentiment, type ResponseLength, type SearchOptions, type SearchResponse, type SearchType, Valyu };
package/dist/index.js CHANGED
@@ -203,6 +203,139 @@ var Valyu = class {
203
203
  };
204
204
  }
205
205
  }
206
+ /**
207
+ * Extract content from URLs with optional AI processing
208
+ * @param urls - Array of URLs to process (max 10)
209
+ * @param options - Content extraction configuration options
210
+ * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema
211
+ * @param options.extractEffort - Extraction thoroughness: "normal" or "high"
212
+ * @param options.responseLength - Content length per URL
213
+ * @param options.maxPriceDollars - Maximum cost limit in USD
214
+ * @returns Promise resolving to content extraction results
215
+ */
216
+ async contents(urls, options = {}) {
217
+ try {
218
+ if (!urls || !Array.isArray(urls)) {
219
+ return {
220
+ success: false,
221
+ error: "urls must be an array",
222
+ urls_requested: 0,
223
+ urls_processed: 0,
224
+ urls_failed: 0,
225
+ results: [],
226
+ total_cost_dollars: 0,
227
+ total_characters: 0
228
+ };
229
+ }
230
+ if (urls.length === 0) {
231
+ return {
232
+ success: false,
233
+ error: "urls array cannot be empty",
234
+ urls_requested: 0,
235
+ urls_processed: 0,
236
+ urls_failed: 0,
237
+ results: [],
238
+ total_cost_dollars: 0,
239
+ total_characters: 0
240
+ };
241
+ }
242
+ if (urls.length > 10) {
243
+ return {
244
+ success: false,
245
+ error: "Maximum 10 URLs allowed per request",
246
+ urls_requested: urls.length,
247
+ urls_processed: 0,
248
+ urls_failed: urls.length,
249
+ results: [],
250
+ total_cost_dollars: 0,
251
+ total_characters: 0
252
+ };
253
+ }
254
+ if (options.extractEffort && !["normal", "high"].includes(options.extractEffort)) {
255
+ return {
256
+ success: false,
257
+ error: "extractEffort must be 'normal' or 'high'",
258
+ urls_requested: urls.length,
259
+ urls_processed: 0,
260
+ urls_failed: urls.length,
261
+ results: [],
262
+ total_cost_dollars: 0,
263
+ total_characters: 0
264
+ };
265
+ }
266
+ if (options.responseLength !== void 0) {
267
+ const validLengths = ["short", "medium", "large", "max"];
268
+ if (typeof options.responseLength === "string" && !validLengths.includes(options.responseLength)) {
269
+ return {
270
+ success: false,
271
+ error: "responseLength must be 'short', 'medium', 'large', 'max', or a number",
272
+ urls_requested: urls.length,
273
+ urls_processed: 0,
274
+ urls_failed: urls.length,
275
+ results: [],
276
+ total_cost_dollars: 0,
277
+ total_characters: 0
278
+ };
279
+ }
280
+ if (typeof options.responseLength === "number" && options.responseLength <= 0) {
281
+ return {
282
+ success: false,
283
+ error: "responseLength number must be positive",
284
+ urls_requested: urls.length,
285
+ urls_processed: 0,
286
+ urls_failed: urls.length,
287
+ results: [],
288
+ total_cost_dollars: 0,
289
+ total_characters: 0
290
+ };
291
+ }
292
+ }
293
+ const payload = {
294
+ urls
295
+ };
296
+ if (options.summary !== void 0) {
297
+ payload.summary = options.summary;
298
+ }
299
+ if (options.extractEffort !== void 0) {
300
+ payload.extract_effort = options.extractEffort;
301
+ }
302
+ if (options.responseLength !== void 0) {
303
+ payload.response_length = options.responseLength;
304
+ }
305
+ if (options.maxPriceDollars !== void 0) {
306
+ payload.max_price_dollars = options.maxPriceDollars;
307
+ }
308
+ const response = await import_axios.default.post(
309
+ `${this.baseUrl}/contents`,
310
+ payload,
311
+ { headers: this.headers }
312
+ );
313
+ if (!response.status || response.status < 200 || response.status >= 300) {
314
+ return {
315
+ success: false,
316
+ error: response.data?.error || "Request failed",
317
+ urls_requested: urls.length,
318
+ urls_processed: 0,
319
+ urls_failed: urls.length,
320
+ results: [],
321
+ total_cost_dollars: 0,
322
+ total_characters: 0
323
+ };
324
+ }
325
+ return response.data;
326
+ } catch (e) {
327
+ return {
328
+ success: false,
329
+ error: e.response?.data?.error || e.message,
330
+ urls_requested: urls.length,
331
+ urls_processed: 0,
332
+ urls_failed: urls.length,
333
+ results: [],
334
+ total_cost_dollars: 0,
335
+ total_characters: 0
336
+ };
337
+ }
338
+ }
206
339
  };
207
340
  // Annotate the CommonJS export names for ESM import in node:
208
341
  0 && (module.exports = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { SearchResponse, SearchType, SearchOptions } from './types';\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(apiKey?: string, baseUrl: string = \"https://api.valyu.network/v1\") {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @returns Promise resolving to search results\n */\n async search(query: string, options: SearchOptions = {}): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (providedSearchTypeString === \"web\" || providedSearchTypeString === \"proprietary\" || providedSearchTypeString === \"all\") {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error: \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold: options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n const response = await axios.post(\n `${this.baseUrl}/deepsearch`,\n payload,\n { headers: this.headers }\n );\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n }\n}\n\nexport type { \n SearchResponse, \n SearchType, \n FeedbackSentiment, \n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength\n} from './types'; "],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGX,IAAM,QAAN,MAAY;AAAA,EAIjB,YAAY,QAAiB,UAAkB,gCAAgC;AAC7E,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,aAAO;AAAA,IACT;AACA,UAAM,aAAa,IAAI,KAAK,IAAI;AAChC,WAAO,sBAAsB,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA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AAAA,UACV,mBAAmB,EAAE,KAAK,GAAG,aAAa,EAAE;AAAA,UAC5C,qBAAqB;AAAA,UACrB,yBAAyB;AAAA,UACzB,kBAAkB;AAAA,QACpB;AAAA,MACF;AAEA,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,QACpC,OAAO;AAAA,QACP;AAAA,QACA,SAAS,CAAC;AAAA,QACV,mBAAmB,EAAE,KAAK,GAAG,aAAa,EAAE;AAAA,QAC5C,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,kBAAkB;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { SearchResponse, SearchType, SearchOptions, ContentsOptions, ContentsResponse } from './types';\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(apiKey?: string, baseUrl: string = \"https://api.valyu.network/v1\") {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @returns Promise resolving to search results\n */\n async search(query: string, options: SearchOptions = {}): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (providedSearchTypeString === \"web\" || providedSearchTypeString === \"proprietary\" || providedSearchTypeString === \"all\") {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error: \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold: options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n const response = await axios.post(\n `${this.baseUrl}/deepsearch`,\n payload,\n { headers: this.headers }\n );\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n }\n\n /**\n * Extract content from URLs with optional AI processing\n * @param urls - Array of URLs to process (max 10)\n * @param options - Content extraction configuration options\n * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema\n * @param options.extractEffort - Extraction thoroughness: \"normal\" or \"high\"\n * @param options.responseLength - Content length per URL\n * @param options.maxPriceDollars - Maximum cost limit in USD\n * @returns Promise resolving to content extraction results\n */\n async contents(urls: string[], options: ContentsOptions = {}): Promise<ContentsResponse> {\n try {\n // Validate URLs array\n if (!urls || !Array.isArray(urls)) {\n return {\n success: false,\n error: \"urls must be an array\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n if (urls.length === 0) {\n return {\n success: false,\n error: \"urls array cannot be empty\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n if (urls.length > 10) {\n return {\n success: false,\n error: \"Maximum 10 URLs allowed per request\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n // Validate extractEffort if provided\n if (options.extractEffort && ![\"normal\", \"high\"].includes(options.extractEffort)) {\n return {\n success: false,\n error: \"extractEffort must be 'normal' or 'high'\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n // Validate responseLength if provided\n if (options.responseLength !== undefined) {\n const validLengths = [\"short\", \"medium\", \"large\", \"max\"];\n if (typeof options.responseLength === \"string\" && !validLengths.includes(options.responseLength)) {\n return {\n success: false,\n error: \"responseLength must be 'short', 'medium', 'large', 'max', or a number\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n if (typeof options.responseLength === \"number\" && options.responseLength <= 0) {\n return {\n success: false,\n error: \"responseLength number must be positive\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n urls\n };\n\n // Add optional parameters only if provided\n if (options.summary !== undefined) {\n payload.summary = options.summary;\n }\n\n if (options.extractEffort !== undefined) {\n payload.extract_effort = options.extractEffort;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.maxPriceDollars !== undefined) {\n payload.max_price_dollars = options.maxPriceDollars;\n }\n\n const response = await axios.post(\n `${this.baseUrl}/contents`,\n payload,\n { headers: this.headers }\n );\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n }\n}\n\nexport type { \n SearchResponse, \n SearchType, \n FeedbackSentiment, \n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength,\n ContentsOptions,\n ContentsResponse,\n ContentResult,\n ExtractEffort,\n ContentResponseLength\n} from './types'; "],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGX,IAAM,QAAN,MAAY;AAAA,EAIjB,YAAY,QAAiB,UAAkB,gCAAgC;AAC7E,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI,G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B;AAAA,QACnC;AAAA,MACF;AAGA,UAAI,QAAQ,YAAY,QAAW;AACjC,gBAAQ,UAAU,QAAQ;AAAA,MAC5B;AAEA,UAAI,QAAQ,kBAAkB,QAAW;AACvC,gBAAQ,iBAAiB,QAAQ;AAAA,MACnC;AAEA,UAAI,QAAQ,mBAAmB,QAAW;AACxC,gBAAQ,kBAAkB,QAAQ;AAAA,MACpC;AAEA,UAAI,QAAQ,oBAAoB,QAAW;AACzC,gBAAQ,oBAAoB,QAAQ;AAAA,MACtC;AAEA,YAAM,WAAW,MAAM,aAAAA,QAAM;AAAA,QAC3B,GAAG,KAAK,OAAO;AAAA,QACf;AAAA,QACA,EAAE,SAAS,KAAK,QAAQ;AAAA,MAC1B;AAEA,UAAI,CAAC,SAAS,UAAU,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACvE,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,SAAS,MAAM,SAAS;AAAA,UAC/B,gBAAgB,KAAK;AAAA,UACrB,gBAAgB;AAAA,UAChB,aAAa,KAAK;AAAA,UAClB,SAAS,CAAC;AAAA,UACV,oBAAoB;AAAA,UACpB,kBAAkB;AAAA,QACpB;AAAA,MACF;AAEA,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,QACpC,gBAAgB,KAAK;AAAA,QACrB,gBAAgB;AAAA,QAChB,aAAa,KAAK;AAAA,QAClB,SAAS,CAAC;AAAA,QACV,oBAAoB;AAAA,QACpB,kBAAkB;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
package/dist/index.mjs CHANGED
@@ -169,6 +169,139 @@ var Valyu = class {
169
169
  };
170
170
  }
171
171
  }
172
+ /**
173
+ * Extract content from URLs with optional AI processing
174
+ * @param urls - Array of URLs to process (max 10)
175
+ * @param options - Content extraction configuration options
176
+ * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema
177
+ * @param options.extractEffort - Extraction thoroughness: "normal" or "high"
178
+ * @param options.responseLength - Content length per URL
179
+ * @param options.maxPriceDollars - Maximum cost limit in USD
180
+ * @returns Promise resolving to content extraction results
181
+ */
182
+ async contents(urls, options = {}) {
183
+ try {
184
+ if (!urls || !Array.isArray(urls)) {
185
+ return {
186
+ success: false,
187
+ error: "urls must be an array",
188
+ urls_requested: 0,
189
+ urls_processed: 0,
190
+ urls_failed: 0,
191
+ results: [],
192
+ total_cost_dollars: 0,
193
+ total_characters: 0
194
+ };
195
+ }
196
+ if (urls.length === 0) {
197
+ return {
198
+ success: false,
199
+ error: "urls array cannot be empty",
200
+ urls_requested: 0,
201
+ urls_processed: 0,
202
+ urls_failed: 0,
203
+ results: [],
204
+ total_cost_dollars: 0,
205
+ total_characters: 0
206
+ };
207
+ }
208
+ if (urls.length > 10) {
209
+ return {
210
+ success: false,
211
+ error: "Maximum 10 URLs allowed per request",
212
+ urls_requested: urls.length,
213
+ urls_processed: 0,
214
+ urls_failed: urls.length,
215
+ results: [],
216
+ total_cost_dollars: 0,
217
+ total_characters: 0
218
+ };
219
+ }
220
+ if (options.extractEffort && !["normal", "high"].includes(options.extractEffort)) {
221
+ return {
222
+ success: false,
223
+ error: "extractEffort must be 'normal' or 'high'",
224
+ urls_requested: urls.length,
225
+ urls_processed: 0,
226
+ urls_failed: urls.length,
227
+ results: [],
228
+ total_cost_dollars: 0,
229
+ total_characters: 0
230
+ };
231
+ }
232
+ if (options.responseLength !== void 0) {
233
+ const validLengths = ["short", "medium", "large", "max"];
234
+ if (typeof options.responseLength === "string" && !validLengths.includes(options.responseLength)) {
235
+ return {
236
+ success: false,
237
+ error: "responseLength must be 'short', 'medium', 'large', 'max', or a number",
238
+ urls_requested: urls.length,
239
+ urls_processed: 0,
240
+ urls_failed: urls.length,
241
+ results: [],
242
+ total_cost_dollars: 0,
243
+ total_characters: 0
244
+ };
245
+ }
246
+ if (typeof options.responseLength === "number" && options.responseLength <= 0) {
247
+ return {
248
+ success: false,
249
+ error: "responseLength number must be positive",
250
+ urls_requested: urls.length,
251
+ urls_processed: 0,
252
+ urls_failed: urls.length,
253
+ results: [],
254
+ total_cost_dollars: 0,
255
+ total_characters: 0
256
+ };
257
+ }
258
+ }
259
+ const payload = {
260
+ urls
261
+ };
262
+ if (options.summary !== void 0) {
263
+ payload.summary = options.summary;
264
+ }
265
+ if (options.extractEffort !== void 0) {
266
+ payload.extract_effort = options.extractEffort;
267
+ }
268
+ if (options.responseLength !== void 0) {
269
+ payload.response_length = options.responseLength;
270
+ }
271
+ if (options.maxPriceDollars !== void 0) {
272
+ payload.max_price_dollars = options.maxPriceDollars;
273
+ }
274
+ const response = await axios.post(
275
+ `${this.baseUrl}/contents`,
276
+ payload,
277
+ { headers: this.headers }
278
+ );
279
+ if (!response.status || response.status < 200 || response.status >= 300) {
280
+ return {
281
+ success: false,
282
+ error: response.data?.error || "Request failed",
283
+ urls_requested: urls.length,
284
+ urls_processed: 0,
285
+ urls_failed: urls.length,
286
+ results: [],
287
+ total_cost_dollars: 0,
288
+ total_characters: 0
289
+ };
290
+ }
291
+ return response.data;
292
+ } catch (e) {
293
+ return {
294
+ success: false,
295
+ error: e.response?.data?.error || e.message,
296
+ urls_requested: urls.length,
297
+ urls_processed: 0,
298
+ urls_failed: urls.length,
299
+ results: [],
300
+ total_cost_dollars: 0,
301
+ total_characters: 0
302
+ };
303
+ }
304
+ }
172
305
  };
173
306
  export {
174
307
  Valyu
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { SearchResponse, SearchType, SearchOptions } from './types';\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(apiKey?: string, baseUrl: string = \"https://api.valyu.network/v1\") {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @returns Promise resolving to search results\n */\n async search(query: string, options: SearchOptions = {}): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (providedSearchTypeString === \"web\" || providedSearchTypeString === \"proprietary\" || providedSearchTypeString === \"all\") {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error: \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold: options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n const response = await axios.post(\n `${this.baseUrl}/deepsearch`,\n payload,\n { headers: this.headers }\n );\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n }\n}\n\nexport type { \n SearchResponse, \n SearchType, \n FeedbackSentiment, \n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength\n} from './types'; "],"mappings":";AAAA,OAAO,WAAW;AAGX,IAAM,QAAN,MAAY;AAAA,EAIjB,YAAY,QAAiB,UAAkB,gCAAgC;AAC7E,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,aAAO;AAAA,IACT;AACA,UAAM,aAAa,IAAI,KAAK,IAAI;AAChC,WAAO,sBAAsB,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,MAAM,OAAO,OAAe,UAAyB,CAAC,GAA4B;AAChF,QAAI;AAEF,YAAM,oBAAgC;AACtC,YAAM,uBAAuB;AAC7B,YAAM,oBAAoB;AAC1B,YAAM,4BAA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,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,QACpC,OAAO;AAAA,QACP;AAAA,QACA,SAAS,CAAC;AAAA,QACV,mBAAmB,EAAE,KAAK,GAAG,aAAa,EAAE;AAAA,QAC5C,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,kBAAkB;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { SearchResponse, SearchType, SearchOptions, ContentsOptions, ContentsResponse } from './types';\n\nexport class Valyu {\n private baseUrl: string;\n private headers: Record<string, string>;\n\n constructor(apiKey?: string, baseUrl: string = \"https://api.valyu.network/v1\") {\n if (!apiKey) {\n apiKey = process.env.VALYU_API_KEY;\n if (!apiKey) {\n throw new Error(\"VALYU_API_KEY is not set\");\n }\n }\n this.baseUrl = baseUrl;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey\n };\n }\n\n /**\n * Validates date format (YYYY-MM-DD)\n */\n private validateDateFormat(date: string): boolean {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n if (!dateRegex.test(date)) {\n return false;\n }\n const parsedDate = new Date(date);\n return parsedDate instanceof Date && !isNaN(parsedDate.getTime());\n }\n\n /**\n * Search for information using the Valyu DeepSearch API\n * @param query - The search query string\n * @param options - Search configuration options\n * @param options.searchType - Type of search: \"web\", \"proprietary\", or \"all\"\n * @param options.maxNumResults - Maximum number of results (1-20)\n * @param options.maxPrice - Maximum price per thousand characters (CPM)\n * @param options.isToolCall - Whether this is a tool call\n * @param options.relevanceThreshold - Minimum relevance score (0-1)\n * @param options.includedSources - List of specific sources to include\n * @param options.excludeSources - List of URLs/domains to exclude from search results\n * @param options.category - Category filter for search results\n * @param options.startDate - Start date filter (YYYY-MM-DD format)\n * @param options.endDate - End date filter (YYYY-MM-DD format)\n * @param options.countryCode - Country code filter for search results\n * @param options.responseLength - Response content length: \"short\"/\"medium\"/\"large\"/\"max\" or integer character count\n * @returns Promise resolving to search results\n */\n async search(query: string, options: SearchOptions = {}): Promise<SearchResponse> {\n try {\n // Default values\n const defaultSearchType: SearchType = \"all\";\n const defaultMaxNumResults = 10;\n const defaultIsToolCall = true;\n const defaultRelevanceThreshold = 0.5;\n const defaultMaxPrice = 30;\n\n // Validate searchType\n let finalSearchType: SearchType = defaultSearchType;\n const providedSearchTypeString = options.searchType?.toLowerCase();\n\n if (providedSearchTypeString === \"web\" || providedSearchTypeString === \"proprietary\" || providedSearchTypeString === \"all\") {\n finalSearchType = providedSearchTypeString as SearchType;\n } else if (options.searchType !== undefined) {\n return {\n success: false,\n error: \"Invalid searchType provided. Must be one of: all, web, proprietary\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate date formats\n if (options.startDate && !this.validateDateFormat(options.startDate)) {\n return {\n success: false,\n error: \"Invalid startDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n if (options.endDate && !this.validateDateFormat(options.endDate)) {\n return {\n success: false,\n error: \"Invalid endDate format. Must be YYYY-MM-DD\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Validate maxNumResults range\n const maxNumResults = options.maxNumResults ?? defaultMaxNumResults;\n if (maxNumResults < 1 || maxNumResults > 20) {\n return {\n success: false,\n error: \"maxNumResults must be between 1 and 20\",\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n query,\n search_type: finalSearchType,\n max_num_results: maxNumResults,\n is_tool_call: options.isToolCall ?? defaultIsToolCall,\n relevance_threshold: options.relevanceThreshold ?? defaultRelevanceThreshold,\n max_price: options.maxPrice ?? defaultMaxPrice,\n };\n\n // Add optional parameters only if provided\n if (options.includedSources !== undefined) {\n payload.included_sources = options.includedSources;\n }\n\n if (options.excludeSources !== undefined) {\n payload.exclude_sources = options.excludeSources;\n }\n\n if (options.category !== undefined) {\n payload.category = options.category;\n }\n\n if (options.startDate !== undefined) {\n payload.start_date = options.startDate;\n }\n\n if (options.endDate !== undefined) {\n payload.end_date = options.endDate;\n }\n\n if (options.countryCode !== undefined) {\n payload.country_code = options.countryCode;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n const response = await axios.post(\n `${this.baseUrl}/deepsearch`,\n payload,\n { headers: this.headers }\n );\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n tx_id: null,\n query,\n results: [],\n results_by_source: { web: 0, proprietary: 0 },\n total_deduction_pcm: 0.0,\n total_deduction_dollars: 0.0,\n total_characters: 0\n };\n }\n }\n\n /**\n * Extract content from URLs with optional AI processing\n * @param urls - Array of URLs to process (max 10)\n * @param options - Content extraction configuration options\n * @param options.summary - AI summary configuration: false (raw), true (auto), string (custom), or JSON schema\n * @param options.extractEffort - Extraction thoroughness: \"normal\" or \"high\"\n * @param options.responseLength - Content length per URL\n * @param options.maxPriceDollars - Maximum cost limit in USD\n * @returns Promise resolving to content extraction results\n */\n async contents(urls: string[], options: ContentsOptions = {}): Promise<ContentsResponse> {\n try {\n // Validate URLs array\n if (!urls || !Array.isArray(urls)) {\n return {\n success: false,\n error: \"urls must be an array\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n if (urls.length === 0) {\n return {\n success: false,\n error: \"urls array cannot be empty\",\n urls_requested: 0,\n urls_processed: 0,\n urls_failed: 0,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n if (urls.length > 10) {\n return {\n success: false,\n error: \"Maximum 10 URLs allowed per request\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n // Validate extractEffort if provided\n if (options.extractEffort && ![\"normal\", \"high\"].includes(options.extractEffort)) {\n return {\n success: false,\n error: \"extractEffort must be 'normal' or 'high'\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n // Validate responseLength if provided\n if (options.responseLength !== undefined) {\n const validLengths = [\"short\", \"medium\", \"large\", \"max\"];\n if (typeof options.responseLength === \"string\" && !validLengths.includes(options.responseLength)) {\n return {\n success: false,\n error: \"responseLength must be 'short', 'medium', 'large', 'max', or a number\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n if (typeof options.responseLength === \"number\" && options.responseLength <= 0) {\n return {\n success: false,\n error: \"responseLength number must be positive\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n }\n\n // Build payload with snake_case for API\n const payload: Record<string, any> = {\n urls\n };\n\n // Add optional parameters only if provided\n if (options.summary !== undefined) {\n payload.summary = options.summary;\n }\n\n if (options.extractEffort !== undefined) {\n payload.extract_effort = options.extractEffort;\n }\n\n if (options.responseLength !== undefined) {\n payload.response_length = options.responseLength;\n }\n\n if (options.maxPriceDollars !== undefined) {\n payload.max_price_dollars = options.maxPriceDollars;\n }\n\n const response = await axios.post(\n `${this.baseUrl}/contents`,\n payload,\n { headers: this.headers }\n );\n\n if (!response.status || response.status < 200 || response.status >= 300) {\n return {\n success: false,\n error: response.data?.error || \"Request failed\",\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n\n return response.data;\n } catch (e: any) {\n return {\n success: false,\n error: e.response?.data?.error || e.message,\n urls_requested: urls.length,\n urls_processed: 0,\n urls_failed: urls.length,\n results: [],\n total_cost_dollars: 0,\n total_characters: 0\n };\n }\n }\n}\n\nexport type { \n SearchResponse, \n SearchType, \n FeedbackSentiment, \n FeedbackResponse,\n SearchOptions,\n CountryCode,\n ResponseLength,\n ContentsOptions,\n ContentsResponse,\n ContentResult,\n ExtractEffort,\n ContentResponseLength\n} from './types'; "],"mappings":";AAAA,OAAO,WAAW;AAGX,IAAM,QAAN,MAAY;AAAA,EAIjB,YAAY,QAAiB,UAAkB,gCAAgC;AAC7E,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,MACb,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,MAAuB;AAChD,UAAM,YAAY;AAClB,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,aAAO;AAAA,IACT;AACA,UAAM,aAAa,IAAI,KAAK,IAAI;AAChC,WAAO,sBAAsB,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,gBAAQ,kBAAkB,QAAQ;AAAA,MACpC;AAEA,UAAI,QAAQ,oBAAoB,QAAW;AACzC,gBAAQ,oBAAoB,QAAQ;AAAA,MACtC;AAEA,YAAM,WAAW,MAAM,MAAM;AAAA,QAC3B,GAAG,KAAK,OAAO;AAAA,QACf;AAAA,QACA,EAAE,SAAS,KAAK,QAAQ;AAAA,MAC1B;AAEA,UAAI,CAAC,SAAS,UAAU,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACvE,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,SAAS,MAAM,SAAS;AAAA,UAC/B,gBAAgB,KAAK;AAAA,UACrB,gBAAgB;AAAA,UAChB,aAAa,KAAK;AAAA,UAClB,SAAS,CAAC;AAAA,UACV,oBAAoB;AAAA,UACpB,kBAAkB;AAAA,QACpB;AAAA,MACF;AAEA,aAAO,SAAS;AAAA,IAClB,SAAS,GAAQ;AACf,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,EAAE,UAAU,MAAM,SAAS,EAAE;AAAA,QACpC,gBAAgB,KAAK;AAAA,QACrB,gBAAgB;AAAA,QAChB,aAAa,KAAK;AAAA,QAClB,SAAS,CAAC;AAAA,QACV,oBAAoB;AAAA,QACpB,kBAAkB;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valyu-js",
3
- "version": "2.0.2",
4
- "description": "DeepSearch API for AI.",
3
+ "version": "2.1.0",
4
+ "description": "Search for AIs - DeepSearch and Content API.",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
@@ -31,7 +31,10 @@
31
31
  "ai",
32
32
  "sdk",
33
33
  "rag",
34
- "valyu"
34
+ "valyu",
35
+ "search",
36
+ "content-extraction",
37
+ "deepsearch"
35
38
  ],
36
39
  "author": "Valyu",
37
40
  "license": "MIT",