DeepSeek ウェブ検索
Responses API の web_search ツールで、DeepSeek V4.1 Flash にリアルタイム情報をウェブ検索させ、出典付きで回答させます。
📝 概要
deepseek-v4.1-flash はウェブ検索に対応しています。モデルが質問に応じて検索するかどうか、どのキーワードで検索するかを自動で判断し、検索結果をもとに回答し、出典リンクを添えます。ニュース、天気、相場、試合結果など鮮度が重要な情報の取得に向いています。
ウェブ検索は Responses API(POST /v1/responses)の web_search ツールで有効にします。
利用条件
- トークンのグループ:Deepseek官转
- モデル:
deepseek-v4.1-flash - エンドポイント:
POST https://api.88api.ai/v1/responses
💡 リクエスト例
基本的な使い方 ✅
curl https://api.88api.ai/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "deepseek-v4.1-flash",
"tools": [{"type": "web_search"}],
"input": "今日の杭州の天気は?"
}'Python(OpenAI SDK) ✅
from openai import OpenAI
client = OpenAI(base_url="https://api.88api.ai/v1", api_key="sk-あなたのトークン")
resp = client.responses.create(
model="deepseek-v4.1-flash",
tools=[{"type": "web_search"}],
input="今日の杭州の天気は?",
)
print(resp.output_text)キーワード数と結果数を制限する ✅
curl https://api.88api.ai/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "deepseek-v4.1-flash",
"max_tool_calls": 2,
"tools": [{
"type": "web_search",
"max_keyword": 2,
"limit": 5,
"user_location": {"type": "approximate", "country": "中国", "region": "浙江", "city": "杭州"}
}],
"input": "今日の杭州の天気は?"
}'ストリーミング ✅
リクエストボディに "stream": true を追加します。検索のたびに次のイベントが順に返され、その後に回答テキストが出力されます。
| イベント | 意味 |
|---|---|
response.web_search_call.in_progress | 検索を開始 |
response.web_search_call.searching | 検索中 |
response.web_search_call.completed | 検索完了 |
response.output_text.delta | 回答テキスト(逐次出力) |
response.completed | すべて完了(usage を含む) |
📬 レスポンス例
抜粋です。思考過程(reasoning)などは省略しています。
{
"object": "response",
"status": "completed",
"output": [
{
"type": "web_search_call",
"id": "ws_0217925902513450000...",
"status": "completed",
"action": {
"type": "search",
"query": "杭州今天天气"
}
},
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "杭州は今朝雨がやみ、曇りに変わりました。最高気温は約 21〜24℃……",
"annotations": [
{
"type": "url_citation",
"title": "中国气象局-天气预报-城市预报",
"url": "https://weather.cma.cn/web/text/HD/AZJ.html",
"site_name": "中国气象局",
"publish_time": "2026年10月21日 08:00:00(CST) 星期三"
}
]
}
]
}
],
"usage": {
"input_tokens": 4320,
"output_tokens": 418,
"total_tokens": 4738,
"tool_usage": {"web_search": 1},
"tool_usage_details": {"web_search": {"search_engine": 1}}
}
}| フィールド | 説明 |
|---|---|
output[].type = "web_search_call" | モデルが行った 1 回の検索。action.query は使用したキーワードで、1 ラウンドで複数使った場合は ; で区切られます |
output[].type = "message" | 最終回答。本文は output_text.text |
annotations[].type = "url_citation" | 回答が引用した出典:タイトル、リンク、サイト名、公開日時 |
usage.tool_usage.web_search | このリクエストの検索回数(キーワード単位) |
⚙️ パラメータ
tools 内の web_search
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
type | string | はい | 常に web_search |
max_keyword | integer | いいえ | 1 ラウンドあたりの最大キーワード数(1〜50) |
limit | integer | いいえ | 1 回の検索で返す最大件数(1〜50、既定 10) |
user_location | object | いいえ | おおよその位置。天気や地域情報の精度が上がります。形式:{"type": "approximate", "country": "中国", "region": "浙江", "city": "杭州"} |
リクエスト全体のパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
max_tool_calls | integer | いいえ | 1 回の回答で行う検索の最大ラウンド数(1〜10、既定 3) |
stream | boolean | いいえ | ストリーミング出力 |
その他のパラメータ(input、instructions、max_output_tokens など)は OpenAI Responses と同じです。
💰 料金
料金 = モデルのトークン料金 + 検索料金
- 検索料金はキーワード数で計算:1 ラウンドで使ったキーワードの数だけカウントされ、レスポンスの
usage.tool_usage.web_searchが課金対象の回数です。モデルが検索不要と判断した場合、検索料金はかかりません。 - トークン料金:検索結果は入力としてモデルに渡されるため、入力トークンが大きく増えます(1 回の検索で通常数千トークン)。モデル料金で課金されます。
- 料金を抑えるには、
max_keywordで 1 ラウンドのキーワード数を、max_tool_callsで検索ラウンド数を制限してください。
❓ よくある質問
/v1/chat/completions でウェブ検索はできますか?
できません。ウェブ検索は /v1/responses でのみ有効です。Chat Completions に web_search ツールを渡しても検索は行われず、検索料金もかかりません。
検索されないことがあるのはなぜですか? 検索するかどうかはモデルが質問内容から判断します。最新情報が不要な質問(計算、一般知識など)にはそのまま回答します。必ず検索させたい場合は「ウェブ検索してから回答して」と明示してください。
他のグループでも使えますか?
現在は Deepseek官转 グループの deepseek-v4.1-flash のみ対応しています。