Skip to Content
모델 사용법Claude웹 검색

Claude 웹 검색

이 페이지에서는 Claude가 web_search 도구로 웹을 검색하도록 하는 방법을 설명합니다. 모델 ID, 엔드포인트 주소, 공급자 설명은 Claude 시리즈 개요를 참고하십시오.

요점Sonnet 5.5에서 웹 검색을 사용하려면 Anthropic 네이티브 Messages API를 호출하고 Anthropic 공급자를 지정합니다. 다른 모델은 모델 페이지에서 Web Search 지원 여부를 확인하십시오.

tools에 공식 web_search 서버 도구를 추가하면 모델이 스스로 검색하고 답변에 출처를 인용합니다.

claude_web_search.py
import os import anthropic client = anthropic.Anthropic( base_url="https://api.ofox.ai/anthropic", api_key=os.environ["OFOX_API_KEY"], default_headers={"X-OfoxAI-Provider-Type": "anthropic"}, ) message = client.messages.create( model="anthropic/claude-sonnet-5.5", max_tokens=192, tools=[{"type": "web_search_20250305", "name": "web_search", "max_uses": 1, "allowed_domains": ["python.org"]}], messages=[{"role": "user", "content": "웹 검색을 한 번 사용해 python.org에서 Python 공식 다운로드 페이지를 찾고 URL만 답하십시오."}], ) print("".join(b.text for b in message.content if b.type == "text")) print("검색 횟수:", message.usage.server_tool_use.web_search_requests)
  • 응답의 content에는 server_tool_use(검색어), web_search_tool_result(검색 결과), text(답변) 블록이 순서대로 나옵니다.
  • usage.server_tool_use.web_search_requests는 실제 검색 횟수입니다. 검색은 횟수 단위로 과금되며, 단가는 모델 페이지 를 참고하십시오.
  • max_uses는 한 요청에서 검색할 수 있는 횟수를 제한합니다. 검색 결과도 입력 토큰 요금에 포함될 수 있습니다.

기타 오류는 자주 발생하는 오류를 참고하십시오.

마지막 업데이트