Claude Sonnet 3.7부터 Claude는 토큰 효율적인 방식으로 도구를 호출할 수 있습니다. 요청은 평균적으로 출력 토큰을 14%, 최대 70%까지 절약하며, 이는 지연 시간도 줄여줍니다. 정확한 토큰 감소량과 지연 시간 개선은 전체 응답 형태와 크기에 따라 달라집니다.
토큰 효율적인 도구 사용은 Claude 3.7의 베타 기능입니다. 이 베타 기능을 사용하려면 도구 사용 요청에 베타 헤더 token-efficient-tools-2025-02-19를 추가하기만 하면 됩니다.모든 Claude 4 모델은 기본적으로 토큰 효율적인 도구 사용을 지원합니다. 베타 헤더가 필요하지 않지만, token-efficient-tools-2025-02-19 헤더가 API 요청을 중단시키지는 않습니다.
토큰 효율적인 도구 사용은 현재 disable_parallel_tool_use와 함께 작동하지 않습니다.
다음은 Claude Sonnet 3.7에서 API를 사용하여 토큰 효율적인 도구를 사용하는 방법의 예시입니다:
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: token-efficient-tools-2025-02-19" \
  -d '{
    "model": "claude-3-7-sonnet-20250219",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get the current weather in a given location",
        "input_schema": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. San Francisco, CA"
            }
          },
          "required": [
            "location"
          ]
        }
      }
    ],
    "messages": [
      {
        "role": "user",
        "content": "Tell me the weather in San Francisco."
      }
    ]
  }' | jq '.usage'
위의 요청은 평균적으로 일반 요청보다 더 적은 입력 및 출력 토큰을 사용해야 합니다. 이를 확인하려면 동일한 요청을 하되 베타 헤더 목록에서 token-efficient-tools-2025-02-19를 제거해 보세요.
프롬프트 캐싱의 이점을 유지하려면 캐시하려는 요청에 대해 베타 헤더를 일관되게 사용하세요. 선택적으로 사용하면 프롬프트 캐싱이 실패합니다.