Skip to main content
The Valyu TypeScript SDK provides comprehensive access to all Valyu APIs, enabling you to build powerful AI applications with search, content extraction, and answer generation capabilities.

Features

The SDK includes three core APIs:
  • Search API - Advanced search across web and proprietary data sources
  • Contents API - Extract and process content from URLs with AI
  • Answer API - AI-powered answer generation with search integration

Installation

Install the Valyu TypeScript SDK using your preferred package manager:
npm install valyu-js

Authentication

Get your API key from Valyu Platform (free $10 credits included). Set up authentication in one of two ways:
export VALYU_API_KEY="your-api-key-here"
import { Valyu } from "valyu-js";

// Automatically uses VALYU_API_KEY from environment
const valyu = new Valyu();

Direct API Key

import { Valyu } from "valyu-js";

const valyu = new Valyu("your-api-key-here");

Quick Start

Here’s a simple example to get you started with search:
import { Valyu } from "valyu-js";

const valyu = new Valyu();

// Basic search example
const searchResponse = await valyu.search(
  "What are the latest developments in quantum computing?"
);

console.log(`Found ${searchResponse.results.length} results`);
searchResponse.results.forEach(result => {
  console.log(`Title: ${result.title}`);
  console.log(`URL: ${result.url}`);
  console.log(`Content preview: ${result.content.substring(0, 200)}...`);
});

Error Handling

The SDK includes built-in error handling and validation:
const response = await valyu.search("test query");

if (!response.success) {
  console.error("Search failed:", response.error);
  return;
}

// Process successful results
response.results.forEach(result => {
  // Handle each result
});

Next Steps

Explore the detailed documentation for each API:

Support

I