跳至主要內容

APISerpent 搜尋

取得 API 金鑰: https://apiserpent.com

APISerpent 是一個多引擎 SERP API(Google、Bing、Yahoo、DuckDuckGo),具有兩個端點,並可透過 deep 旗標選擇:

模式端點deep結果
快速搜尋(預設)https://apiserpent.com/api/search/quickFalsenum 1–100
深度搜尋https://apiserpent.com/api/searchTruenum 10–100

兩種模式的計費皆為每 1k 次搜尋 $0.60。

LiteLLM Python SDK

APISerpent Search
import os
from litellm import search

os.environ["APISERPENT_API_KEY"] = "your-api-key"

response = search(
query="latest AI developments",
search_provider="apiserpent",
max_results=5
)

for result in response.results:
print(f"{result.title}: {result.url}")
print(f"Snippet: {result.snippet}\n")
APISerpent Deep Search
from litellm import search

response = search(
query="open source vector databases comparison",
search_provider="apiserpent",
deep=True, # routes to /api/search
max_results=20
)

LiteLLM AI 閘道

1. 設定 config.yaml

config.yaml
model_list:
- model_name: gpt-5
litellm_params:
model: gpt-5
api_key: os.environ/OPENAI_API_KEY

search_tools:
- search_tool_name: apiserpent-search
litellm_params:
search_provider: apiserpent
api_key: os.environ/APISERPENT_API_KEY

2. 啟動 proxy

litellm --config /path/to/config.yaml

# RUNNING on http://0.0.0.0:4000

3. 測試搜尋端點

Test Request
curl http://0.0.0.0:4000/v1/search/apiserpent-search \
-H "Authorization: Bearer sk-1234" \
-H "Content-Type: application/json" \
-d '{
"query": "latest AI developments",
"max_results": 5
}'

統一參數

APISerpent 支援標準的 Perplexity 統一規格參數:

APISerpent Search with unified parameters
from litellm import search

response = search(
query="machine learning research",
search_provider="apiserpent",
max_results=10, # -> num (clamped to the endpoint range)
search_domain_filter=["arxiv.org"], # -> site: filters appended to the query
country="US" # -> country (lowercased)
)
統一規格參數對應至 APISerpent 參數
max_resultsnum(限制:快速搜尋 1–100、深度搜尋 10–100)
search_domain_filter附加至 qsite: 子句
countrycountry(轉為小寫)
max_tokens_per_page忽略(無對應項)

提供者特定參數

可將任何 APISerpent 特定參數作為關鍵字引數傳遞:

APISerpent Search with Provider-specific Parameters
import os
from litellm import search

os.environ["APISERPENT_API_KEY"] = "your-api-key"

response = search(
query="elektroauto reichweite",
search_provider="apiserpent",
max_results=10,
# APISerpent-specific parameters
engine="bing", # 'google' (default), 'bing', 'yahoo', or 'ddg'
country="de", # localized results
language="de", # 2-letter ISO language code
freshness="d", # time filter: 'h', 'd', '7d', 'w', 'm', 'y'
safe="strict", # SafeSearch: 'off', 'moderate', or 'strict'
pages=2 # pages to scrape (1-10)
)
參數類型說明
enginestringgoogle(預設)、bingyahoo、或 ddg
countrystring本地化結果的國家代碼(預設 us
languagestring2 字母 ISO 語言代碼(例如 enesde
freshnessstring時間篩選器:hd7dwmy
safestringSafeSearch:offmoderate、或 strict
pagesinteger要抓取的頁數(1–10)
formatstringfull(預設)或 simple
pixel_positionboolean包含像素座標(僅限付費方案)

num 會被限制在其有效範圍內(快速搜尋 1–100、深度搜尋 10–100),且 pages 必須為 1–10;超出範圍的值會引發 ValueError

回應說明

APISerpent 的完整格式回應會將結果巢狀放在 results.organic 下。LiteLLM adapter 會將每個自然結果的 titleurlsnippet 對應到統一的 SearchResponse 結構。

🚅
LiteLLM Enterprise
為正式環境打造的 SSO/SAML、稽核記錄、支出追蹤、多團隊管理與防護欄。
深入瞭解 →