JinaReaderConnector
Fetch and parse web content, search the web, or check facts using the Jina Reader API.
Key Features
- Supports three operation modes:
read(fetch a URL and return its text content),search(search the web and return top results), andground(perform fact checking). - Returns results as
Documentobjects with rich metadata whenjson_responseisTrue. - Accepts optional request headers for fine-grained control over the Jina Reader API (for example, specifying the target language or output format).
- Supports both synchronous and asynchronous execution.
Configuration
- Drag the
JinaReaderConnectorcomponent 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 Jina API key. Use
JINA_API_KEYas the secret key. For instructions, see Create Secrets. Get your API key from Jina AI. - Set
modeto the operation you want:read,search, orground. - Set
json_responsetotrueto get rich structured metadata orfalseto get a single document with minimal metadata.
- Create a secret with your Jina API key. Use
Connections
JinaReaderConnector receives a query string:
- In
readmode, the query is a URL to fetch. - In
searchmode, the query is a search term to look up on the web. - In
groundmode, the query is a statement to fact-check.
It outputs a list of Document objects. In search mode, multiple documents are returned (one per result). In read and ground modes, a single document is returned.
Source Code
To check this component's source code, open reader.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
JinaReaderConnector:
type: haystack_integrations.components.connectors.jina.reader.JinaReaderConnector
init_parameters:
mode: read
api_key:
type: env_var
env_vars:
- JINA_API_KEY
strict: false
json_response: true
Using the Component in a Pipeline
This is an example of a query pipeline that uses JinaReaderConnector in search mode to retrieve web documents for a given query and then generates an answer using an LLM.
# haystack-pipeline
components:
JinaReaderConnector:
type: haystack_integrations.components.connectors.jina.reader.JinaReaderConnector
init_parameters:
mode: search
api_key:
type: env_var
env_vars:
- JINA_API_KEY
strict: false
json_response: true
prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
required_variables: "*"
template: |-
Answer the question based on the provided web search results.
Search results:
{% for document in documents %}
{{ document.content }}
{% endfor %}
Question: {{ question }}
Answer:
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: JinaReaderConnector.documents
receiver: prompt_builder.documents
- sender: prompt_builder.prompt
receiver: llm.messages
max_runs_per_component: 100
metadata: {}
inputs:
query:
- JinaReaderConnector.query
- prompt_builder.question
outputs:
replies: llm.replies
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
query | str | The URL to fetch (in read mode), the search term (in search mode), or the statement to fact-check (in ground mode). |
headers | Optional[Dict[str, str]] | Optional headers to include in the request. See the Jina Reader documentation for available options. |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | The fetched or searched content as Document objects. In read and ground modes, one document is returned. In search mode, multiple documents are returned (one per result). |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
mode | JinaReaderMode | str | The operation mode for the reader. Use read to process a URL and return its text content, search to search the web, or ground to perform fact checking. | |
api_key | Secret | Secret.from_env_var('JINA_API_KEY') | The Jina API key. |
json_response | bool | True | If True, requests a JSON response from Jina, resulting in Document objects with rich structured metadata. If False, requests a raw text response, resulting in one Document with minimal metadata. |
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 URL, search term, or statement to process. | |
headers | Optional[Dict[str, str]] | None | Optional headers to include in the request to the Jina Reader API. |
Related Information
Was this page helpful?