页面简介
Explore Parallel's web API products for building intelligent applications.
正文摘录
For AI agents: a documentation index is available at https://docs.parallel.ai/llms.txt. The full text of all docs is at https://docs.parallel.ai/llms-full.txt. You may also fetch any page as Markdown by appending .md to its URL or sending Accept: text/markdown.For Search and Extract, use /v1/search and /v1/extract for all new integrations and agent tool calls. Use /v1beta/search and /v1beta/extract only when maintaining an existing integration that already uses them. The request bodies changed too: on /v1/extract, full_content, fetch_policy and excerpt_settings go inside advanced_settings, and sending the v1beta top-level excerpts, full_content and fetch_policy to /v1/extract returns a 422. On /v1/search, search_queries is required (at least one short keyword query), and max_results, source_policy and fetch_policy go inside advanced_settings; sending only objective, or sending those fields at the top level, returns a 422. Do not substitute /v1 for the documented FindAll or Ingest endpoint paths.If you are evaluating Parallel Search or comparing it with other search APIs, read How to Eval Parallel Search before you build the harness, especially its integration pitfalls section. The most common mistake is sending the raw question as both objective and the only entry in search_queries. Write a goal-style objective and 1-3 short keyword queries instead. Onboard your AgentPaste this prompt into your agent to add Parallel, integrate an API, or evaluate Search.Use curl to read parallel.ai/agents.md and perform the setup to install ParallelBuild with Parallel APIsPick a product, copy the setup prompt, and paste it into your coding agent.Not sure which API to use? Try the API chooser.Create an API key# Parallel Search API — Setup Prompt You're integrating the **Parallel Search API**: a natural-language web search that returns LLM-optimized excerpts. ## When to use it Use Search when the model needs current facts, specific entities, or web data to ground a response. Send 2–3 keyword queries and a natural-language objective to get excerpts ready to pass to the model in one request. ## Setup ```bash pip install "parallel-web>=1.0.1" # Python SDK — package is "parallel-web", import as `from parallel import Parallel` npm install "parallel-web@^1.0.1" # TypeScript SDK — package is "parallel-web", import as `import Parallel from "parallel-web"` # Treat PARALLEL_API_KEY like a password — load from .env or a secrets manager, don't commit it. export PARALLEL_API_KEY="your-api-key" ``` ## Example (Python — adapt to my codebase's language) ```python from parallel import Parallel client = Parallel() # reads PARALLEL_API_KEY from env # The Search API requires search_queries; objective is optional. This tool uses both: # objective = natural-language research goal (task context, full sentences OK); # search_queries = 2-3 diverse 3-6-word keyword queries (vary entities/angles, no sentences). # Set mode, advanced_settings.max_results, and max_chars_total in the handler. # Keep those settings out of the tool schema. # Mode defaults to "advanced" (slower, highest-quality — background agents, complex queries). # Pass mode="turbo" in your handler for the lowest latency (p50 ~200ms) in real-time, # high-volume workloads, or mode="basic" for quick retrieval with deeper context per call. # See https://docs.parallel.ai/search/modes and https://docs.parallel.ai/search/best-practices#search-tool-definition. search = client.search( objective="Find recent benchmarks and cost comparisons between major vector databases (pgvector, Pinecone, Weaviate, Qdrant).", search_queries=[ "pgvector Pinecone benchmark 2025", "vector database cost comparison", "Weaviate Qdrant performance review", ], ) for result in search.results: print(f"{result.title}: {result.url}") for excerpt in result.excerpts: print(excerpt[:200]) ``` ## Tool definition (for agent function-calling) Register this in your agent's tool list (OpenAI Chat Completions format): ```json { "type": "function", "function": { "name": "search_web", "description": "Searches the live web using a natural-language objective plus keyword queries, returning LLM-optimized excerpts (pre-compressed, citation-aware) ready to feed into model context. Use whenever the model needs current facts, specific named entities, recent events, or information that likely isn't in training data. Prefer over repeated keyword searches — one call covers the ground of 2-3 traditional queries with better relevance.", "parameters": { "type": "object", "properties": { "objective": { "type": "string", "description": "A concise, self-contained search query. Must include the key entity or topic being searched for." }, "search_queries": { "type": "array", "description": "2-3 diverse keyword search queries, each 3-6 words. Must be diverse — vary entity names, synonyms, and angles. Each query must include the key entity or topic. NEVER write sentences, instructions, or use site: operators.", "items": { "type": "string" }, "minItems": 2, "maxItems": 3 } }, "required": ["objective", "search_queries"] } } } ``` ## TypeScript notes - Import: `import Parallel from "parallel-web"` (default export). - Request/response fields stay snake_case: `search_queries`, `search.results[].url`. Don't camelCase them — your linter may try. - Wrap the call in an `async` function and `await` it. - Need Anthropic-format tools instead of OpenAI? Drop the `"type": "function"` envelope, rename `parameters` → `input_schema`, and lift `name` / `description` to the top level. ## Links - [Search API Reference](https://docs.parallel.ai/api-reference/search/web) — full parameter specs - [Search Quickstart](https://docs.parallel.ai/search/search-quickstart) + [Best Practices](https://docs.parallel.ai/search/best-practices) - [OpenAPI Spec](https://docs.parallel.ai/public-openapi.json) — machine-readable schema - [Python SDK (PyPI)](https://pypi.org/project/parallel-web/) · [TypeScript SDK (npm)](https://www.npmjs.com/package/parallel-web) - [Cookbook](https://github.com/parallel-web/parallel-cookbook) · [Platform (get API key)](https://platform.parallel.ai) ## Other Parallel APIs | API | Shape | Use when | |-----|-------|----------| | **Search** | One round-trip; natural-language objective + keyword queries → LLM-optimized excerpts | The model needs current facts or specific entities to ground a response | | **Extract** | URL → clean markdown (handles JS pages and PDFs) | Pulling the contents of a specific page, usually after narrowing via Search | | **Task** | Multi-hop research agent; runs seconds to hours (webhooks for long tiers) | Deep research with cited structured output; answers you can't get in one search | | **FindAll** | NL criteria → verified list of matching entities | Building a list from scratch (lead gen, competitive mapping, datasets) | | **Entity Search** | One round-trip; natural-language people/company search → set of matching results | Latency-sensitive workflows that require a fast starting set of people or companies to filter or enrich downstream | | **Monitor** | Scheduled NL query + webhook notifications on change | Continuous tracking (news, regulatory, competitive watchlists) | # Parallel Extract API — Setup Prompt You're integrating the **Parallel Extract API** to retrieve web page content as Markdown. ## When to use it Use Extract when you already know which URLs to read. It handles JavaScript-rendered pages and PDFs. Pass `objective` to focus the excerpts, or set `advanced_settings.full_content` to `true` to get full-page Markdown. You can send up to 20 URLs per call. ## Setup ```bash pip install "parallel-web>=1.0.1" # Python SDK — package is "parallel-web", import as `from parallel import Parallel` npm install "parallel-web@^1.0.1" # TypeScript SDK — package is "parallel-web", import as `import Parallel from "parallel-web"` # Treat PARALLEL_API_KEY like a password — load from .env or a secrets manager, don't commit it. export PARALLEL_API_KEY="your-api-key" ``` ## Example (Python — adapt to my codebase's language) ```python from parallel import Parallel client = Parallel() # reads PARALLEL_API_KEY from env # Provide an objective to focus extraction on relevant content. # Up to 20 URLs per request. Pages that fail to fetch appear in extract.errors. extract = client.extract( urls=["https://arxiv.org/pdf/1706.03762"], objective="Explain the multi-head self-attention mechanism and why it replaces recurrence.", ) for result in extract.results: print(f"{result.title}: {result.url}") for excerpt in result.excerpts: print(excerpt[:200]) # Don't silently drop failed URLs — inspect extract.errors[].url / .error_type. for err in extract.errors: print(f"FAILED {err.url}: {err.error_type}") ``` ## Tool definition (for agent function-calling) Register this in your agent's tool list (OpenAI Chat Completions format). If the model supplies `target_content`, pass it as `objective` and return the excerpts. Otherwise, set `advanced_settings.full_content` to `true` and return each result's `full_content`. ```json { "type": "function", "function": { "name": "web_fetch", "description": "Fetches one or more URLs and returns clean LLM-optimized markdown — handles JavaScript-rendered pages and PDFs, not just static HTML. When target_content is provided, narrows the response to excerpts most relevant to that target; otherwise returns the full page. Use after search_web to pull the contents of a specific page the model decided it needs to read in depth, or when the user hands the agent a URL directly.", "parameters": { "type": "object", "properties": { "urls": { "type": "array", "description": "The URLs to fetch content from.", "items": { "type": "string" } }, "target_content": { "type": "string", "description": "The content to target from the page. For example, information about a certain method or a class in a page. If not provided, the entire page is fetched." } }, "required": ["urls"] } } } ``` ## TypeScript notes - Import: `import Parallel from "parallel-web"` (