### Automatic API Key Setup Source: https://docs.valyu.ai/integrations/claude-code-plugin Example interaction flow for automatic API key setup. Claude prompts for the key on first use and saves it. ```text You: Valyu(web, "AI news 2025") Claude: "To use Valyu search, I need your API key. Get one free at https://platform.valyu.ai" You: val_abc123... Claude: [saves key and runs search] ``` -------------------------------- ### Deploy AgentCore Runtime with Bash Source: https://docs.valyu.ai/integrations/aws-agentcore These bash commands guide you through deploying and launching the AgentCore Runtime. Navigate to the examples directory, configure the agent non-interactively, launch it, and then invoke it with a JSON payload. ```bash cd examples/runtime agentcore configure --entrypoint agent.py --non-interactive --name valyuagent agentcore launch agentcore invoke '{"prompt": "What is NVIDIA stock price?"}' ``` -------------------------------- ### Install Valyu SDK Source: https://docs.valyu.ai/compare/tavily-alternative Install the Valyu Python SDK using pip. This is the first step to migrate from Tavily or start using Valyu's enhanced search capabilities. ```bash pip install valyu ``` -------------------------------- ### Install Valyu Rust SDK Source: https://docs.valyu.ai/sdk/rust-sdk Add the Valyu crate and tokio to your Cargo.toml to get started. ```APIDOC ## Install ```toml [dependencies] valyu = "0.3" tokio = { version = "1", features = ["full"] } ``` ``` -------------------------------- ### Running a Batch of DeepResearch Tasks Source: https://docs.valyu.ai/sdk/typescript-sdk/deepresearch-batch This example demonstrates how to install the SDK, authenticate, create a batch, add tasks, and wait for their completion. It highlights shared configurations like mode and output format. ```APIDOC ## Running a Batch of DeepResearch Tasks ### Description This example demonstrates how to install the SDK, authenticate, create a batch, add tasks, and wait for their completion. It highlights shared configurations like mode and output format. ### Setup * **Install**: `npm install valyu-js` * **Authentication**: Set the `VALYU_API_KEY` environment variable or pass `new Valyu("your-api-key")`. The SDK calls `https://api.valyu.ai/v1/deepresearch/batches` with the `x-api-key` header. ### Code Example ```typescript import { Valyu } from "valyu-js"; const valyu = new Valyu(); const batch = await valyu.batch.create({ name: "Competitor scan", mode: "fast", // fast (~$0.10/task) is optimised for batch; also standard/heavy/max }); await valyu.batch.addTasks(batch.batch_id, { tasks: [ { query: "Analyse competitor A" }, { query: "Analyse competitor B" }, ], }); const result = await valyu.batch.waitForCompletion(batch.batch_id); console.log(`Completed: ${result.counts.completed} tasks`); ``` ### Modes and Pricing * **Modes**: `fast` (~$0.10/task), `standard` (~$0.50/task), `heavy` (~$2.50/task), `max` (~$15/task). All modes share credits. * **Tasks per request**: Up to 100. ### Limitations * Batch tasks do NOT support `files`, `deliverables`, `mcpServers`, `previousReports`, or HITL checkpoints. Use `valyu.deepresearch.create()` for individual tasks requiring these features. ### Configuration * **Batch-level**: `mode`, `outputFormats`, `search`. * **Task-level overrides**: `researchStrategy`, `reportFormat`, `urls`, `metadata`. ### Best Practices * Prefer `webhookUrl` over polling for large batches. * Premium sources (SEC, patents, drug discovery, genomics) require a subscription and lower the cost per credit. Recommend a plan if the batch needs these sources. ``` -------------------------------- ### Install JavaScript SDK Source: https://docs.valyu.ai/home Install the Valyu JavaScript SDK using npm. ```bash npm install valyu-js ``` -------------------------------- ### Install Scientific Skills with skills.sh Source: https://docs.valyu.ai/integrations/community-agent-skills Use this command to install the scientific skills repository via the `skills.sh` utility. This is the recommended installation method. ```bash npx skills i yorkeccak/scientific-skills ``` -------------------------------- ### Search Configuration Example Source: https://docs.valyu.ai/sdk/typescript-sdk/deepresearch-batch Example of configuring search parameters for a batch. ```APIDOC ## Search Configuration Batch-level `search` configuration applies to all tasks within the batch. ```typescript const batch = await client.batch.create({ name: "Academic Research", mode: "standard", search: { includedSources: ["academic", "finance"], startDate: "2024-01-01", endDate: "2024-12-31", }, }); ``` Refer to the [Batch Processing Guide](/guides/deepresearch-batching#search-parameters) for a comprehensive list of available options. ``` -------------------------------- ### Perform Web Search with Valyu (Python) Source: https://docs.valyu.ai/compare/parallel-alternative Initialize the Valyu client and perform a web search for specific keywords. This example shows how to iterate through the results and print the title and URL of each item. Ensure the 'valyu' library is installed. ```python from valyu import Valyu valyu = Valyu() # Web search response = valyu.search( "latest AI chip developments", search_type="web", max_num_results=10 ) for result in response.results: print(f"Title: {result.title}") print(f"URL: {result.url}") ``` -------------------------------- ### Install Valyu CLI with Homebrew Source: https://docs.valyu.ai/integrations/cli Install the Valyu CLI using the Homebrew package manager. ```bash brew install valyuAI/cli/valyu ``` -------------------------------- ### Perform Web Search with Valyu (JavaScript) Source: https://docs.valyu.ai/compare/parallel-alternative Initialize the Valyu client using the 'valyu-js' library and perform a web search. This example demonstrates iterating through the search results to display the title and URL of each finding. Make sure to install the 'valyu-js' package. ```javascript import { Valyu } from "valyu-js"; const valyu = new Valyu(); // Web search const response = await valyu.search( "latest AI chip developments", { searchType: "web", maxNumResults: 10 } ); response.results.forEach((result) => { console.log(`Title: ${result.title}`); console.log(`URL: ${result.url}`); }); ``` -------------------------------- ### Install Valyu AI Search Plugin Source: https://docs.valyu.ai/integrations/claude-code-plugin Commands to add the Valyu AI plugin marketplace and install the plugin. ```bash # Add the marketplace /plugin marketplace add valyuAI/valyu-search-plugin # Install the plugin /plugin install valyu-search-plugin@valyu-marketplace ``` -------------------------------- ### Install Valyu SDK and set API key Source: https://docs.valyu.ai/guides/workflows-quickstart Install the Valyu SDK for Python or TypeScript and set your API key as an environment variable. ```bash pip install valyu # valyu-py >= 2.10.0 export VALYU_API_KEY="your-api-key" ``` ```bash npm install valyu-js # valyu-js >= 2.8.0 export VALYU_API_KEY="your-api-key" ``` -------------------------------- ### Install Valyu CLI Source: https://docs.valyu.ai/integrations/cli Instructions for installing the Valyu CLI on macOS/Linux and Windows. Choose the method that best suits your environment. ```bash curl -fsSL https://raw.githubusercontent.com/valyuAI/valyu-cli/main/install.sh | bash ``` ```bash brew install valyuAI/cli/valyu ``` ```bash npm install -g @valyu/cli ``` ```powershell irm https://raw.githubusercontent.com/valyuAI/valyu-cli/main/install.ps1 | iex ``` -------------------------------- ### Install Valyu TypeScript SDK Source: https://docs.valyu.ai/sdk/typescript-sdk Install the Valyu TypeScript SDK using npm, pnpm, or yarn. ```bash npm install valyu-js ``` ```bash pnpm add valyu-js ``` ```bash yarn add valyu-js ``` -------------------------------- ### TypeScript SDK Installation Source: https://docs.valyu.ai/api-reference/openapi.json Install the Valyu TypeScript SDK using npm. ```bash npm install valyu ``` -------------------------------- ### Install AWS AgentCore Source: https://docs.valyu.ai/integrations/aws-agentcore Install the AWS AgentCore library. Use `[strands]` for local development with Strands Agents or `[agentcore]` for AWS AgentCore Gateway/Runtime deployment. ```bash pip install "valyu-agentcore[strands]" ``` ```bash pip install "valyu-agentcore[agentcore]" ``` -------------------------------- ### Install Valyu CLI with npm Source: https://docs.valyu.ai/integrations/cli Install the Valyu CLI globally using npm. Requires Node.js 20 or later. ```bash npm install -g @valyu/cli ``` -------------------------------- ### Install Valyu AI SDK Source: https://docs.valyu.ai/integrations/vercel-ai-sdk Install the Valyu AI SDK package using npm. Ensure your Valyu API key is set in your .env file. ```bash npm install @valyu/ai-sdk ``` ```bash VALYU_API_KEY=your-api-key-here ``` -------------------------------- ### Get AI-powered answers with real-time search Source: https://docs.valyu.ai/api-reference/openapi.json Searches across web, academic, and financial sources, then uses AI to generate a readable, cited response. Returns results as a Server-Sent Events (SSE) stream. The AI agent performs multi-round search with up to 2 tool call rounds (3 in `fast_mode`), can decompose queries into sub-queries, and synthesizes findings into a coherent answer. ## SSE Event Types Events are sent as `data: {json}\n\n` with the following types: | Event | Description | | --- | --- | | `search_results` | Search sources found (may occur multiple times) | | `content` | Partial answer text chunk (OpenAI-compatible delta format) | | `metadata` | Final metadata with costs, token usage, and all search results | | `[DONE]` | Stream complete | ## Cost Structure Each request costs a base of ~$0.10 plus variable search and AI token costs. The `cost` object in the metadata event provides a full breakdown. ```APIDOC ## POST /v1/answer ### Description Searches across web, academic, and financial sources, then uses AI to generate a readable, cited response. Returns results as a **Server-Sent Events (SSE)** stream. The AI agent performs multi-round search with up to 2 tool call rounds (3 in `fast_mode`), can decompose queries into sub-queries, and synthesizes findings into a coherent answer. ## SSE Event Types Events are sent as `data: {json}\n\n` with the following types: | Event | Description | | --- | --- | | `search_results` | Search sources found (may occur multiple times) | | `content` | Partial answer text chunk (OpenAI-compatible delta format) | | `metadata` | Final metadata with costs, token usage, and all search results | | `[DONE]` | Stream complete | ## Cost Structure Each request costs a base of ~$0.10 plus variable search and AI token costs. The `cost` object in the metadata event provides a full breakdown. ### Method POST ### Endpoint /v1/answer ### Request Body - **schema**: #/components/schemas/AnswerRequest ### Request Example #### Basic question ```json { "question": "What is the capital of France?" } ``` ``` -------------------------------- ### Get Workflow Source: https://docs.valyu.ai/api-reference/openapi.json Retrieves a single workflow with its resolved version. By default, returns the current version. ```APIDOC ## GET /v1/workflows/{slug} ### Description Retrieves a single workflow with its resolved version. By default returns the current version; pass `version` to fetch a specific one. ### Method GET ### Endpoint /v1/workflows/{slug} ### Parameters #### Path Parameters - **slug** (string) - Required - The workflow slug. #### Query Parameters - **version** (integer) - Optional - Version to return. Defaults to the current version. ### Response #### Success Response (200) - **workflow_response** (object) - The workflow. #### Response Example { "example": "{\"id\": \"wf_abc123\", \"name\": \"Example Workflow\", \"version\": 1}" ``` -------------------------------- ### Manual API Key Setup: Config File Source: https://docs.valyu.ai/integrations/claude-code-plugin Create the ~/.valyu directory and save the API key in config.json. ```bash mkdir -p ~/.valyu echo '{"apiKey": "your-api-key-here"}' > ~/.valyu/config.json ``` -------------------------------- ### Basic Question with Rust SDK Source: https://docs.valyu.ai/sdk/rust-sdk/answer Demonstrates how to initialize the client and ask a simple question, then print the response. ```rust use valyu::ValyuClient; #[tokio::main] async fn main() -> Result<(), Box> { let client = ValyuClient::new("your-api-key"); let response = client.ask("What are the latest developments in quantum computing?").await?; if response.success { if let Some(contents) = &response.contents { println!("{}", contents); } } Ok(()) } ``` -------------------------------- ### Install Valyu Python SDK and Make First Search Call Source: https://docs.valyu.ai/sdk/python-sdk Install the SDK using pip. Ensure your VALYU_API_KEY is set as an environment variable. This snippet demonstrates how to initialize the Valyu client and perform a basic search query. ```python pip install valyu ``` ```python from valyu import Valyu print(Valyu().search("What is quantum computing?")) ``` -------------------------------- ### Ask a question Source: https://docs.valyu.ai/guides/answer-api This snippet demonstrates how to use the Answer API to get an AI-powered answer to a query. It shows examples in Python, JavaScript, and cURL. ```APIDOC ## Ask a question ### Description Use this endpoint to get an AI-powered answer to your query. The API searches across web, academic, and financial sources to generate a readable response with citations. ### Method POST ### Endpoint /v1/answer ### Request Body - **query** (string) - Required - The question you want to ask. ### Request Example ```json { "query": "latest developments in quantum computing" } ``` ### Response #### Success Response (200) - **contents** (string) - The AI-generated answer to the query. - **citations** (array) - A list of sources used to generate the answer. #### Response Example ```json { "contents": "Quantum computing has seen significant advancements in recent years, particularly in areas like qubit stability and error correction. Major breakthroughs include...", "citations": [ { "title": "Nature - Quantum Computing Advances", "url": "https://www.nature.com/quantum-computing" } ] } ``` ``` -------------------------------- ### Valyu Rust SDK Search Example Source: https://docs.valyu.ai/sdk/rust-sdk/search This example demonstrates how to set up the Valyu Rust SDK client, perform a simple search, and use the builder pattern for more advanced search configurations. ```APIDOC ## Valyu Rust SDK Search ### Description This code snippet shows how to initialize the `ValyuClient`, perform a basic search query, and utilize the `DeepSearchRequest` builder for fine-grained control over search parameters. ### Setup 1. Add the `valyu` crate to your `Cargo.toml`: `cargo add valyu` 2. Add `tokio` for the async runtime: `cargo add tokio --features full` 3. Initialize the client with your API key: `let client = ValyuClient::new("your-api-key");` ### Simple Search ```rust use valyu::ValyuClient; #[tokio::main] async fn main() -> Result<(), Box> { let client = ValyuClient::new("your-api-key"); let response = client.search("your query here").await?; // Process response Ok(()) } ``` ### Advanced Search with Builder Pattern ```rust use valyu::{ValyuClient, DeepSearchRequest}; #[tokio::main] async fn main() -> Result<(), Box> { let client = ValyuClient::new("your-api-key"); let request = DeepSearchRequest::new("your query here") .with_search_type("all") // Options: "all", "web", "proprietary" .with_max_results(10) // Range: 1-20 .with_relevance_threshold(0.5) .with_response_length("short") // Options: "short", "medium", "large", "max" .with_included_sources(vec!["valyu/valyu-arxiv".to_string()]); let response = client.deep_search(&request).await?; if let Some(results) = &response.results { for r in results { println!("{}", r.title.as_deref().unwrap_or("Untitled")); } } Ok(()) } ``` ### Builder Options - `with_included_sources(vec![...])`: Specify datasets, domains, or presets (e.g., `academic`, `finance`). - `with_excluded_sources(vec![...])`: Exclude specific datasets or domains. - `with_date_range(start, end)`: Filter by date range (format: `YYYY-MM-DD`). - `with_country_code`: Filter by country code. - `with_fast_mode`: Enable faster search at potentially lower accuracy. **Note**: Use either `with_included_sources` or `with_excluded_sources`, not both. ``` -------------------------------- ### Poll for workflow completion and get results Source: https://docs.valyu.ai/guides/workflows-quickstart Poll the DeepResearch task using its ID to check for completion and retrieve the final status and output. This example uses the Python SDK. ```python result = valyu.deepresearch.wait(task.deepresearch_id) print(result.status) print(result.output) ``` -------------------------------- ### Install and Authenticate Valyu SDK Source: https://docs.valyu.ai/sdk/typescript-sdk/contents Install the SDK using npm and set up authentication by either setting the `VALYU_API_KEY` environment variable or passing the key directly to the `Valyu` constructor. ```bash npm install valyu-js ``` ```typescript import { Valyu } from "valyu-js"; const valyu = new Valyu(); // or // const valyu = new Valyu("your-api-key"); ``` -------------------------------- ### Valyu Answer API Core Usage (TypeScript) Source: https://docs.valyu.ai/sdk/typescript-sdk/answer Use this snippet to perform a search and get a synthesized answer. Ensure the 'valyu-js' SDK is installed and authentication is configured via environment variable or constructor. ```typescript import { Valyu } from "valyu-js"; const valyu = new Valyu(); const response = await valyu.answer("What are the latest developments in quantum computing?", { searchType: "all", // "all" | "web" | "proprietary" | "news" fastMode: false, // true for lower latency streaming: false, // true returns an async iterable of chunks }); if (response.success) console.log(response.contents); ``` -------------------------------- ### Make your first search call Source: https://docs.valyu.ai/sdk/rust-sdk An example of how to initialize the client and perform a basic search query, then print the results. ```APIDOC ## First call ```rust use valyu::ValyuClient; #[tokio::main] async fn main() -> Result<(), Box> { let client = ValyuClient::new("your-api-key"); let response = client.search("What are the latest developments in quantum computing?").await?; if let Some(results) = &response.results { for result in results { println!("{} - {}", result.title.as_deref().unwrap_or("Untitled"), result.url.as_deref().unwrap_or("No URL")); } } Ok(()) } ``` ``` -------------------------------- ### Source-Filtered Request with Custom Instructions Source: https://docs.valyu.ai/api-reference/answer/get-ai-powered-answers-with-real-time-search Filter search results to specific sources and provide custom instructions to guide the AI's focus. This example targets financial sources for SEC enforcement actions. ```json { "query": "SEC enforcement actions against crypto exchanges", "search_type": "proprietary", "included_sources": [ "finance" ], "system_instructions": "You are a financial regulatory analyst. Focus on enforcement actions and penalties.", "start_date": "2024-01-01" } ``` -------------------------------- ### Constructor Options Source: https://docs.valyu.ai/sdk/python-sdk Details the available parameters for configuring the `AsyncValyu` client during instantiation. ```APIDOC ## Constructor Options | Parameter | Type | Description | | --------------------------- | ----------------------------- | ------------------------------------------------------------------------------------- | | `api_key` | `Optional[str]` | API key. Falls back to `VALYU_API_KEY`. | | `base_url` | `str` | Base URL of the Valyu API. | | `max_connections` | `int` | Max simultaneous HTTP connections. Match it to your expected peak concurrency. | | `max_keepalive_connections` | `Optional[int]` | Idle connections kept warm for reuse. | | `timeout` | `float` | Per-request timeout in seconds. | | `http_client` | `Optional[httpx.AsyncClient]` | Pre-configured client to use instead of the default. Ownership stays with the caller. | ``` -------------------------------- ### Discover Available Datasources Source: https://docs.valyu.ai/guides/datasources Query the Datasources API to get a list of available data sources, including example queries, response schemas, and pricing. This is essential for agents to dynamically discover data without hardcoding source lists. ```python import requests datasources = requests.get( "https://api.valyu.ai/v1/datasources", headers={"x-api-key": "YOUR_API_KEY"}, ).json()["datasources"] ``` ```bash curl https://api.valyu.ai/v1/datasources \ -H "x-api-key: YOUR_API_KEY" ``` -------------------------------- ### Create and Run a DeepResearch Batch Source: https://docs.valyu.ai/sdk/python-sdk/deepresearch-batch This snippet demonstrates how to install the Valyu SDK, authenticate, and run a batch of DeepResearch tasks in parallel. It shows how to define tasks, specify a mode, and wait for completion. It also includes an example of listing completed tasks and printing their outputs. ```APIDOC ## Create and Run a DeepResearch Batch ### Description Run a batch of DeepResearch tasks in parallel using the official `valyu` Python SDK batch API. All tasks in a batch share one mode, output format, and search config. ### Setup * **Install**: `pip install valyu` * **Auth**: Set the `VALYU_API_KEY` environment variable or pass `api_key="..."` to the `Valyu` constructor. The SDK calls `https://api.valyu.ai/v1/deepresearch/batches` with the `x-api-key` header. ### Method ```python from valyu import Valyu valyu = Valyu() batch = valyu.batch.create_and_run( name="Competitor scan", mode="fast", # fast (~$0.10/task) is optimised for batch; also standard/heavy/max tasks=[ {"query": "Analyse competitor A"}, {"query": "Analyse competitor B"}, ], wait=True, ) results = valyu.batch.list_tasks(batch.batch_id, status="completed", include_output=True) for t in results.tasks: print(t.query, "->", t.output[:200]) ``` ### Parameters * **`name`** (string) - Required - A name for the batch. * **`mode`** (string) - Required - The processing mode for the batch. Options: `fast` (~$0.10/task), `standard` (~$0.50/task), `heavy` (~$2.50/task), `max` (~$15/task). Requires sufficient credits. * **`tasks`** (list of dict) - Required - A list of tasks to run. Each task is a dictionary, typically containing a `"query"` key. Other keys like `"research_strategy"`, `"report_format"`, `"urls"`, and `"metadata"` can be overridden per task. * **`wait`** (boolean) - Optional - If `True`, the call will block until the batch is complete. ### Notes * Up to 100 tasks per request. * Batch tasks do NOT support `files`, `deliverables`, `mcp_servers`, `previous_reports`, or HITL. Use `valyu.deepresearch.create()` for those. * `mode`, `output_formats`, and `search` are batch-level configurations. * Prefer `webhook_url` over polling for large batches. * Premium sources (SEC, patents, drug discovery, genomics) require a subscription and lower the cost per credit. ``` -------------------------------- ### Basic Search with Valyu SDK Source: https://docs.valyu.ai/sdk/python-sdk/search Demonstrates how to initialize the Valyu client and perform a basic search query. It then prints the number of results and details of each result. ```python from valyu import Valyu valyu = Valyu() response = valyu.search("What are the latest developments in quantum computing?") print(f"Found {len(response.results)} results") for result in response.results: print(result.title, "-", result.url) print(result.content[:200], "...") ``` -------------------------------- ### Install Valyu and Set API Key Source: https://docs.valyu.ai/search/quickstart Install the Valyu library for your environment (Python or Node.js) and set your API key as an environment variable. Obtain your API key from the Valyu platform. ```bash pip install valyu # or: npm install valyu-js export VALYU_API_KEY=your_key # get one at https://platform.valyu.ai ``` -------------------------------- ### Manual API Key Setup: Environment Variable (Bash) Source: https://docs.valyu.ai/integrations/claude-code-plugin Set the VALYU_API_KEY environment variable for Bash. Remember to source the file to apply changes. ```bash echo 'export VALYU_API_KEY="your-api-key-here"' >> ~/.bashrc source ~/.bashrc ``` -------------------------------- ### Error Handling Example Source: https://docs.valyu.ai/sdk/rust-sdk/answer Example of how to handle potential errors when calling the Answer API. ```APIDOC ## Error Handling Example ```rust use valyu::{AnswerRequest, ValyuError}; // Assuming 'client' is an initialized Valyu client match client.answer(&AnswerRequest::new("test query")).await { Ok(response) => { if !response.success { eprintln!("Answer failed: {:?}", response.error); return; } if let Some(contents) = &response.contents { println!("{}", contents); } } Err(ValyuError::InvalidApiKey) => eprintln!("Invalid API key"), Err(ValyuError::RateLimitExceeded) => eprintln!("Rate limit exceeded"), Err(e) => eprintln!("Error: {}", e), } ``` ``` -------------------------------- ### Valyu Rust SDK Search and Deep Search Example Source: https://docs.valyu.ai/sdk/rust-sdk/search Demonstrates how to initialize the Valyu client and perform both a simple search and a more controlled deep search using the builder pattern. Ensure you have the `valyu` and `tokio` crates added to your project. ```rust use valyu::{ValyuClient, DeepSearchRequest}; #[tokio::main] async fn main() -> Result<(), Box> { let client = ValyuClient::new("your-api-key"); // Simple let response = client.search("your query here").await?; // Builder for full control let request = DeepSearchRequest::new("your query here") .with_search_type("all") // "all" | "web" | "proprietary" .with_max_results(10) // 1-20 .with_relevance_threshold(0.5) .with_response_length("short") // "short" | "medium" | "large" | "max" .with_included_sources(vec!["valyu/valyu-arxiv".to_string()]); let response = client.deep_search(&request).await?; if let Some(results) = &response.results { for r in results { println!("{}", r.title.as_deref().unwrap_or("Untitled")); } } Ok(()) } ```