> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geekai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# 联网对话

### 原生支持搜索的模型

你可以在[模型广场](https://geekai.co/models)中通过 `联网搜索` 标签筛选查看原生支持联网对话的模型以及支持通过官方内置工具函数进行联网对话的模型。

对于模型名称带联网/搜索/深度搜索/深度研究/深度推理字样的 AI 模型原生支持联网搜索，如 GPT-5 联网版、GPT-4o 联网版、GPT-4o mini 联网版、Grok 3 深度推理版、Jina 深度搜索、DeepSeek 秘塔搜索版等，默认已经开启联网搜索，无需手动设置，可以跳过本文档：

* `gpt-5-search-api`
* `gpt-4o-search-preview`
* `gpt-4o-mini-search-preview`
* `o3-deep-research`
* `o4-mini-deep-research`
* `deepseek-search`
* `deepseek-r1-search`
* `deepseek-r1-metasearch`
* `gemini-2.5-flash-deepsearch`
* `gemini-2.5-pro-deepsearch`
* `qwen-deep-research`
* `grok-3-deepsearch`
* `sonar`
* `sonar-reasoning`
* `sonar-reasoning-pro`
* `sonar-deep-research`
* `jina-deepsearch-v1`

### 启用联网搜索

在调用对话 API 时，可以通过将 `enable_search` 参数设置为 `true` 来开启联网搜索，对于支持内置联网工具联网搜索的模型底层会自动应用，对于不支持通过内置联网工具搜索的模型，极客智坊采用第三方AI搜索引擎提供联网搜索来补充上下文实现联网对话的效果：

<CodeGroup>
  ```bash curl theme={null}
  curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
  --header 'Authorization: Bearer $GEEKAI_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "model": "gpt-5-mini",
      "messages": [
          {
              "role": "user",
              "content": "今天杭州西湖天气如何"
          }
      ],
      "enable_search": true
  }'
  ```

  ```bash python theme={null}
  # 先安装网络库 `pip3 install aiohttp asyncio`

  import aiohttp
  import asyncio
  import json

  async def invoke_geekai():
  	headers = {
  		"Authorization": "Bearer $GEEKAI_API_KEY",
  		"Content-Type": "application/json"
  	}
  	
  	body =     {
        "model": "gpt-5-mini",
        "messages": [
          {
            "role": "user",
            "content": "今天杭州西湖天气如何"
          }
        ],
        "enable_search": True,
        "stream": True
      }

  	async with aiohttp.ClientSession() as session:
  		async with session.post(
  			"https://geekai.co/v1/chat/completions", 
  			headers=headers,
  			json=body
  		) as response:
  			async for line in response.content:
  				line = line.decode("utf-8").strip()
  				if line.startswith("data: "):
  					data = line[6:]
  					if data == "[DONE]":
  						break
  					try:
  						chunk = data.strip()
  						if chunk:
  							print(chunk)
  					except Exception as e:
  						print(f"Error parsing chunk: {e}")

  asyncio.run(invoke_geekai())
  ```

  ```bash javascript theme={null}
  const response = await fetch("https://geekai.co/v1/chat/completions", {
      method: "POST",
      headers: {
          "Authorization": "Bearer $GEEKAI_API_KEY",
          "Content-Type": "application/json"
      },
      body: JSON.stringify({
          "model": "gpt-5-mini",
          "messages": [
              {
                  "role": "user",
                  "content": "今天杭州西湖天气如何"
              }
          ],
          "stream": true,
          "enable_search": true
      })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```bash go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io"
  	"net/http"
  )

  func main() {
  	requestBody := map[string]interface{}{
  		"model": "gpt-5-mini",
  		"messages": []interface{}{
              map[string]interface{}{
                  "role": "user", 
                  "content": "今天杭州西湖天气如何",
              },
          },
          "enable_search": true,
          "stream": true,
  	}
  	
  	jsonData, err := json.Marshal(requestBody)
  	if err != nil {
  		panic(err)
  	}

  	client := &http.Client{}
  	req, err := http.NewRequest("POST", "https://geekai.co/api/v1/chat/completions", bytes.NewBuffer(jsonData))
  	if err != nil {
  		panic(err)
  	}

  	req.Header.Set("Authorization", "Bearer $GEEKAI_API_KEY")
  	req.Header.Set("Content-Type", "application/json")

  	resp, err := client.Do(req)
  	if err != nil {
  		panic(err)
  	}
  	defer resp.Body.Close()

  	body, err := io.ReadAll(resp.Body)
  	if err != nil {
  		panic(err)
  	}

  	fmt.Println(string(body))
  }
  ```
</CodeGroup>

开启联网对话会会产生额外的 token 消耗，或者额外的搜索工具调用费用（按次数），对应的消耗可以在响应对象的 `usage` 字段中查看。你可以在[模型广场](https://geekai.co/models)查看原生支持搜索的模型搜索成本以及调用第三方AI搜索引擎工具的成本，也可以在[账单记录](https://geekai.co/user/transactions)查看扣费明细。

### 指定搜索引擎

如上所述，对于非原生支持联网搜索的模型，极客智坊使用第三方AI搜索引擎工具提供联网搜索来补充上下文实现联网对话的效果，默认使用的是免费的智谱搜索基础版 `glm/search_std`，你还可以通过 `search_config` 配置中的 `engine` 配置项指定使用的第三方搜索引擎：

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "deepseek-chat",
    "messages": [
        {
            "role": "user",
            "content": "今天杭州西湖天气如何"
        }
    ],
    "enable_search": true,
    "search_config": {
        "engine": "glm/search-pro",
        "return_result": true
    },
    "stream": true
}'
```

你可以在模型广场通过”搜索引擎“标签查看并选用要使用的第三方AI搜索引擎：

![极客智坊支持的AI搜索引擎](https://static.geekai.co/storage/2025/04/24/image-20250424134539455.png)

关于 `search_config` 的详细配置，请参考 [API 手册说明](https://docs.geekai.co/cn/api/chat/completions)。
