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
    도구

    세밀한 도구 스트리밍

    도구 사용에서 매개변수 값에 대한 세밀한 스트리밍을 지원하여 대용량 매개변수 수신 시작 지연 시간을 줄입니다.

    도구 사용이 이제 매개변수 값에 대한 세밀한 스트리밍을 지원합니다. 이를 통해 개발자는 버퍼링/JSON 검증 없이 도구 사용 매개변수를 스트리밍할 수 있어 대용량 매개변수 수신을 시작하는 지연 시간을 줄일 수 있습니다.

    세밀한 도구 스트리밍은 베타 기능입니다. 프로덕션에서 사용하기 전에 응답을 평가해 주시기 바랍니다.

    모델 응답의 품질, API 자체, 또는 문서의 품질에 대한 피드백을 제공하려면 이 양식을 사용해 주세요. 여러분의 의견을 듣기를 기대합니다!

    세밀한 도구 스트리밍을 사용할 때 잠재적으로 유효하지 않거나 부분적인 JSON 입력을 받을 수 있습니다. 코드에서 이러한 예외 상황을 고려해 주시기 바랍니다.

    세밀한 도구 스트리밍 사용 방법

    이 베타 기능을 사용하려면 도구 사용 요청에 베타 헤더 fine-grained-tool-streaming-2025-05-14를 추가하고 스트리밍을 켜기만 하면 됩니다.

    다음은 API와 함께 세밀한 도구 스트리밍을 사용하는 방법의 예시입니다:

    Shell
    curl https://api.anthropic.com/v1/messages \
      -H "content-type: application/json" \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "anthropic-beta: fine-grained-tool-streaming-2025-05-14" \
      -d '{
        "model": "claude-sonnet-4-5",
        "max_tokens": 65536,
        "tools": [
          {
            "name": "make_file",
            "description": "Write text to a file",
            "input_schema": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string",
                  "description": "The filename to write text to"
                },
                "lines_of_text": {
                  "type": "array",
                  "description": "An array of lines of text to write to the file"
                }
              },
              "required": ["filename", "lines_of_text"]
            }
          }
        ],
        "messages": [
          {
            "role": "user",
            "content": "Can you write a long poem and make a file called poem.txt?"
          }
        ],
        "stream": true
      }' | jq '.usage'
    Python
    import anthropic
    
    client = anthropic.Anthropic()
    
    response = client.beta.messages.stream(
        max_tokens=65536,
        model="claude-sonnet-4-5",
        tools=[{
          "name": "make_file",
          "description": "Write text to a file",
          "input_schema": {
            "type": "object",
            "properties": {
              "filename": {
                "type": "string",
                "description": "The filename to write text to"
              },
              "lines_of_text": {
                "type": "array",
                "description": "An array of lines of text to write to the file"
              }
            },
            "required": ["filename", "lines_of_text"]
          }
        }],
        messages=[{
          "role": "user",
          "content": "Can you write a long poem and make a file called poem.txt?"
        }],
        betas=["fine-grained-tool-streaming-2025-05-14"]
    )
    
    print(response.usage)
    TypeScript
    import Anthropic from '@anthropic-ai/sdk';
    
    const anthropic = new Anthropic();
    
    const message = await anthropic.beta.messages.stream({
      model: "claude-sonnet-4-5",
      max_tokens: 65536,
      tools: [{
        "name": "make_file",
        "description": "Write text to a file",
        "input_schema": {
          "type": "object",
          "properties": {
            "filename": {
              "type": "string",
              "description": "The filename to write text to"
            },
            "lines_of_text": {
              "type": "array",
              "description": "An array of lines of text to write to the file"
            }
          },
          "required": ["filename", "lines_of_text"]
        }
      }],
      messages: [{ 
        role: "user", 
        content: "Can you write a long poem and make a file called poem.txt?" 
      }],
      betas: ["fine-grained-tool-streaming-2025-05-14"]
    });
    
    console.log(message.usage);

    이 예시에서 세밀한 도구 스트리밍은 Claude가 lines_of_text 매개변수가 유효한 JSON인지 검증하기 위해 버퍼링하지 않고 긴 시의 줄들을 도구 호출 make_file로 스트리밍할 수 있게 합니다. 이는 전체 매개변수가 버퍼링되고 검증될 때까지 기다릴 필요 없이 매개변수가 도착하는 대로 스트림을 볼 수 있음을 의미합니다.

    세밀한 도구 스트리밍을 사용하면 도구 사용 청크가 더 빠르게 스트리밍을 시작하며, 종종 더 길고 단어 구분이 적습니다. 이는 청킹 동작의 차이 때문입니다.

    예시:

    세밀한 스트리밍 없이 (15초 지연):

    청크 1: '{"'
    청크 2: 'query": "Ty'
    청크 3: 'peScri'
    청크 4: 'pt 5.0 5.1 '
    청크 5: '5.2 5'
    청크 6: '.3'
    청크 8: ' new f'
    청크 9: 'eatur'
    ...

    세밀한 스트리밍과 함께 (3초 지연):

    청크 1: '{"query": "TypeScript 5.0 5.1 5.2 5.3'
    청크 2: ' new features comparison'

    세밀한 스트리밍은 버퍼링이나 JSON 검증 없이 매개변수를 전송하기 때문에 결과 스트림이 유효한 JSON 문자열로 완료된다는 보장이 없습니다. 특히 중지 이유 max_tokens에 도달하면 스트림이 매개변수 중간에 끝날 수 있으며 불완전할 수 있습니다. 일반적으로 max_tokens에 도달했을 때를 처리하기 위한 특별한 지원을 작성해야 합니다.

    도구 응답에서 유효하지 않은 JSON 처리

    세밀한 도구 스트리밍을 사용할 때 모델로부터 유효하지 않거나 불완전한 JSON을 받을 수 있습니다. 이 유효하지 않은 JSON을 오류 응답 블록에서 모델에 다시 전달해야 하는 경우, 적절한 처리를 보장하기 위해 JSON 객체로 감쌀 수 있습니다(합리적인 키와 함께). 예를 들어:

    {
      "INVALID_JSON": "<your invalid json string>"
    }

    이 접근 방식은 모델이 콘텐츠가 유효하지 않은 JSON임을 이해하도록 도우면서 디버깅 목적으로 원본 잘못된 형식의 데이터를 보존합니다.

    유효하지 않은 JSON을 감쌀 때 래퍼 객체에서 유효한 JSON 구조를 유지하기 위해 유효하지 않은 JSON 문자열의 따옴표나 특수 문자를 적절히 이스케이프해야 합니다.

    • 도구 응답에서 유효하지 않은 JSON 처리
    © 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