翻篇收录说明
翻篇网页快照

Fireworks - Parallel

https://docs.parallel.ai/integrations/fireworks

最近抓取:2026-12-04 18:17:02(北京时间)

最近内容变化:2026-12-04 18:17:02(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Ground Fireworks-hosted open models in live web results with Parallel Search

正文摘录

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. 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, and the model can search the web with Parallel before answering. The system prompt asks it to list the URLs it used. How it works You send a question to a Fireworks model through the chat completions API, along with a web_search tool definition. The model may decide to call the tool with a search objective and a few keyword queries. If it answers without searching, the app returns that answer as is. Your code sends the objective and queries to Parallel Search at POST https://api.parallel.ai/v1/search. You return the search results to the model as a tool message. The model writes a final answer from the results. The system prompt asks it to list 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. The OpenAI SDK sets these minimums. The Parallel SDKs support older versions, but this example doesn’t use them. Install PythonTypeScriptpip install openai requests export FIREWORKS_API_KEY="your-fireworks-api-key" export PARALLEL_API_KEY="your-parallel-api-key" 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. PythonTypeScriptimport json import os import uuid import requests from openai import OpenAI MODEL = "accounts/fireworks/models/kimi-k3" fireworks = OpenAI( api_key=os.environ["FIREWORKS_API_KEY"], base_url="https://api.fireworks.ai/inference/v1", ) SEARCH_TOOL = { "type": "function", "function": { "name": "web_search", "description": "Search the web. Results include URLs and excerpts, and titles when available.", "parameters": { "type": "object", "properties": { "objective": { "type": "string", "description": "Describe the search goal in a concise, standalone sentence. Name the key entity or topic.", }, "search_queries": { "type": "array", "description": "Provide 1-3 keyword queries of 3-6 words each. Include the key entity or topic in every query. For multiple queries, vary names, synonyms, or angles. Do not use sentences, instructions, or site: operators.", "items": {"type": "string"}, "minItems": 1, "maxItems": 3, }, }, "required": ["objective", "search_queries"], }, }, } SYSTEM_PROMPT = ( "Use the web_search tool to find current information before you answer. " "Answer in a few sentences, then end with a Sources list of the URLs you used." ) def web_search(objective, search_queries, session_id): response = requests.post( "https://api.parallel.ai/v1/search", headers={"x-api-key": os.environ["PARALLEL_API_KEY"]}, json={ "objective": objective, "search_queries": search_queries, "session_id": session_id, "mode": "fast", "advanced_settings": {"max_results": 5}, }, timeout=60, ) response.raise_for_status() return response.json()["results"] def answer(question, max_steps=5): session_id = f"session_{uuid.uuid4().hex}" messages = [ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": question}, ] for _ in range(max_steps): response = fireworks.chat.completions.create( model=MODEL, messages=messages, tools=[SEARCH_TOOL], temperature=0.1, ) message = response.choices[0].message if not message.tool_calls: return message.content messages.append(message) for tool_call in message.tool_calls: args = json.loads(tool_call.function.arguments) results = web_search(args["objective"], args["search_queries"], session_id) messages.append( { "role": "tool", "tool_call_id": tool_call.id, "content": json.dumps(results), } ) raise RuntimeError("The model did not finish answering within max_steps.") if __name__ == "__main__": print(answer("What is the latest stable release of Python, and what is new in it?")) The example uses Kimi K3 (accounts/fireworks/models/kimi-k3), which supports function calling. To use another model, set MODEL to a Fireworks model that supports function calling. Example output When the model decides to search, its tool call arguments look like this: { "objective": "Find the latest stable Python release and what is new in it.", "search_queries": [ "latest Python stable release", "Python release new features", "Python whats new" ] } Parallel Search returns results ordered by relevance. Each result has a url and excerpts. The title and publish_date fields are optional and can be null. The app passes the results array to the model unchanged: [ { "url": "https://www.python.org/downloads/release/python-3150", "title": "Python Release Python 3.15.0 | Python.org", "publish_date": null, "excerpts": [ "**Release date:** Oct. 9, 2026\n\nPython 3.15.0 is the newest major release ..." ] } ] The full Search response also includes search_id and session_id, and may include warnings and usage. See the Search API reference for every field. The system prompt asks for an answer in plain text followed by a list of source URLs: <A short answer written from the search results.> Sources: - https://www.python.org/downloads/release/python-3150 - https://blog.python.org/2026/10/python-3150-final-is-here 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. Each search tool call sends one Search request. Search pricing depends on the mode and the number of results beyond the first 10. Next steps Extract: add a second tool so the model can read full pages or focused excerpts from URLs it finds. Parallel MCP: connect Parallel Search and Extract to an MCP client without writing a tool handler. Search best practices: write better objectives and search queries. Fireworks docs: tool calling, OpenAI compatibility, and the serverless quickstart.