Loading...
    • 개발자 가이드
    • API 참고자료
    • MCP
    • 리소스
    • 릴리스 노트
    Search...
    ⌘K

    첫 번째 단계

    Claude 소개빠른 시작

    모델 및 가격

    모델 개요모델 선택하기Claude 4.5의 새로운 기능Claude 4.5로 마이그레이션모델 지원 중단가격 정책

    Claude로 빌드하기

    기능 개요Messages API 작업컨텍스트 윈도우프롬프트 작성 모범 사례

    기능

    프롬프트 캐싱컨텍스트 편집확장된 사고스트리밍 메시지배치 처리인용다국어 지원토큰 카운팅임베딩비전PDF 지원Files API검색 결과Google Sheets 애드온

    도구

    개요도구 사용을 구현하는 방법토큰 효율적인 도구 사용세밀한 도구 스트리밍Bash 도구코드 실행 도구컴퓨터 사용 도구텍스트 편집기 도구웹 페치 도구웹 검색 도구메모리 도구

    에이전트 스킬

    개요빠른 시작Skill 작성 모범 사례Skills 사용하기

    Agent SDK

    개요Agent SDK 참조 - TypeScriptPython SDK

    가이드

    스트리밍 입력권한 처리세션 관리Agent SDK 호스팅시스템 프롬프트 수정하기SDK에서의 MCP사용자 정의 도구SDK의 서브에이전트SDK의 슬래시 명령어SDK의 에이전트 스킬비용 및 사용량 추적할 일 목록SDK의 플러그인

    API의 MCP

    MCP 커넥터원격 MCP 서버

    타사 플랫폼의 Claude

    Amazon BedrockVertex AI

    프롬프트 엔지니어링

    개요프롬프트 생성기프롬프트 템플릿 사용하기프롬프트 개선기명확하고 직접적으로예시(멀티샷 프롬프팅) 사용Claude가 생각하도록 하기(CoT)XML 태그 사용Claude에게 역할 부여하기 (시스템 프롬프트)Claude의 응답 미리 채우기복잡한 프롬프트 체이닝긴 컨텍스트 팁확장 사고 팁

    테스트 및 평가

    성공 기준 정의하기테스트 케이스 개발평가 도구 사용하기지연 시간 줄이기

    보안 강화

    환각 현상 줄이기출력 일관성 높이기탈옥 완화handle-streaming-refusals프롬프트 유출 감소Claude의 캐릭터 유지

    관리 및 모니터링

    Admin API 개요사용량 및 비용 APIClaude Code Analytics API
    Console
    기능

    검색 결과

    검색 결과와 출처 속성을 제공하여 RAG 애플리케이션에 대한 자연스러운 인용을 활성화합니다

    검색 결과 콘텐츠 블록은 적절한 출처 속성을 통해 자연스러운 인용을 활성화하여 웹 검색 품질의 인용을 사용자 정의 애플리케이션에 제공합니다. 이 기능은 Claude가 출처를 정확하게 인용해야 하는 RAG(검색 증강 생성) 애플리케이션에서 특히 강력합니다.

    검색 결과 기능은 다음 모델에서 사용 가능합니다:

    • Claude Opus 4.1 (claude-opus-4-1-20250805)
    • Claude Opus 4 (claude-opus-4-20250514)
    • Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)
    • Claude Sonnet 4 (claude-sonnet-4-20250514)
    • Claude Sonnet 3.7 (deprecated) (claude-3-7-sonnet-20250219)
    • Claude 3.5 Haiku (claude-3-5-haiku-20241022)

    주요 이점

    • 자연스러운 인용 - 모든 콘텐츠에 대해 웹 검색과 동일한 인용 품질 달성
    • 유연한 통합 - 동적 RAG를 위한 도구 반환 또는 미리 가져온 데이터를 위한 최상위 콘텐츠로 사용
    • 적절한 출처 속성 - 각 결과에는 명확한 속성을 위한 출처 및 제목 정보 포함
    • 문서 해결 방법 불필요 - 문서 기반 해결 방법의 필요성 제거
    • 일관된 인용 형식 - Claude의 웹 검색 기능의 인용 품질 및 형식과 일치

    작동 방식

    검색 결과는 두 가지 방법으로 제공될 수 있습니다:

    1. 도구 호출에서 - 사용자 정의 도구가 검색 결과를 반환하여 동적 RAG 애플리케이션 활성화
    2. 최상위 콘텐츠로 - 미리 가져온 또는 캐시된 콘텐츠를 위해 사용자 메시지에 검색 결과를 직접 제공

    두 경우 모두 Claude는 적절한 출처 속성을 통해 검색 결과의 정보를 자동으로 인용할 수 있습니다.

    검색 결과 스키마

    검색 결과는 다음 구조를 사용합니다:

    {
      "type": "search_result",
      "source": "https://example.com/article",  // 필수: 출처 URL 또는 식별자
      "title": "Article Title",                  // 필수: 결과의 제목
      "content": [ // 필수: 텍스트 블록의 배열
        {
          "type": "text",
          "text": "The actual content of the search result..."
        }
      ],
      "citations": {                             // 선택사항: 인용 구성
        "enabled": true                          // 이 결과에 대한 인용 활성화/비활성화
      }
    }

    필수 필드

    필드유형설명
    typestring"search_result"이어야 함
    sourcestring콘텐츠의 출처 URL 또는 식별자
    titlestring검색 결과의 설명적 제목
    contentarray실제 콘텐츠를 포함하는 텍스트 블록의 배열

    선택사항 필드

    필드유형설명
    citationsobjectenabled 부울 필드가 있는 인용 구성
    cache_controlobject캐시 제어 설정 (예: {"type": "ephemeral"})

    content 배열의 각 항목은 다음을 포함하는 텍스트 블록이어야 합니다:

    • type: "text"이어야 함
    • text: 실제 텍스트 콘텐츠 (비어있지 않은 문자열)

    방법 1: 도구 호출에서 검색 결과

    가장 강력한 사용 사례는 사용자 정의 도구에서 검색 결과를 반환하는 것입니다. 이를 통해 도구가 자동 인용으로 관련 콘텐츠를 가져오고 반환하는 동적 RAG 애플리케이션을 활성화합니다.

    예제: 지식 기반 도구

    from anthropic import Anthropic
    from anthropic.types import (
        MessageParam,
        TextBlockParam,
        SearchResultBlockParam,
        ToolResultBlockParam
    )
    
    client = Anthropic()
    
    # Define a knowledge base search tool
    knowledge_base_tool = {
        "name": "search_knowledge_base",
        "description": "Search the company knowledge base for information",
        "input_schema": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The search query"
                }
            },
            "required": ["query"]
        }
    }
    
    # Function to handle the tool call
    def search_knowledge_base(query):
        # Your search logic here
        # Returns search results in the correct format
        return [
            SearchResultBlockParam(
                type="search_result",
                source="https://docs.company.com/product-guide",
                title="Product Configuration Guide",
                content=[
                    TextBlockParam(
                        type="text",
                        text="To configure the product, navigate to Settings > Configuration. The default timeout is 30 seconds, but can be adjusted between 10-120 seconds based on your needs."
                    )
                ],
                citations={"enabled": True}
            ),
            SearchResultBlockParam(
                type="search_result",
                source="https://docs.company.com/troubleshooting",
                title="Troubleshooting Guide",
                content=[
                    TextBlockParam(
                        type="text",
                        text="If you encounter timeout errors, first check the configuration settings. Common causes include network latency and incorrect timeout values."
                    )
                ],
                citations={"enabled": True}
            )
        ]
    
    # Create a message with the tool
    response = client.messages.create(
        model="claude-sonnet-4-5",  # Works with all supported models
        max_tokens=1024,
        tools=[knowledge_base_tool],
        messages=[
            MessageParam(
                role="user",
                content="How do I configure the timeout settings?"
            )
        ]
    )
    
    # When Claude calls the tool, provide the search results
    if response.content[0].type == "tool_use":
        tool_result = search_knowledge_base(response.content[0].input["query"])
        
        # Send the tool result back
        final_response = client.messages.create(
            model="claude-sonnet-4-5",  # Works with all supported models
            max_tokens=1024,
            messages=[
                MessageParam(role="user", content="How do I configure the timeout settings?"),
                MessageParam(role="assistant", content=response.content),
                MessageParam(
                    role="user",
                    content=[
                        ToolResultBlockParam(
                            type="tool_result",
                            tool_use_id=response.content[0].id,
                            content=tool_result  # Search results go here
                        )
                    ]
                )
            ]
        )

    방법 2: 최상위 콘텐츠로 검색 결과

    사용자 메시지에 검색 결과를 직접 제공할 수도 있습니다. 이는 다음의 경우에 유용합니다:

    • 검색 인프라에서 미리 가져온 콘텐츠
    • 이전 쿼리의 캐시된 검색 결과
    • 외부 검색 서비스의 콘텐츠
    • 테스트 및 개발

    예제: 직접 검색 결과

    from anthropic import Anthropic
    from anthropic.types import (
        MessageParam,
        TextBlockParam,
        SearchResultBlockParam
    )
    
    client = Anthropic()
    
    # Provide search results directly in the user message
    response = client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=1024,
        messages=[
            MessageParam(
                role="user",
                content=[
                    SearchResultBlockParam(
                        type="search_result",
                        source="https://docs.company.com/api-reference",
                        title="API Reference - Authentication",
                        content=[
                            TextBlockParam(
                                type="text",
                                text="All API requests must include an API key in the Authorization header. Keys can be generated from the dashboard. Rate limits: 1000 requests per hour for standard tier, 10000 for premium."
                            )
                        ],
                        citations={"enabled": True}
                    ),
                    SearchResultBlockParam(
                        type="search_result",
                        source="https://docs.company.com/quickstart",
                        title="Getting Started Guide",
                        content=[
                            TextBlockParam(
                                type="text",
                                text="To get started: 1) Sign up for an account, 2) Generate an API key from the dashboard, 3) Install our SDK using pip install company-sdk, 4) Initialize the client with your API key."
                            )
                        ],
                        citations={"enabled": True}
                    ),
                    TextBlockParam(
                        type="text",
                        text="Based on these search results, how do I authenticate API requests and what are the rate limits?"
                    )
                ]
            )
        ]
    )
    
    print(response.model_dump_json(indent=2))

    Claude의 인용이 포함된 응답

    검색 결과가 제공되는 방식과 관계없이 Claude는 검색 결과의 정보를 사용할 때 자동으로 인용을 포함합니다:

    {
      "role": "assistant",
      "content": [
        {
          "type": "text",
          "text": "To authenticate API requests, you need to include an API key in the Authorization header",
          "citations": [
            {
              "type": "search_result_location",
              "source": "https://docs.company.com/api-reference",
              "title": "API Reference - Authentication",
              "cited_text": "All API requests must include an API key in the Authorization header",
              "search_result_index": 0,
              "start_block_index": 0,
              "end_block_index": 0
            }
          ]
        },
        {
          "type": "text",
          "text": ". You can generate API keys from your dashboard",
          "citations": [
            {
              "type": "search_result_location",
              "source": "https://docs.company.com/api-reference",
              "title": "API Reference - Authentication",
              "cited_text": "Keys can be generated from the dashboard",
              "search_result_index": 0,
              "start_block_index": 0,
              "end_block_index": 0
            }
          ]
        },
        {
          "type": "text",
          "text": ". The rate limits are 1,000 requests per hour for the standard tier and 10,000 requests per hour for the premium tier.",
          "citations": [
            {
              "type": "search_result_location",
              "source": "https://docs.company.com/api-reference",
              "title": "API Reference - Authentication",
              "cited_text": "Rate limits: 1000 requests per hour for standard tier, 10000 for premium",
              "search_result_index": 0,
              "start_block_index": 0,
              "end_block_index": 0
            }
          ]
        }
      ]
    }

    인용 필드

    각 인용에는 다음이 포함됩니다:

    필드유형설명
    typestring검색 결과 인용의 경우 항상 "search_result_location"
    sourcestring원본 검색 결과의 출처
    titlestring or null원본 검색 결과의 제목
    cited_textstring인용되는 정확한 텍스트
    search_result_indexinteger검색 결과의 인덱스 (0 기반)
    start_block_indexinteger콘텐츠 배열의 시작 위치
    end_block_indexinteger콘텐츠 배열의 끝 위치

    참고: search_result_index는 검색 결과가 제공되는 방식(도구 호출 또는 최상위 콘텐츠)과 관계없이 검색 결과 콘텐츠 블록의 인덱스(0 기반)를 나타냅니다.

    여러 콘텐츠 블록

    검색 결과는 content 배열에 여러 텍스트 블록을 포함할 수 있습니다:

    {
      "type": "search_result",
      "source": "https://docs.company.com/api-guide",
      "title": "API Documentation",
      "content": [
        {
          "type": "text",
          "text": "Authentication: All API requests require an API key."
        },
        {
          "type": "text",
          "text": "Rate Limits: The API allows 1000 requests per hour per key."
        },
        {
          "type": "text",
          "text": "Error Handling: The API returns standard HTTP status codes."
        }
      ]
    }

    Claude는 start_block_index 및 end_block_index 필드를 사용하여 특정 블록을 인용할 수 있습니다.

    고급 사용법

    두 방법 결합

    동일한 대화에서 도구 기반 및 최상위 검색 결과를 모두 사용할 수 있습니다:

    # First message with top-level search results
    messages = [
        MessageParam(
            role="user",
            content=[
                SearchResultBlockParam(
                    type="search_result",
                    source="https://docs.company.com/overview",
                    title="Product Overview",
                    content=[
                        TextBlockParam(type="text", text="Our product helps teams collaborate...")
                    ],
                    citations={"enabled": True}
                ),
                TextBlockParam(
                    type="text",
                    text="Tell me about this product and search for pricing information"
                )
            ]
        )
    ]
    
    # Claude might respond and call a tool to search for pricing
    # Then you provide tool results with more search results

    다른 콘텐츠 유형과 결합

    두 방법 모두 검색 결과를 다른 콘텐츠와 혼합하는 것을 지원합니다:

    # In tool results
    tool_result = [
        SearchResultBlockParam(
            type="search_result",
            source="https://docs.company.com/guide",
            title="User Guide",
            content=[TextBlockParam(type="text", text="Configuration details...")],
            citations={"enabled": True}
        ),
        TextBlockParam(
            type="text",
            text="Additional context: This applies to version 2.0 and later."
        )
    ]
    
    # In top-level content
    user_content = [
        SearchResultBlockParam(
            type="search_result",
            source="https://research.com/paper",
            title="Research Paper",
            content=[TextBlockParam(type="text", text="Key findings...")],
            citations={"enabled": True}
        ),
        {
            "type": "image",
            "source": {"type": "url", "url": "https://example.com/chart.png"}
        },
        TextBlockParam(
            type="text",
            text="How does the chart relate to the research findings?"
        )
    ]

    캐시 제어

    더 나은 성능을 위해 캐시 제어를 추가합니다:

    {
      "type": "search_result",
      "source": "https://docs.company.com/guide",
      "title": "User Guide",
      "content": [{"type": "text", "text": "..."}],
      "cache_control": {
        "type": "ephemeral"
      }
    }

    인용 제어

    기본적으로 검색 결과에 대해 인용이 비활성화됩니다. citations 구성을 명시적으로 설정하여 인용을 활성화할 수 있습니다:

    {
      "type": "search_result",
      "source": "https://docs.company.com/guide",
      "title": "User Guide",
      "content": [{"type": "text", "text": "Important documentation..."}],
      "citations": {
        "enabled": true  // Enable citations for this result
      }
    }

    citations.enabled가 true로 설정되면 Claude는 검색 결과의 정보를 사용할 때 인용 참조를 포함합니다. 이를 통해 다음이 가능합니다:

    • 사용자 정의 RAG 애플리케이션에 대한 자연스러운 인용
    • 독점 지식 기반과 인터페이싱할 때 출처 속성
    • 검색 결과를 반환하는 모든 사용자 정의 도구에 대한 웹 검색 품질의 인용

    citations 필드를 생략하면 기본적으로 인용이 비활성화됩니다.

    인용은 모두 또는 아무것도 아닙니다: 요청의 모든 검색 결과에 인용이 활성화되거나 모두 비활성화되어야 합니다. 다른 인용 설정을 가진 검색 결과를 혼합하면 오류가 발생합니다. 일부 출처에 대해 인용을 비활성화해야 하는 경우 해당 요청의 모든 검색 결과에 대해 인용을 비활성화해야 합니다.

    모범 사례

    도구 기반 검색의 경우 (방법 1)

    • 동적 콘텐츠: 실시간 검색 및 동적 RAG 애플리케이션에 사용
    • 오류 처리: 검색 실패 시 적절한 메시지 반환
    • 결과 제한: 컨텍스트 오버플로우를 피하기 위해 가장 관련성 높은 결과만 반환

    최상위 검색의 경우 (방법 2)

    • 미리 가져온 콘텐츠: 이미 검색 결과가 있을 때 사용
    • 배치 처리: 여러 검색 결과를 한 번에 처리하기에 이상적
    • 테스트: 알려진 콘텐츠로 인용 동작을 테스트하기에 좋음

    일반 모범 사례

    1. 결과를 효과적으로 구조화

      • 명확하고 영구적인 출처 URL 사용
      • 설명적인 제목 제공
      • 긴 콘텐츠를 논리적 텍스트 블록으로 분할
    2. 일관성 유지

      • 애플리케이션 전체에서 일관된 출처 형식 사용
      • 제목이 콘텐츠를 정확하게 반영하는지 확인
      • 형식 일관성 유지
    3. 오류를 우아하게 처리

      def search_with_fallback(query):
          try:
              results = perform_search(query)
              if not results:
                  return {"type": "text", "text": "No results found."}
              return format_as_search_results(results)
          except Exception as e:
              return {"type": "text", "text": f"Search error: {str(e)}"}

    제한사항

    • 검색 결과 콘텐츠 블록은 Claude API 및 Google Cloud의 Vertex AI에서 사용 가능
    • 검색 결과 내에서는 텍스트 콘텐츠만 지원됨 (이미지 또는 기타 미디어 없음)
    • content 배열은 최소 하나의 텍스트 블록을 포함해야 함
    • 방법 1: 도구 호출에서 검색 결과
    • 방법 2: 최상위 콘텐츠로 검색 결과
    • Claude의 인용이 포함된 응답
    • 도구 기반 검색의 경우 (방법 1)
    • 최상위 검색의 경우 (방법 2)
    © 2025 ANTHROPIC PBC

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    © 2025 ANTHROPIC PBC