Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

ParallelWebSearch

Search the web using the Parallel Search API and return results as Haystack Documents.

Key Features​

  • Wraps the Parallel Search API and returns LLM-optimized excerpts as structured documents.
  • Returns documents with content and URL links, plus a session identifier for linking related searches.
  • Supports session continuity: pass the returned session_id to follow-up searches for better contextual results.
  • Configurable search modes (turbo, fast, basic, advanced) for different latency and quality trade-offs.
  • Supports domain and date filters through search_params.

Configuration​

  1. Drag the ParallelWebSearch component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Create a secret with your Parallel API key and set it as api_key. Use PARALLEL_API_KEY as the environment variable name. For instructions, see Create Secrets.
    2. Set top_k to control the maximum number of results (default: 10).
  4. Go to the Advanced tab to configure search_params and timeout.

Connections​

ParallelWebSearch receives a query string and returns a list of Document objects, a list of URLs, and a session identifier. Connect its documents output to downstream components such as PromptBuilder for retrieval-augmented generation.

Source Code​

To check this component's source code, open parallel_websearch.py in the Haystack Core Integrations repository.

Usage Examples​

Basic Configuration​

ParallelWebSearch:
type: haystack_integrations.components.websearch.parallel.parallel_websearch.ParallelWebSearch
init_parameters:
api_key:
type: env_var
env_vars:
- PARALLEL_API_KEY
strict: false
top_k: 5

Using the Component in a Pipeline​

# haystack-pipeline
components:
websearch:
type: haystack_integrations.components.websearch.parallel.parallel_websearch.ParallelWebSearch
init_parameters:
api_key:
type: env_var
env_vars:
- PARALLEL_API_KEY
strict: false
top_k: 5

prompt_builder:
type: haystack.components.builders.chat_prompt_builder.ChatPromptBuilder
init_parameters:
required_variables: "*"
template:
- role: user
content: |
Answer the question using the following search results:
{% for doc in documents %}
{{ doc.content }}
{% endfor %}
Question: {{ question }}

llm:
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
init_parameters:
api_key:
type: env_var
env_vars:
- OPENAI_API_KEY
strict: false
model: gpt-4o-mini

connections:
- sender: websearch.documents
receiver: prompt_builder.documents
- sender: prompt_builder.prompt
receiver: llm.messages

max_runs_per_component: 100

metadata: {}

inputs:
query:
- websearch.query
- prompt_builder.question

outputs:
replies: llm.replies

Parameters​

Inputs​

ParameterTypeDescription
querystrThe search query string.

Outputs​

ParameterTypeDescription
documentsList[Document]A list of documents containing LLM-optimized search result excerpts.
linksList[str]A list of URLs from the search results.
session_idstrSession identifier for this search. Pass it to follow-up searches in the same task for better contextual results.

Init Parameters​

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
api_keySecretSecret.from_env_var("PARALLEL_API_KEY")The Parallel API key.
top_kOptional[int]10Maximum number of results to return. Maps to advanced_settings.max_results in the API.
search_paramsOptional[Dict[str, Any]]NoneAdditional parameters for the Parallel Search API. Supported keys include objective, mode (turbo, fast, basic, or advanced), max_chars_total, session_id, client_model, and advanced_settings (with nested source policy, date filters, and excerpt settings).
timeoutfloat30.0Request timeout in seconds.

Run Method Parameters​

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
querystrThe search query string.
search_paramsOptional[Dict[str, Any]]NonePer-run override of search parameters. If provided, fully replaces the init-time search_params.