Documentation Index
Fetch the complete documentation index at: https://docs.parallel.ai/llms.txt
Use this file to discover all available pages before exploring further.
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
Give your Claude-powered applications real-time web search by registering Parallel Search as a tool. This guide shows how to define Parallel Search using Anthropic’s Messages API and handle the tool-call loop.
.md to its URL or sending Accept: text/markdown.Overview
Anthropic’s tool use lets Claude emit a structuredtool_use block when it wants to call a function you’ve defined. Your application executes the function and returns a tool_result block in a follow-up user message. By registering Parallel Search as a tool, Claude can:
- Search the web for current information
- Access real-time news, research, and facts
- Cite sources with URLs in responses
The Anthropic SDKs also ship a higher-level Tool Runner helper (currently in beta) that runs the loop for you. The example below uses the manual loop so the request/response shapes are explicit; once you understand them, switch to Tool Runner for less boilerplate.
Prerequisites
- Get your Parallel API key from Platform
- Get your Anthropic API key from Anthropic Console
- Install the required SDKs:
Define the Search Tool
Anthropic tool definitions usename, description, and input_schema (no outer function wrapper, and the schema field is input_schema rather than OpenAI’s parameters). See Search Tool Definition for a framework-agnostic, copy-paste-ready version.
Add
"strict": true to the tool definition to enable strict tool use, which guarantees that Claude’s tool inputs conform to your schema exactly.Implement the Search Function
Create a function that calls the Parallel Search API when Claude requests it:Process Tool Calls
Claude returns one or moretool_use blocks inside response.content whenever stop_reason == "tool_use". Execute each call and reply with a user message whose content is a list of tool_result blocks:
Anthropic requires that
tool_result blocks come first in the content array of the user message that follows a tool_use response — any free-form text must come after them.Complete Example
End-to-end: a loop that lets Claude callsearch_web until it has enough information to answer.
Tool Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
objective | string | Yes | A concise, self-contained search query. Must include the key entity or topic being searched for. |
search_queries | string[] | Yes | Exactly 3 keyword search queries, each 3-6 words. Must be diverse — vary entity names, synonyms, and angles. |
This example uses the default
advanced mode, which prioritizes result quality for tool use. For lower-latency responses, consider "basic" — see Search Modes.Differences from the OpenAI Client
If you’re porting from the OpenAI Tool Calling guide, the main shape changes are:| OpenAI client | Anthropic client | |
|---|---|---|
| Tool wrapper | {type: "function", function: {...}} | Flat {name, description, input_schema} |
| Schema field | parameters | input_schema |
| Tool call in response | message.tool_calls[i].function.arguments (JSON string) | content[i] block where type == "tool_use" (parsed dict) |
| Tool result message | {role: "tool", tool_call_id, content} | {role: "user", content: [{type: "tool_result", tool_use_id, content}]} |
| Tool-call signal | finish_reason == "tool_calls" | stop_reason == "tool_use" |