Parallel AI Tool
This tool provides integration between LlamaIndex and Parallel AI's Search and Extract APIs, enabling LLM agents to perform web research and content extraction.
- Search API: Returns structured, compressed excerpts from web search results optimized for LLM consumption
- Extract API: Converts public URLs into clean, LLM-optimized markdown including JavaScript-heavy pages and PDFs
Installation
pip install llama-index-tools-parallel-web-systems
Setup
- Get your API key from Parallel AI Platform
- Set your API key as an environment variable or pass it directly
Usage
from llama_index.tools.parallel_web_systems import ParallelWebSystemsToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
# Initialize the tool with your API key
parallel_tool = ParallelWebSystemsToolSpec(
api_key="your-api-key-here",
)
# Create an agent with the tool
agent = FunctionAgent(
tools=parallel_tool.to_tool_list(),
llm=OpenAI(model="gpt-4o"),
)
# Use the agent to perform web research
response = await agent.run("What was the GDP of France in 2023?")
print(response)
Available Functions
search
Search the web using Parallel AI's Search API. Returns structured excerpts optimized for LLM consumption.
Parameters:
objective(str, optional): Natural-language description of what to search forsearch_queries(list[str], optional): Traditional keyword search queries (max 5)max_results(int): Maximum results to return, 1-40 (default: 10)mode(str, optional):'one-shot'for comprehensive results,'agentic'for token-efficient resultsexcerpts(dict, optional): Excerpt settings, e.g.,{'max_chars_per_result': 1500}source_policy(dict, optional): Domain and date preferencesfetch_policy(dict, optional): Cache vs live content policy
At least one of objective or search_queries must be provided.
Example:
from llama_index.tools.parallel_web_systems import ParallelWebSystemsToolSpec
parallel_tool = ParallelWebSystemsToolSpec(api_key="your-api-key")
# Search with an objective
results = parallel_tool.search(
objective="What are the latest developments in renewable energy?",
max_results=5,
mode="one-shot",
)
for doc in results:
print(f"Title: {doc.metadata.get('title')}")
print(f"URL: {doc.metadata.get('url')}")
print(f"Excerpts: {doc.text[:300]}...")
print("---")
# Search with specific queries
results = parallel_tool.search(
search_queries=["solar power 2024", "wind energy statistics"],
max_results=8,
mode="agentic",
)
extract
Extract clean, structured content from web pages using Parallel AI's Extract API.
Parameters:
urls(list[str]): List of URLs to extract content fromobjective(str, optional): Natural language objective to focus extractionsearch_queries(list[str], optional): Specific keyword queries to focus extractionexcerpts(bool | dict): Include excerpts (default: True). Can be dict like{'max_chars_per_result': 2000}full_content(bool | dict): Include full page content (default: False)fetch_policy(dict, optional): Cache vs live content policy
Example:
from llama_index.tools.parallel_web_systems import ParallelWebSystemsToolSpec
parallel_tool = ParallelWebSystemsToolSpec(api_key="your-api-key")
# Extract content focused on a specific objective
results = parallel_tool.extract(
urls=["https://en.wikipedia.org/wiki/Artificial_intelligence"],
objective="What are the main applications and ethical concerns of AI?",
excerpts={"max_chars_per_result": 2000},
)
for doc in results:
print(f"Title: {doc.metadata.get('title')}")
print(f"Content: {doc.text[:500]}...")
# Extract full content from multiple URLs
results = parallel_tool.extract(
urls=[
"https://example.com/article1",
"https://example.com/article2",
],
full_content=True,
excerpts=False,
)
Error Handling
The tool includes built-in error handling. If an API call fails, it returns an empty list, allowing your agent to continue:
results = parallel_tool.search(objective="test query")
if not results:
print("No results found or API error occurred")
For extract operations, failed URLs are included in results with error information:
results = parallel_tool.extract(urls=["https://invalid-url.com/"])
for doc in results:
if doc.metadata.get("error_type"):
print(f"Failed: {doc.metadata['url']} - {doc.text}")
License
MIT
Metadata
Release files for llama-index-tools-parallel-web-systems 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_tools_parallel_web_systems-0.3.0.tar.gz | 6.2 kB | Without provenance | Details for llama_index_tools_parallel_web_systems-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_tools_parallel_web_systems-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_tools_parallel_web_systems-0.3.0-py3-none-any.whl |
Total release size: 12.8 kB
Release files / llama_index_tools_parallel_web_systems-0.3.0.tar.gz
| Download URL | llama_index_tools_parallel_web_systems-0.3.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bcb9bdaa7abf13a8e4ead35fae2242ce40ec46b40fe427c452d61c830145b34
|
|
BLAKE2b-256 checksum How to use checksums |
e2f0ab9e5e78584e5eac8e5cf93b68ad6c54b7d0c8c9994f33f9d9b11d35160e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_tools_parallel_web_systems-0.3.0-py3-none-any.whl
| Download URL | llama_index_tools_parallel_web_systems-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b93fe388e8195394f1273793d5c4aab07ea1bab35350796ed44a8ea07faf757
|
|
BLAKE2b-256 checksum How to use checksums |
a2ba41739a26c42517fbc2c369689233046e2abdb1e6f9494957b61c01261103
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-tools-parallel-web-systems 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.