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: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 | No* | Natural language description of your search goal |
search_queries | string[] | No* | Specific search queries to execute |
max_chars_total | integer | No | Maximum total characters across all excerpts (default 50000) |
objective or search_queries is required.
The complete example above shows additional optional parameters (
max_results) that you can add to the tool definition for more control. See the Search API documentation for all available options.