> ## Content Index
> Fetch the complete content index at: https://serpapi.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Connect Sakana AI (Fugu) with Web Search API
- URL: https://serpapi.com/blog/connect-sakana-fugu-ai-with-web-search-api/
- Published: 2026-06-30T06:40:49.000Z
- Updated: 2026-06-30T06:55:55.000Z
- Description: Learn how to connect Sakana AI’s Fugu model with Web Search API to build AI apps that can access real-time search data from Google and other search engines.
- Author: Hilman Ramadhan
- Tags: AI

Sakana AI’s Fugu introduces a new way to work with AI models: instead of relying on a single model for every task, Fugu serves as a multi-agent system that coordinates specialized AI agents via a single OpenAI-compatible API.

[Sakana Fugu — Multi-agent System as A ModelOne model to command them all![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/icon/favicon-5e749f71-84ac-47d2-bc46-a74d142758b3.ico)multi-agent system as a model![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/thumbnail/ogp-6594f53b-1244-4ed2-8dbe-97e7d5db4194.png)](https://sakana.ai/fugu/)

That makes it especially useful for workflows that need more than static model knowledge. When you connect Fugu with [Web Search API](https://serpapi.com/use-cases/web-search-api), you can give your AI application access to real-time search data from Google and other search engines, then use Fugu to reason over that data, summarize it, compare results, or generate useful outputs.

## How to use the Sakana AI API

The Sakana AI API is OpenAI-compatible. We can use it like this:

```python
import os
from openai import OpenAI

base_url = "https://api.sakana.ai/v1"

client = OpenAI(
    api_key=os.environ["FUGU_API_KEY"],
    base_url=base_url,
)

response = client.responses.create(
    model="fugu",
    input="Create a sarcastic poem for vibe coder",
)

print(response.output_text)
```

Don't forget to export your FUGU\_API\_KEY on the terminal

```
export FUGU_API_KEY=YOUR_SAKANA_FUGU_API_KEY
```

The poem result, hope no one is offended 😄

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/06/CleanShot-2026-06-30-at-13.11.58.png)

basic response API call for Sakana AI

**Streaming**  
You can also stream the results with a simple tweak

```python
with client.responses.stream(
    model="fugu",
    input="Explain why vibe coding is useful in three short bullets.",
) as stream:
    for event in stream:
        if event.type == "response.output_text.delta":
            print(event.delta, end="", flush=True)

    # Full response object assembled from the stream.
    response = stream.get_final_response()

print()
print(response.output_text)
```

### Two available models

We have two options to use as the model:

- Fugu: for balancing performance and low latency. Can be used for common problems or tasks.
- Fugu Ultra: for more complicated tasks. It will use a deeper pool of expert AI agents. It costs more and takes a longer time to finish.

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/06/CleanShot-2026-06-30-at-13.05.03.png)

Benchmark from sakana.ai website

## Give real-time data to Sakana AI

Not just the simple `completion` or `response` [built-in tools that available on OpenAI](https://developers.openai.com/api/docs/guides/tools) is also available here, except the advance options.

First, let's ask Sakana what the recent World Cup score is:

```python

response = client.responses.create(
    model="fugu",
    input="What's the recent FIFA men's world cup score?",
)

print(response.output_text)
```

Here is the result:

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/06/CleanShot-2026-06-30-at-13.26.01.png)

Sakana AI has no real-time data access

As we know, world cup 2026 is currently running in USA, clearly the AI don't have access to recent information.

### Basic Web Search tool

Let's connect with the built-in search tool

```python
response = client.responses.create(
    model="fugu",
    tools=[{"type": "web_search"}], # one line addition
    input="What's the recent FIFA men's world cup score?",
)

print(response.output_text)
```

Now, we have the update from today's match (when this blog is written)

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/06/CleanShot-2026-06-30-at-13.28.24.png)

collect real-time news on Sakana AI

### Advanced Web Search Tool

What if we ask more complicated questions that can't be answered with a simple Google search?

```python
input="What's the ticket price for this weekend from Toronto to Los Angeles? one way trip"
```

The program got stuck or just took a very long time (I waited for 3 minutes). So, I'm trying something else. Maybe if I stream it, I can get the thought process:

```python
with client.responses.stream(
    model="fugu",
    tools=[{"type": "web_search"}], 
    input="What's the recommended gift for Argentina football fans? share a link and the price",
) as stream:
    for event in stream:
        if event.type == "response.output_text.delta":
            print(event.delta, end="", flush=True)

    # Full response object assembled from the stream.
    response = stream.get_final_response()

print()
print(response.output_text)
```

Again, I don't see anything and had to wait \~3 minutes before I stopped the program

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/06/CleanShot-2026-06-30-at-13.45.05.png)

Sakana AI error on hard question that need real-time data

**The issue and the solution**  
Similar to the OpenAI native web search tool, there are still some limitations. To solve this issue, we can connect the AI with [SerpApi - search engine APIs](https://serpapi.com/search-engine-apis). 

**Sample project**  
I'm going to ask the AI to return a recommended items alongside real time pricing and shopping link.

Sample usage:

```python
query = "What's a good gaming laptop under $1000?"
run_shopping_assistant(query)
```

Sample result:

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/06/CleanShot-2026-06-30-at-14.33.57.png)

Sample result when Sakana AI has access to live e-commerce data

**Preparation**

1. Ensure you register at [serpapi.com](https://serpapi.com/) to get your free API key.
2. Understand the basics of function calling on OpenAI, as we'll build a custom function to call an API

[Function calling | OpenAI APILearn how function calling enables large language models to connect to external data and systems.![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/icon/favicon-cebe74b4-8322-448b-a610-36ca6ae22e64.png)OpenAI API![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/thumbnail/function-calling-788683c5-cde5-410b-bf7e-047c7ebc7ebe.png)](https://developers.openai.com/api/docs/guides/function-calling)

  
If you want to try it directly, here is the source code link:

[tutorials/python\_projects/sakana-fugu-web-search at master · serpapi/tutorialsPublic repo to store our blog and video demo code snippets - serpapi/tutorials![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/icon/pinned-octocat-093da3e6fa40-0186e17a-88d6-4a54-b941-65642ee072ec.svg)GitHubserpapi![](https://opengraph.githubassets.com/614632a8a97a32851249ff50473c4de9fa5b3e07ad10c8210d18ee47b444198d/serpapi/tutorials)](https://github.com/serpapi/tutorials/tree/master/python%5Fprojects/sakana-fugu-web-search)

**Code implementation**

1. First, let's load everything: OpenAI API key, SerpApi API Key, and the required packages

```python
import os
import json
import requests
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

base_url = "https://api.sakana.ai/v1"

client = OpenAI(
    api_key=os.environ.get("FUGU_API_KEY"),
    base_url=base_url,
)

SERPAPI_API_KEY = os.environ.get("SERPAPI_API_KEY")

```

1. Define the tool structure we're going to use

```python
tools = [
    {
        "type": "function",
        "name": "google_shopping_search",
        "description": "Search for products on Google Shopping using SerpApi",
        "parameters": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The product search query"
                },
            },
            "required": ["query"],
            "additionalProperties": False,
        },
        "strict": True,
    }
]
```

We can add more if we need to access multiple APIs.

1. Define the actual search function  
Now, we're going to call the API, in this case, the Google Shopping API

```python
def google_shopping_search(query):
    """
    Simple Google Shopping search using SerpApi
    """
    print("🔎 Checking SerpApi key...", flush=True)
    if not SERPAPI_API_KEY:
        return {
            "success": False,
            "error": "Missing SERPAPI_API_KEY environment variable",
            "query": query
        }

    print(f"🌐 Requesting Google Shopping results from SerpApi for: {query}", flush=True)
    params = {
        "api_key": SERPAPI_API_KEY,
        "engine": "google_shopping",
        "q": query,
    }
    
    try:
        response = requests.get("https://serpapi.com/search", params=params, timeout=30)
        print(f"🌐 SerpApi responded with HTTP {response.status_code}", flush=True)
        response.raise_for_status()
        print("📦 Parsing SerpApi response JSON...", flush=True)
        data = response.json()
        
        shopping_results = data.get("shopping_results", [])
        
        # Format results
        formatted_results = []
        for item in shopping_results[:5]:
            formatted_item = {
                "title": item.get("title", ""),
                "price": item.get("price", "N/A"),
                "link": item.get("product_link", ""),
                "source": item.get("source", ""),
                "rating": item.get("rating", "N/A"),
                "reviews": item.get("reviews", 0),
            }
            formatted_results.append(formatted_item)
        
        return {
            "success": True,
            "query": query,
            "results": formatted_results,
            "total_results": len(shopping_results)
        }
        
    except requests.exceptions.RequestException as e:
        return {
            "success": False,
            "error": f"API Error: {str(e)}",
            "query": query
        }

```

In this example, I'm getting the first 5 items from the [Google Shopping API](https://serpapi.com/google-shopping-api) response.

1. Helper function

To maintain the readability of the code, let's break down some helper functions. First, to help us see the results in a readable format. You can skip this if you don't need it on your terminal:

```python
def print_shopping_results(result):
    """
    Print SerpApi shopping results in a readable format.
    """
    if result["success"]:
        print(f"📊 Found {result['total_results']} products:\n")
        for i, item in enumerate(result["results"], 1):
            print(f"{i}. {item['title']}")
            print(f"   Price: {item['price']}")
            print(f"   Source: {item['source']}")
            if item["rating"] != "N/A":
                print(f"   Rating: {item['rating']} ⭐ ({item['reviews']} reviews)")
            print(f"   Link: {item['link']}\n")
    else:
        print(f"   Error: {result['error']}\n")
```

Next, to send the actual request to Fugu:

```python
def create_response(input_data):
    """
    Create a non-streaming Fugu response.
    """
    print("🤖 Sending request to Fugu...", flush=True)
    return client.responses.create(
        model="fugu",
        tools=tools,
        input=input_data,
    )
```

Last one, to handle the tool call:

```python
def handle_tool_call(tool_call):
    """
    Execute a Responses API function_call item.
    """
    if tool_call.name != "google_shopping_search":
        result = {
            "success": False,
            "error": f"Unknown tool: {tool_call.name}",
        }
    else:
        try:
            tool_input = json.loads(tool_call.arguments or "{}")
        except json.JSONDecodeError as e:
            tool_input = {}
            result = {
                "success": False,
                "error": f"Invalid tool arguments: {e}",
            }
        else:
            print(f"\n🔧 Calling function: {tool_call.name}")
            print(f"   Query: {tool_input.get('query')}\n")
            result = google_shopping_search(tool_input["query"])
            print_shopping_results(result)

    if not result.get("success"):
        raise RuntimeError(result.get("error", "Tool call failed"))

    return {
        "type": "function_call_output",
        "call_id": tool_call.call_id,
        "output": json.dumps(result),
```

1. Running the program

Now, is the actual function that triggers the whole thing:

```python
def run_shopping_assistant(user_query):
    """
    Run the shopping assistant with Sakana AI Fugu
    """
    if not os.environ.get("FUGU_API_KEY"):
        raise RuntimeError("Missing FUGU_API_KEY environment variable")

    print(f"User: {user_query}\n")

    input_messages = [
        {"role": "user", "content": user_query}
    ]

    print("🧠 Asking Fugu whether a tool is needed...", flush=True)
    response = create_response(input_messages)
    print("✅ Fugu response received.", flush=True)

    max_iterations = 5
    for iteration in range(1, max_iterations + 1):
        print(f"🔁 Processing response step {iteration}/{max_iterations}...", flush=True)

        if response.output_text:
            print(response.output_text)
            print()

        input_messages += response.output

        tool_calls = [
            item for item in response.output
            if getattr(item, "type", None) == "function_call"
        ]

        if not tool_calls:
            print("✅ No tool calls requested. Done.", flush=True)
            return response.output_text

        print(f"🛠️ Fugu requested {len(tool_calls)} tool call(s).", flush=True)
        tool_outputs = [handle_tool_call(tool_call) for tool_call in tool_calls]
        input_messages += tool_outputs

        print("🤖 Recommendation:\n")
        print("🧠 Sending tool results back to Fugu...", flush=True)
        response = create_response(input_messages)
        print("✅ Fugu follow-up response received.", flush=True)

    raise RuntimeError("Reached maximum tool-calling iterations")

# Example usage
if __name__ == "__main__":
    try:
        # Example 1
        query1 = "What's a good gaming laptop under $1000?"
        run_shopping_assistant(query1)
    except RuntimeError as e:
        print(f"❌ Error: {e}")
        print("\nMake sure you have a .env file with:")
        print("  FUGU_API_KEY=...")
        print("  SERPAPI_API_KEY=...")

```

That's it. 

## Use Sakana AI for Coding

Want to use Fugu, the new Sakana AI model, as your coding partner? Here is an example from our Vibe Coding series on YouTube:

Here is [the official guideline on using Sakana in Codex](https://console.sakana.ai/get-started).

## FAQ on Sakana AI

Some frequently asked questions:  
  
**Why is Sakana AI popular?**  
Sakana AI is popular because it takes a different approach to AI by focusing on systems that can combine and coordinate multiple models. Its Fugu model is especially interesting because it works through an OpenAI-compatible API and can orchestrate specialized AI agents for more complex tasks.

**Is Sakana AI - Fugu model free?**  
It's not free. Fugu is available through paid subscription and pay-as-you-go plans, so you’ll need to check the Sakana AI Console for the latest pricing, available models, and usage limits.

**How to use Sakana AI?**  
To use Sakana AI, sign in to the Sakana AI Console and connect to it using its OpenAI-compatible API. You can also combine it with SerpApi to give your AI app access to real-time search data from Google and other search engines.  
  
If you want to use it as your coding partner, you can install `codex-fugu` to use it just like codex CLI.