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 OpenAI-powered applications real-time web search capabilities by integrating Parallel Search as a tool. This guide shows how to define Parallel Search as an OpenAI function and handle tool calls in your application.
.md to its URL or sending Accept: text/markdown.Overview
OpenAI’s tool calling (formerly function calling) allows GPT models to output structured JSON indicating they want to call a function you’ve defined. Your application then executes the function and returns results to the model. By defining Parallel Search as a tool, your model can:- Search the web for current information
- Access real-time news, research, and facts
- Cite sources with URLs in responses
Prerequisites
- Get your Parallel API key from Platform
- Get your OpenAI API key from OpenAI
- Install the required SDKs:
Define the Search Tool
First, define the Parallel search tool using OpenAI’s tool schema format. See Search Tool Definition for a framework-agnostic, copy-paste-ready version.Setting
strict: true (with additionalProperties: false and every field listed in required) enables OpenAI’s structured outputs for tool arguments, preventing schema-violating arguments from the model.Implement the Search Function
Create a function that calls the Parallel Search API when the model requests it:Process Tool Calls
Handle the tool calls returned by OpenAI:Complete Example
Here’s a complete example that ties everything together: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.