웹 페치
웹 페치 (Web Fetch)
웹 페치 도구는 LLM이 지정된 웹 페이지와 PDF 문서에서 전체 콘텐츠를 가져올 수 있게 해줘요. 이를 통해 AI 모델이 인터넷의 실시간 정보에 접근하고 응답에 웹 콘텐츠를 통합할 수 있습니다.
웹 페치 vs 웹 검색
웹 페치는 URL을 제공한 특정 웹 페이지의 전체 콘텐츠를 가져오는 반면, 웹 검색은 쿼리에 기반한 관련 정보를 찾기 위해 인터넷 검색을 수행합니다.
| 기능 | 웹 페치 | 웹 검색 |
|---|---|---|
| 목적 | 특정 URL의 콘텐츠 가져오기 | 인터넷에서 정보 검색 |
| 입력 | 가져올 정확한 URL 제공 | 검색 쿼리/질문 제공 |
| 출력 | 지정 URL의 전체 페이지 콘텐츠 | 관련 정보가 있는 검색 결과 |
| 사용 사례 | • 특정 기사 분석 • 알려진 웹사이트의 콘텐츠 비교 • 특정 페이지에서 데이터 추출 | • 최신 뉴스/이벤트 찾기 • 주제 리서치 • 실시간 정보 얻기 |
웹 페치 예시: "Fetch the content from https://example.com/pricing and summarize it" 웹 검색 예시: "What are the latest AI developments this week?"
지원 프로바이더:
- Anthropic API (
anthropic/)
지원 도구 타입:
web_fetch_20250910- 사용량 한도, 도메인 필터링, 인용 지원이 있는 웹 콘텐츠 검색 도구
빠른 시작
LiteLLM Python SDK
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
# Web fetch tool
tools = [
{
"type": "web_fetch_20250910",
"name": "web_fetch",
"max_uses": 5,
}
]
messages = [
{
"role": "user",
"content": "Please analyze the content at https://example.com/article and summarize the main points"
}
]
response = completion(
model="anthropic/claude-sonnet-5",
messages=messages,
tools=tools,
)
print(response)
출처: 문서
본문
LiteLLM Proxy
- config.yaml에 웹 페치 모델 정의
model_list:
- model_name: claude-sonnet-5 # Anthropic claude-sonnet-5
litellm_params:
model: anthropic/claude-sonnet-5
api_key: os.environ/ANTHROPIC_API_KEY
- proxy server 실행
litellm --config config.yaml
- OpenAI Python SDK로 테스트
import os
from openai import OpenAI
client = OpenAI(
api_key="sk-<your-litellm-api-key>", # your litellm proxy api key
base_url="http://0.0.0.0:4000"
)
response = client.chat.completions.create(
model="claude-sonnet-5",
messages=[
{
"role": "user",
"content": "Please fetch and analyze the content from https://news.ycombinator.com and tell me about the top stories"
}
],
tools=[
{
"type": "web_fetch_20250910",
"name": "web_fetch",
"max_uses": 5,
}
]
)
print(response)
지원 모델
웹 페치는 다음 Anthropic API 모델에서 사용 가능합니다:
claude-opus-4-6(Claude Opus 4.6)claude-sonnet-4-6(Claude Sonnet 4.6)claude-opus-4-5(Claude Opus 4.5)claude-sonnet-4-5(Claude Sonnet 4.5)claude-haiku-4-5(Claude Haiku 4.5)claude-opus-4-1-20250805(Claude Opus 4.1)claude-opus-4-20250514(Claude Opus 4)claude-sonnet-4-20250514(Claude Sonnet 4)claude-3-7-sonnet-20250219(Claude Sonnet 3.7)claude-3-5-sonnet-latest(Claude Sonnet 3.5 v2 - deprecated)claude-3-5-haiku-latest(Claude Haiku 3.5)
웹 페치 도구는 현재 JavaScript로 동적으로 렌더링되는 웹사이트를 지원하지 않습니다.
사용 예시
기본 웹 콘텐츠 가져오기
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{
"type": "web_fetch_20250910",
"name": "web_fetch",
"max_uses": 3,
}
]
messages = [
{
"role": "user",
"content": "Fetch the latest news from https://techcrunch.com and summarize the top 3 articles"
}
]
response = completion(
model="anthropic/claude-sonnet-5",
messages=messages,
tools=tools,
)
print(response)
리서치와 분석
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{
"type": "web_fetch_20250910",
"name": "web_fetch",
"max_uses": 10,
}
]
messages = [
{
"role": "user",
"content": "Research the latest developments in AI by fetching content from multiple tech news websites and provide a comprehensive analysis"
}
]
response = completion(
model="anthropic/claude-sonnet-5",
messages=messages,
tools=tools,
)
print(response)
콘텐츠 비교
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{
"type": "web_fetch_20250910",
"name": "web_fetch",
"max_uses": 5,
}
]
messages = [
{
"role": "user",
"content": "Compare the pricing information from https://openai.com/pricing and https://anthropic.com/pricing and create a comparison table"
}
]
response = completion(
model="anthropic/claude-sonnet-5",
messages=messages,
tools=tools,
)
print(response)
여러 도구와 함께하는 고급 사용법
웹 페치를 컴퓨터 사용이나 텍스트 편집기 같은 다른 도구와 결합할 수 있어요:
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{
"type": "web_fetch_20250910",
"name": "web_fetch",
"max_uses": 5,
},
{
"type": "text_editor_20250124",
"name": "str_replace_editor"
}
]
messages = [
{
"role": "user",
"content": "Fetch the latest AI research papers from arXiv, analyze them, and create a detailed report file with your findings"
}
]
response = completion(
model="anthropic/claude-sonnet-5",
messages=messages,
tools=tools,
)
print(response)
스펙
웹 페치 도구 (web_fetch_20250910)
웹 페치 도구는 다음 파라미터를 지원합니다:
{
"type": "web_fetch_20250910",
"name": "web_fetch",
// Optional: Limit the number of fetches per request
"max_uses": 10,
// Optional: Only fetch from these domains
"allowed_domains": ["example.com", "docs.example.com"],
// Optional: Never fetch from these domains
"blocked_domains": ["private.example.com"],
// Optional: Enable citations for fetched content
"citations": {
"enabled": true
},
// Optional: Maximum content length in tokens
"max_content_tokens": 100000
}