LLM 联网搜索
实时联网支持:突破 LLM 时效限制,让输出更准确、更可靠
我们为 OpenAI 和 Gemini 系列大模型接口带来了获取最新网络信息的能力,帮助你:
- 获取最新资讯: 无论是今日热点、最新研究还是实时数据,都能即时获取
- 消除知识盲区: 突破大模型训练数据的时间限制,获取训练后的新信息
- 降低幻觉风险: 基于实时网络搜索的事实回答,大幅减少 AI 已读乱回的可能性
- 提升决策质量: 基于最新事实的分析和建议,让你的决策更有把握
支持的模型: 目前支持 OpenAI 和 Gemini 大模型系列,包含两种接入方式:
1. 原生搜索能力模型:
Gemini 系列 (Ground with Google search):
gemini-2.0-pro-exp-02-05-searchgemini-2.0-flash-exp-searchgemini-2.0-flash-search
OpenAI 系列 (Bing search):
gpt-4o-search-previewgpt-4o-mini-search-preview
2. 参数支持方式:
只需增加参数 web_search_options={} ,即可为所有 gemini、OpenAI 大模型开启联网能力。Gemini 系列的搜索费率为 35 美元/千次;
使用方法
使用前需要运行 pip install -U openai 升级 openai 包。
- Python
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***", # 换成你在 NUWA 生成的密钥
base_url="https://api.nuwaapi.com/v1"
)
chat_completion = client.chat.completions.create(
model="gpt-4o-mini-search-preview",
# 🌐 启用搜索
web_search_options={},
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "搜索大模型 Deepseek R1 的相关资讯,简短介绍,并提供相关链接。"
}
]
}
]
)
print(chat_completion.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-***',
baseURL: 'https://api.nuwaapi.com/v1'
});
async function main() {
const chatCompletion = await client.chat.completions.create({
model: 'gpt-4o-mini-search-preview',
// 🌐 启用搜索
web_search_options: {},
messages: [
{
role: 'user',
content: [
{
type: 'text',
text: '搜索大模型 Deepseek R1 的相关资讯,简短介绍,并提供相关链接。'
}
]
}
]
});
console.log(chatCompletion.choices[0].message.content);
}
main().catch(console.error);
curl "https://api.nuwaapi.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-***" \
-d '{
"model": "gpt-4o-mini-search-preview",
"web_search_options": {},
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "搜索大模型 Deepseek R1 的相关资讯,简短介绍,并提供相关链接。"
}
]
}
],
"stream": false
}'