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_idto 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
- Drag the
ParallelWebSearchcomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Create a secret with your Parallel API key and set it as
api_key. UsePARALLEL_API_KEYas the environment variable name. For instructions, see Create Secrets. - Set
top_kto control the maximum number of results (default: 10).
- Create a secret with your Parallel API key and set it as
- Go to the Advanced tab to configure
search_paramsandtimeout.
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
| Parameter | Type | Description |
|---|---|---|
query | str | The search query string. |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | A list of documents containing LLM-optimized search result excerpts. |
links | List[str] | A list of URLs from the search results. |
session_id | str | Session 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:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | Secret | Secret.from_env_var("PARALLEL_API_KEY") | The Parallel API key. |
top_k | Optional[int] | 10 | Maximum number of results to return. Maps to advanced_settings.max_results in the API. |
search_params | Optional[Dict[str, Any]] | None | Additional 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). |
timeout | float | 30.0 | Request 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
query | str | The search query string. | |
search_params | Optional[Dict[str, Any]] | None | Per-run override of search parameters. If provided, fully replaces the init-time search_params. |
Related Information
Was this page helpful?