Skip to main content
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. Do not substitute /v1 for the documented FindAll or Ingest endpoint paths.
Fireworks serves open models through an OpenAI-compatible API. This guide shows how to give a Fireworks model a web_search tool backed by Parallel Search, so it can answer questions about current topics and cite its sources. The example is a small search app in a single file. You ask a question, the model searches the web with Parallel, and you get back an answer with source URLs.

How it works

  1. You send a question to a Fireworks model through the chat completions API, along with a web_search tool definition.
  2. The model decides it needs fresh information and returns a tool call with a search objective and a few keyword queries.
  3. Your code sends the objective and queries to Parallel Search at POST https://api.parallel.ai/v1/search.
  4. You return the search results to the model as a tool message.
  5. The model writes a final answer from the results and lists the URLs it used.
The model can search more than once before it answers. The example stops after five model calls.

What you’ll need

  • A Fireworks API key, exported as FIREWORKS_API_KEY.
  • A Parallel API key, exported as PARALLEL_API_KEY.
  • Python 3.10 or later. For the TypeScript version, Node.js 22 or later.

Install

The example uses the OpenAI SDK because Fireworks is OpenAI-compatible. It calls Parallel Search over plain HTTP, so you don’t need the Parallel SDK.

Build the search app

Save the Python version as search_app.py and run it with python search_app.py. Save the TypeScript version as search_app.ts and run it with npx tsx search_app.ts.
The example uses Kimi K3 (accounts/fireworks/models/kimi-k3), which Fireworks lists as a recommended model for agents with tool use. You can switch to any Fireworks model that supports function calling by changing MODEL.

Example output

When the model decides to search, its tool call arguments look like this:
Parallel Search returns results ordered by relevance. Each result has a url, title, publish_date, and excerpts. The app passes the results array to the model unchanged:
The full Search response also includes search_id, session_id, warnings, and usage. See the Search API reference for every field. The final answer is plain text that ends with the sources the model used:

Tips

  • Choose a model that supports function calling. Not every Fireworks model supports tools. Look for Function Calling on the model’s page in the Fireworks Model Library, or see Fireworks’ recommended models for agents with tool use. Fireworks also recommends a low temperature, between 0.0 and 0.3, for tool calling.
  • Pass the assistant message back as is. Reasoning models on Fireworks can return reasoning_content alongside tool calls. Appending the SDK message object keeps that context for the next call. See interleaved thinking in the Fireworks docs.
  • Pick a Search mode. The example uses fast, which returns high-quality results in around 700ms and suits most tool-calling loops. Use turbo for the lowest latency and cost. Leave out mode to use the default advanced mode when quality matters more than speed. See Search modes.
  • Set the result count. advanced_settings.max_results sets the maximum number of results. It defaults to 10 and Search returns at most 20. Fewer results keep the model’s context small. See Advanced settings.
  • Reuse one session per question. The example creates a session_id for each question and sends it with every search for that question. This groups related calls, as described in Search best practices.
  • Cite sources. Every result includes its url, and the system prompt asks the model to list the URLs it used. If your app needs a guaranteed source list, also collect the URLs from the search results in your code.

Costs

You pay Fireworks for model tokens and Parallel for each search. See Fireworks serverless pricing and Parallel pricing. Search pricing depends on the mode, and each tool call is one search request.

Next steps