Blog
 / 
AI Tools
October 30, 2026

Ground Fireworks AI Models in Real-Time Web Data with You.com

You can integrate You.com with Fireworks AI to build assistants and agents on open models that answer from current, cited web results instead of only their training data. You.com returns LLM-ready web and news results, and Fireworks serves open chat models behind an OpenAI-compatible API.

This page explains how Fireworks AI and You.com fit together, then walks you through a complete tutorial. You learn how to connect a Fireworks model to the You.com MCP server with no setup, search the web with the You.com Web Search API, generate answers with inline citations, build a tool-calling research agent, and use the integration from LangChain.

Background

Fireworks AI is an inference and training platform for open models, such as Kimi, DeepSeek, GLM, Qwen, MiniMax, and gpt-oss. You can call models on shared serverless capacity and pay per token, or run them on dedicated deployments. You can also fine-tune models on your own data and serve the tuned model on the same platform.

Because the Fireworks API is compatible with the OpenAI API, you use the official OpenAI client libraries and point them at the Fireworks base URL, https://api.fireworks.ai/inference/v1. Frameworks that support OpenAI-compatible providers, such as LangChain and LangGraph, work the same way.

You.com complements Fireworks in the following ways:

  • Fresh knowledge: Open models know only what was in their training data. The Web Search API returns current web and news results, so the model can answer questions about recent events.
  • Citations: Every result includes its URL and title, so the model can cite its sources and your users can verify the answer.
  • Agent tools: The You.com MCP server and the Web Search API give agents a search tool that they call whenever they need more information.

Key Concepts

ConceptFireworks AIYou.com
SearchDecides when to search and what to search for, through OpenAI-compatible function calling or the Responses API.Returns ranked web and news results with titles, URLs, and query-relevant snippets.
GroundingGenerates an answer from the search results and cites them.Supplies the search results that ground the answer.
AgentsPlans multi-step research and calls tools in a loop.Backs the agent's search tool, through the Web Search API or the MCP server.
MCPConnects to remote MCP servers from the Responses API and calls their tools for you.Hosts an MCP server with search, content, and research tools.

Supported Models

The following serverless models work with this tutorial. For the full list, including models that you can run on dedicated deployments, see the Fireworks model library.

Model typeModel IDNotes
Chataccounts/fireworks/models/gpt-oss-120bSupports function calling. Used for cited answers in this tutorial.
Chataccounts/fireworks/models/kimi-k3Supports function calling. Used for the agent and the MCP example in this tutorial.
Chataccounts/fireworks/models/glm-5p3, accounts/fireworks/models/deepseek-v4p1-flash, accounts/fireworks/models/minimax-m3Support function calling. Use any of them in place of the models above.

Quick Start: Connect a Fireworks Model to the You.com MCP Server

The fastest way to give a Fireworks model web access is the Fireworks Responses API, which connects to remote MCP servers. When you add the You.com MCP server as a tool, Fireworks lists the server's tools, lets the model call them, and returns the final answer. The ?profile=free endpoint doesn't need a You.com API key, and allows the you-search tool for up to 100 queries per day.

pip install --quiet --upgrade openai
export FIREWORKS_API_KEY="<fireworks-api-key>"
import os
from openai import OpenAI

fireworks = OpenAI(
    base_url="https://api.fireworks.ai/inference/v1",
    api_key=os.environ["FIREWORKS_API_KEY"],
)

response = fireworks.responses.create(
    model="accounts/fireworks/models/kimi-k3",
    input="What are the most recent developments in fusion energy? Cite your sources.",
    tools=[
        {
            "type": "mcp",
            "server_label": "you",
            "server_url": "https://api.you.com/mcp?profile=free",
            "require_approval": "never",
        }
    ],
)
print(response.output_text)

The response's output list contains an mcp_call item for each search that the model ran, followed by the final message. For higher limits and full control over the search parameters, use the Web Search API as shown in the following tutorial.

Tutorial: Build a Research Assistant with Web Search

In this tutorial, you call the You.com Web Search API from Python, generate answers that cite their sources, and build an agent that decides for itself what to search for.

Prerequisites

To complete this tutorial, you must have the following:

  • A You.com API key. To create one, go to the You.com platform.
  • A Fireworks AI API key. To create one, go to API Keys in the Fireworks console.
  • Python 3.9 or later.

Set Up the Environment

1. Install the dependencies.

pip install --quiet --upgrade openai requests

2. Set your environment variables.

export YDC_API_KEY="<you-api-key>"
export FIREWORKS_API_KEY="<fireworks-api-key>"

3. Create a Fireworks client and choose your models.

import json
import os

import requests
from openai import OpenAI

fireworks = OpenAI(
    base_url="https://api.fireworks.ai/inference/v1",
    api_key=os.environ["FIREWORKS_API_KEY"],
)

CHAT_MODEL = "accounts/fireworks/models/gpt-oss-120b"
AGENT_MODEL = "accounts/fireworks/models/kimi-k3"

Search the Web

Send a query to the Web Search API and keep the title, URL, and snippets of each web result. The snippets are short excerpts of the page that are relevant to the query.

def web_search(query, count=5):
    response = requests.post(
        "https://ydc-index.io/v1/search",
        headers={"X-API-Key": os.environ["YDC_API_KEY"]},
        json={"query": query, "count": count},
        timeout=30,
    )
    response.raise_for_status()
    return [
        {"title": r["title"], "url": r["url"], "snippets": r.get("snippets", [])}
        for r in response.json()["results"].get("web", [])
    ]

for result in web_search("fusion energy breakthroughs"):
    print(f'{result["title"]}\n  {result["url"]}')

To restrict results by date, country, language, or domain, add request parameters such as freshness. To learn more, see Request Controls.

Answer Questions with Citations

Pass numbered search results to a Fireworks chat model as context, and instruct the model to cite the results by number. Then print the numbered sources under the answer, so that users can check each claim.

CITATION_PROMPT = (
    "Answer the question using only the numbered search results. Cite every "
    "claim inline with the number of its source, such as [1]. If the results "
    "don't contain the answer, say so."
)

def answer(question):
    sources = web_search(question)
    context = "\n\n".join(
        f'[{i}] {s["title"]} ({s["url"]})\n' + "\n".join(s["snippets"])
        for i, s in enumerate(sources, 1)
    )
    response = fireworks.chat.completions.create(
        model=CHAT_MODEL,
        messages=[
            {"role": "system", "content": CITATION_PROMPT},
            {"role": "user", "content": f"Search results:\n{context}\n\nQuestion: {question}"},
        ],
    )
    return response.choices[0].message.content, sources

text, sources = answer("What are the latest milestones in fusion energy?")
print(text)
for i, source in enumerate(sources, 1):
    print(f'[{i}] {source["url"]}')

Build a Research Agent

In the previous section, your code always runs one search with the user's question. An agent instead decides for itself when to search, what to search for, and when it has enough information to answer. It can break a complex question into several searches and compare the results.

1. Define the search tool. The model sees the tool's name, description, and parameters, and returns a tool call when it wants to search.

TOOLS = [
    {
        "type": "function",
        "function": {
            "name": "web_search",
            "description": "Search the web for current information. Returns "
            "result titles, URLs, and relevant snippets.",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {
                        "type": "string",
                        "description": "A short search query about one topic.",
                    }
                },
                "required": ["query"],
            },
        },
    }
]

2. Run the agent loop. The agent calls the model, runs any searches that the model requests, sends the results back, and repeats until the model returns a final answer.

AGENT_PROMPT = (
    "You are a research assistant. Use web_search to find current "
    "information, and run separate searches for separate topics. Cite "
    "sources inline with their URLs."
)

def run_agent(question, max_steps=8):
    messages = [
        {"role": "system", "content": AGENT_PROMPT},
        {"role": "user", "content": question},
    ]
    for _ in range(max_steps):
        response = fireworks.chat.completions.create(
            model=AGENT_MODEL, messages=messages, tools=TOOLS
        )
        message = response.choices[0].message
        messages.append(message.model_dump(exclude_none=True))

        if not message.tool_calls:
            return message.content

        for call in message.tool_calls:
            args = json.loads(call.function.arguments)
            print(f'Searching: {args["query"]}')
            messages.append(
                {
                    "role": "tool",
                    "tool_call_id": call.id,
                    "content": json.dumps(web_search(**args)),
                }
            )

    raise RuntimeError("The agent didn't finish within max_steps.")

print(run_agent("Compare the latest funding rounds of two fusion energy startups."))

Use Fireworks with LangChain

If you build with LangChain, use the langchain-youdotcom package for web search and the langchain-fireworks package for the chat model. The following example builds a retrieval chain with YouRetriever and an agent with YouSearchTool.

pip install --quiet --upgrade langchain langchain-youdotcom langchain-fireworks
from langchain.agents import create_agent
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_fireworks import ChatFireworks
from langchain_youdotcom import YouRetriever, YouSearchTool

retriever = YouRetriever(count=5)
llm = ChatFireworks(model="accounts/fireworks/models/gpt-oss-120b")

prompt = ChatPromptTemplate.from_template(
    "Answer using only these search results, and cite their URLs.\n\n"
    "{context}\n\nQuestion: {question}"
)

def format_docs(docs):
    return "\n\n".join(f'{doc.metadata["url"]}\n{doc.page_content}' for doc in docs)

chain = (
    {"context": retriever | format_docs, "question": RunnablePassthrough()}
    | prompt
    | llm
    | StrOutputParser()
)
print(chain.invoke("What are the latest milestones in fusion energy?"))

agent = create_agent(
    model=ChatFireworks(model="accounts/fireworks/models/kimi-k3"),
    tools=[YouSearchTool()],
    system_prompt="You are a research assistant. Search the web, and cite sources with their URLs.",
)
result = agent.invoke(
    {"messages": [{"role": "user", "content": "Who leads the fusion energy race, and why?"}]}
)
print(result["messages"][-1].content)

Next Steps

  • Fetch the full content of the most relevant pages with the Contents API before you answer, for questions that need more than snippets.
  • Try other Fireworks chat models by changing CHAT_MODEL or AGENT_MODEL. See the Fireworks model library.
  • Add more tools to the agent. To learn more about tool definitions, see Fireworks function calling.

Learn More

    Share Article:

  1. LI Test

  2. LI Test

Related resources.

What Is MCP Web Search? Live Results for Model Context Protocol Agents

What Is MCP Web Search? Live Results for Model Context Protocol Agents

October 12, 2026

Blog

How to Build a LlamaIndex Web Search Retriever with the You.com Web Search API

How to Build a LlamaIndex Web Search Retriever with the You.com Web Search API

October 9, 2026

Blog

How to Add a Web Search Plugin to Codex CLI with the You.com MCP Server

How to Add a Web Search Plugin to Codex CLI with the You.com MCP Server

October 8, 2026

Blog

How to Build LangGraph Integrations with the You.com Web Search API

How to Build LangGraph Integrations with the You.com Web Search API

October 7, 2026

Blog

How to Add Web Search to AutoGen Agents With the You.com MCP Server

How to Add Web Search to AutoGen Agents With the You.com MCP Server

October 2, 2026

Blog