확장 사고는 Claude에게 복잡한 작업에 대한 향상된 추론 능력을 제공하며, 최종 답변을 전달하기 전에 단계별 사고 과정에 대한 다양한 수준의 투명성을 제공합니다.
Claude Opus 4.6의 경우, 이 페이지에 설명된 수동 사고 모드 대신 effort 파라미터와 함께 적응형 사고 (thinking: {type: "adaptive"})를 사용하는 것을 권장합니다. 수동 thinking: {type: "enabled", budget_tokens: N} 구성은 Opus 4.6에서 더 이상 사용되지 않으며 향후 모델 릴리스에서 제거될 예정입니다.
확장 사고는 다음 모델에서 지원됩니다:
claude-opus-4-6) — 적응형 사고 권장; 수동 모드 (type: "enabled")는 더 이상 사용되지 않음claude-opus-4-5-20251101)claude-opus-4-1-20250805)claude-opus-4-20250514)claude-sonnet-4-5-20250929)claude-sonnet-4-20250514)claude-3-7-sonnet-20250219) (지원 중단)claude-haiku-4-5-20251001)API 동작은 Claude Sonnet 3.7과 Claude 4 모델 간에 다르지만, API 형태는 정확히 동일합니다.
자세한 내용은 모델 버전 간 사고의 차이점을 참조하세요.
확장 사고가 켜지면, Claude는 내부 추론을 출력하는 thinking 콘텐츠 블록을 생성합니다. Claude는 이 추론의 통찰을 반영한 후 최종 응답을 작성합니다.
API 응답에는 thinking 콘텐츠 블록이 포함되고, 그 뒤에 text 콘텐츠 블록이 따릅니다.
다음은 기본 응답 형식의 예시입니다:
{
"content": [
{
"type": "thinking",
"thinking": "Let me analyze this step by step...",
"signature": "WaUjzkypQ2mUEVM36O2TxuC06KN8xyfbJwyem2dw3URve/op91XWHOEBLLqIOMfFG/UvLEczmEsUjavL...."
},
{
"type": "text",
"text": "Based on my analysis..."
}
]
}확장 사고의 응답 형식에 대한 자세한 내용은 Messages API 레퍼런스를 참조하세요.
다음은 Messages API에서 확장 사고를 사용하는 예시입니다:
curl https://api.anthropic.com/v1/messages \
--header "x-api-key: $ANTHROPIC_API_KEY" \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--data \
'{
"model": "claude-sonnet-4-5",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{
"role": "user",
"content": "Are there an infinite number of prime numbers such that n mod 4 == 3?"
}
]
}'확장 사고를 켜려면, type 파라미터를 enabled로 설정하고 budget_tokens를 확장 사고를 위한 지정된 토큰 예산으로 설정한 thinking 객체를 추가하세요. Claude Opus 4.6의 경우, type: "adaptive"를 대신 사용하는 것을 권장합니다 — 자세한 내용은 적응형 사고를 참조하세요. type: "enabled"와 budget_tokens는 Opus 4.6에서 여전히 지원되지만, 더 이상 사용되지 않으며 향후 릴리스에서 제거될 예정입니다.
budget_tokens 파라미터는 Claude가 내부 추론 과정에 사용할 수 있는 최대 토큰 수를 결정합니다. Claude 4 이후 모델에서 이 제한은 전체 사고 토큰에 적용되며, 요약된 출력에는 적용되지 않습니다. 더 큰 예산은 복잡한 문제에 대해 더 철저한 분석을 가능하게 하여 응답 품질을 향상시킬 수 있지만, 특히 32k 이상의 범위에서는 Claude가 할당된 전체 예산을 사용하지 않을 수 있습니다.
budget_tokens는 Claude Opus 4.6에서 더 이상 사용되지 않으며 향후 모델 릴리스에서 제거될 예정입니다. 사고 깊이를 제어하려면 effort 파라미터와 함께 적응형 사고를 사용하는 것을 권장합니다.
Claude Opus 4.6은 최대 128K 출력 토큰을 지원합니다. 이전 모델은 최대 64K 출력 토큰을 지원합니다.
budget_tokens는 max_tokens보다 작은 값으로 설정해야 합니다. 그러나 도구와 함께 인터리브 사고를 사용할 때는 토큰 제한이 전체 컨텍스트 윈도우(200k 토큰)가 되므로 이 제한을 초과할 수 있습니다.
With extended thinking enabled, the Messages API for Claude 4 models returns a summary of Claude's full thinking process. Summarized thinking provides the full intelligence benefits of extended thinking, while preventing misuse.
Here are some important considerations for summarized thinking:
Claude Sonnet 3.7 continues to return full thinking output.
In rare cases where you need access to full thinking output for Claude 4 models, contact our sales team.
서버 전송 이벤트(SSE)를 사용하여 확장 사고 응답을 스트리밍할 수 있습니다.
확장 사고에 대해 스트리밍이 활성화되면, thinking_delta 이벤트를 통해 사고 콘텐츠를 수신합니다.
Messages API를 통한 스트리밍에 대한 자세한 문서는 스트리밍 Messages를 참조하세요.
다음은 사고와 함께 스트리밍을 처리하는 방법입니다:
curl https://api.anthropic.com/v1/messages \
--header "x-api-key: $ANTHROPIC_API_KEY" \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--data \
'{
"model": "claude-sonnet-4-5",
"max_tokens": 16000,
"stream": true,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{
"role": "user",
"content": "What is the greatest common divisor of 1071 and 462?"
}
]
}'스트리밍 출력 예시:
event: message_start
data: {"type": "message_start", "message": {"id": "msg_01...", "type": "message", "role": "assistant", "content": [], "model": "claude-sonnet-4-5", "stop_reason": null, "stop_sequence": null}}
event: content_block_start
data: {"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": ""}}
event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "I need to find the GCD of 1071 and 462 using the Euclidean algorithm.\n\n1071 = 2 × 462 + 147"}}
event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\n462 = 3 × 147 + 21\n147 = 7 × 21 + 0\n\nSo GCD(1071, 462) = 21"}}
// Additional thinking deltas...
event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "EqQBCgIYAhIM1gbcDa9GJwZA2b3hGgxBdjrkzLoky3dl1pkiMOYds..."}}
event: content_block_stop
data: {"type": "content_block_stop", "index": 0}
event: content_block_start
data: {"type": "content_block_start", "index": 1, "content_block": {"type": "text", "text": ""}}
event: content_block_delta
data: {"type": "content_block_delta", "index": 1, "delta": {"type": "text_delta", "text": "The greatest common divisor of 1071 and 462 is **21**."}}
// Additional text deltas...
event: content_block_stop
data: {"type": "content_block_stop", "index": 1}
event: message_delta
data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null}}
event: message_stop
data: {"type": "message_stop"}사고가 활성화된 상태에서 스트리밍을 사용할 때, 텍스트가 때때로 더 큰 청크로 도착하다가 더 작은 토큰 단위 전달과 번갈아 나타나는 것을 알 수 있습니다. 이는 특히 사고 콘텐츠에서 예상되는 동작입니다.
스트리밍 시스템은 최적의 성능을 위해 콘텐츠를 배치로 처리해야 하므로, 스트리밍 이벤트 사이에 지연이 발생할 수 있는 이러한 "청크" 전달 패턴이 나타날 수 있습니다. 사고 콘텐츠가 더 부드럽게 스트리밍되도록 하는 향후 업데이트에 초점을 맞추어 이 경험을 지속적으로 개선하고 있습니다.
확장 사고는 도구 사용과 함께 사용할 수 있어, Claude가 도구 선택 및 결과 처리를 통해 추론할 수 있습니다.
도구 사용과 함께 확장 사고를 사용할 때 다음 제한 사항에 유의하세요:
도구 선택 제한: 사고와 함께하는 도구 사용은 tool_choice: {"type": "auto"} (기본값) 또는 tool_choice: {"type": "none"}만 지원합니다. tool_choice: {"type": "any"} 또는 tool_choice: {"type": "tool", "name": "..."}를 사용하면 오류가 발생합니다. 이러한 옵션은 도구 사용을 강제하며, 이는 확장 사고와 호환되지 않습니다.
사고 블록 보존: 도구 사용 중에는 마지막 어시스턴트 메시지에 대해 thinking 블록을 API에 다시 전달해야 합니다. 추론의 연속성을 유지하기 위해 완전하고 수정되지 않은 블록을 API에 포함하세요.
도구 사용 루프를 포함하여 어시스턴트 턴 중간에 사고를 전환할 수 없습니다. 전체 어시스턴트 턴은 단일 사고 모드에서 작동해야 합니다:
모델의 관점에서, 도구 사용 루프는 어시스턴트 턴의 일부입니다. 어시스턴트 턴은 Claude가 여러 도구 호출과 결과를 포함할 수 있는 전체 응답을 완료할 때까지 완료되지 않습니다.
예를 들어, 이 시퀀스는 모두 단일 어시스턴트 턴의 일부입니다:
User: "What's the weather in Paris?"
Assistant: [thinking] + [tool_use: get_weather]
User: [tool_result: "20°C, sunny"]
Assistant: [text: "The weather in Paris is 20°C and sunny"]여러 API 메시지가 있더라도, 도구 사용 루프는 개념적으로 하나의 연속적인 어시스턴트 응답의 일부입니다.
턴 중간 사고 충돌이 발생하면(예: 도구 사용 루프 중에 사고를 켜거나 끄는 경우), API는 해당 요청에 대해 자동으로 사고를 비활성화합니다. 모델 품질을 보존하고 분포 내에 유지하기 위해, API는 다음을 수행할 수 있습니다:
이는 턴 중간에 사고를 전환하려고 해도 오류가 발생하지 않지만, 해당 요청에 대해 사고가 조용히 비활성화됨을 의미합니다. 사고가 활성화되었는지 확인하려면 응답에서 thinking 블록의 존재를 확인하세요.
모범 사례: 턴 중간에 전환하려고 하지 말고 각 턴 시작 시 사고 전략을 계획하세요.
예시: 턴 완료 후 사고 전환
User: "What's the weather?"
Assistant: [tool_use] (thinking disabled)
User: [tool_result]
Assistant: [text: "It's sunny"]
User: "What about tomorrow?"
Assistant: [thinking] + [text: "..."] (thinking enabled - new turn)어시스턴트 턴을 완료한 후 사고를 전환하면, 새 요청에 대해 사고가 실제로 활성화되도록 보장할 수 있습니다.
사고 모드를 전환하면 메시지 기록에 대한 프롬프트 캐싱도 무효화됩니다. 자세한 내용은 프롬프트 캐싱과 함께하는 확장 사고 섹션을 참조하세요.
도구 사용 중에는 thinking 블록을 API에 다시 전달해야 하며, 완전하고 수정되지 않은 블록을 API에 포함해야 합니다. 이는 모델의 추론 흐름과 대화 무결성을 유지하는 데 중요합니다.
이전 assistant 역할 턴에서 thinking 블록을 생략할 수 있지만, 다중 턴 대화에서는 항상 모든 사고 블록을 API에 다시 전달하는 것을 권장합니다. API는:
대화 중 사고 모드를 전환할 때, 전체 어시스턴트 턴(도구 사용 루프 포함)이 단일 사고 모드에서 작동해야 함을 기억하세요. 자세한 내용은 대화에서 사고 모드 전환을 참조하세요.
Claude가 도구를 호출할 때, 외부 정보를 기다리기 위해 응답 구성을 일시 중지합니다. 도구 결과가 반환되면, Claude는 기존 응답을 계속 구축합니다. 이로 인해 도구 사용 중 사고 블록을 보존해야 하며, 그 이유는 다음과 같습니다:
추론 연속성: 사고 블록은 도구 요청으로 이어진 Claude의 단계별 추론을 캡처합니다. 도구 결과를 게시할 때, 원래 사고를 포함하면 Claude가 중단한 곳에서 추론을 계속할 수 있습니다.
컨텍스트 유지: 도구 결과는 API 구조에서 사용자 메시지로 나타나지만, 연속적인 추론 흐름의 일부입니다. 사고 블록을 보존하면 여러 API 호출에 걸쳐 이 개념적 흐름이 유지됩니다. 컨텍스트 관리에 대한 자세한 내용은 컨텍스트 윈도우 가이드를 참조하세요.
중요: thinking 블록을 제공할 때, 연속된 thinking 블록의 전체 시퀀스는 원래 요청 중에 모델이 생성한 출력과 일치해야 합니다. 이러한 블록의 시퀀스를 재배열하거나 수정할 수 없습니다.
Claude 4 모델에서 도구 사용과 함께하는 확장 사고는 인터리브 사고를 지원하며, 이를 통해 Claude가 도구 호출 사이에 사고하고 도구 결과를 받은 후 더 정교한 추론을 할 수 있습니다.
인터리브 사고를 통해 Claude는:
Claude Opus 4.6의 경우, 적응형 사고를 사용할 때 인터리브 사고가 자동으로 활성화됩니다 — 베타 헤더가 필요하지 않습니다.
Claude 4 모델의 경우, API 요청에 베타 헤더 interleaved-thinking-2025-05-14를 추가하여 인터리브 사고를 활성화하세요.
인터리브 사고에 대한 몇 가지 중요한 고려 사항은 다음과 같습니다:
budget_tokens는 max_tokens 파라미터를 초과할 수 있습니다. 이는 하나의 어시스턴트 턴 내 모든 사고 블록에 걸친 총 예산을 나타내기 때문입니다.interleaved-thinking-2025-05-14가 필요합니다.interleaved-thinking-2025-05-14를 전달할 수 있으며, 효과는 없습니다.interleaved-thinking-2025-05-14를 전달하면 요청이 실패합니다.사고와 함께하는 프롬프트 캐싱에는 몇 가지 중요한 고려 사항이 있습니다:
확장 사고 작업은 완료하는 데 5분 이상 걸리는 경우가 많습니다. 더 긴 사고 세션과 다단계 워크플로에서 캐시 히트를 유지하려면 1시간 캐시 지속 시간을 사용하는 것을 고려하세요.
사고 블록 컨텍스트 제거
캐시 무효화 패턴
확장된 사고를 도구 사용과 함께 사용할 때, 사고 블록은 토큰 계산에 영향을 미치는 특정 캐싱 동작을 보입니다:
작동 방식:
상세 예시 흐름:
요청 1:
User: "파리 날씨가 어때?"응답 1:
[thinking_block_1] + [tool_use block 1]요청 2:
User: ["파리 날씨가 어때?"],
Assistant: [thinking_block_1] + [tool_use block 1],
User: [tool_result_1, cache=True]응답 2:
[thinking_block_2] + [text block 2]요청 2는 요청 내용(응답이 아닌)의 캐시를 기록합니다. 캐시에는 원래 사용자 메시지, 첫 번째 사고 블록, 도구 사용 블록, 그리고 도구 결과가 포함됩니다.
요청 3:
User: ["파리 날씨가 어때?"],
Assistant: [thinking_block_1] + [tool_use block 1],
User: [tool_result_1, cache=True],
Assistant: [thinking_block_2] + [text block 2],
User: [Text response, cache=True]Claude Opus 4.5 이후 모델(Claude Opus 4.6 포함)의 경우, 이전의 모든 사고 블록이 기본적으로 유지됩니다. 이전 모델의 경우, 도구 결과가 아닌 사용자 블록이 포함되었기 때문에 이전의 모든 사고 블록이 무시됩니다. 이 요청은 다음과 동일하게 처리됩니다:
User: ["파리 날씨가 어때?"],
Assistant: [tool_use block 1],
User: [tool_result_1, cache=True],
Assistant: [text block 2],
User: [Text response, cache=True]핵심 사항:
cache_control 마커 없이도 자동으로 발생합니다이전 Claude 모델(Claude Sonnet 3.7 이전)에서는 프롬프트 토큰과 max_tokens의 합이 모델의 컨텍스트 윈도우를 초과하면, 시스템이 자동으로 max_tokens를 컨텍스트 제한에 맞게 조정했습니다. 이는 큰 max_tokens 값을 설정해도 시스템이 필요에 따라 자동으로 줄여주었다는 의미입니다.
Claude 3.7 및 4 모델에서는 max_tokens(사고가 활성화된 경우 사고 예산 포함)가 엄격한 제한으로 적용됩니다. 이제 프롬프트 토큰 + max_tokens가 컨텍스트 윈도우 크기를 초과하면 시스템이 유효성 검사 오류를 반환합니다.
더 자세한 내용은 컨텍스트 윈도우 가이드를 참조하세요.
사고가 활성화된 상태에서 컨텍스트 윈도우 사용량을 계산할 때 알아야 할 고려 사항이 있습니다:
max_tokens 제한에 포함됩니다아래 다이어그램은 확장된 사고가 활성화된 경우의 특수한 토큰 관리를 보여줍니다:
유효 컨텍스트 윈도우는 다음과 같이 계산됩니다:
context window =
(current input tokens - previous thinking tokens) +
(thinking tokens + encrypted thinking tokens + text output tokens)특히 사고가 포함된 다중 턴 대화를 작업할 때 정확한 토큰 수를 얻으려면 토큰 계산 API를 사용하는 것을 권장합니다.
확장된 사고를 도구 사용과 함께 사용할 때, 사고 블록은 명시적으로 보존되어 도구 결과와 함께 반환되어야 합니다.
확장된 사고와 도구 사용에 대한 유효 컨텍스트 윈도우 계산은 다음과 같습니다:
context window =
(current input tokens + previous thinking tokens + tool use tokens) +
(thinking tokens + encrypted thinking tokens + text output tokens)아래 다이어그램은 확장된 사고와 도구 사용에 대한 토큰 관리를 보여줍니다:
확장된 사고가 포함된 Claude 3.7 및 4 모델의 컨텍스트 윈도우 및 max_tokens 동작을 고려하면, 다음이 필요할 수 있습니다:
max_tokens 값 조정이 변경은 특히 최대 토큰 제한이 크게 증가함에 따라 더 예측 가능하고 투명한 동작을 제공하기 위해 이루어졌습니다.
Full thinking content is encrypted and returned in the signature field. This field is used to verify that thinking blocks were generated by Claude when passed back to the API.
It is only strictly necessary to send back thinking blocks when using tools with extended thinking. Otherwise you can omit thinking blocks from previous turns, or let the API strip them for you if you pass them back.
If sending back thinking blocks, we recommend passing everything back as you received it for consistency and to avoid potential issues.
Here are some important considerations on thinking encryption:
signature_delta inside a content_block_delta event just before the content_block_stop event.signature values are significantly longer in Claude 4 models than in previous models.signature field is an opaque field and should not be interpreted or parsed - it exists solely for verification purposes.signature values are compatible across platforms (Claude APIs, Amazon Bedrock, and Vertex AI). Values generated on one platform will be compatible with another.Occasionally Claude's internal reasoning will be flagged by our safety systems. When this occurs, we encrypt some or all of the thinking block and return it to you as a redacted_thinking block. redacted_thinking blocks are decrypted when passed back to the API, allowing Claude to continue its response without losing context.
When building customer-facing applications that use extended thinking:
Here's an example showing both normal and redacted thinking blocks:
{
"content": [
{
"type": "thinking",
"thinking": "Let me analyze this step by step...",
"signature": "WaUjzkypQ2mUEVM36O2TxuC06KN8xyfbJwyem2dw3URve/op91XWHOEBLLqIOMfFG/UvLEczmEsUjavL...."
},
{
"type": "redacted_thinking",
"data": "EmwKAhgBEgy3va3pzix/LafPsn4aDFIT2Xlxh0L5L8rLVyIwxtE3rAFBa8cr3qpPkNRj2YfWXGmKDxH4mPnZ5sQ7vB9URj2pLmN3kF8/dW5hR7xJ0aP1oLs9yTcMnKVf2wRpEGjH9XZaBt4UvDcPrQ..."
},
{
"type": "text",
"text": "Based on my analysis..."
}
]
}Seeing redacted thinking blocks in your output is expected behavior. The model can still use this redacted reasoning to inform its responses while maintaining safety guardrails.
If you need to test redacted thinking handling in your application, you can use this special test string as your prompt: ANTHROPIC_MAGIC_STRING_TRIGGER_REDACTED_THINKING_46C9A13E193C177646C7398A98432ECCCE4C1253D5E2D82641AC0E52CC2876CB
When passing thinking and redacted_thinking blocks back to the API in a multi-turn conversation, you must include the complete unmodified block back to the API for the last assistant turn. This is critical for maintaining the model's reasoning flow. We suggest always passing back all thinking blocks to the API. For more details, see the Preserving thinking blocks section.
Messages API는 Claude Sonnet 3.7과 Claude 4 모델에서 사고를 다르게 처리하며, 주로 수정 및 요약 동작에서 차이가 있습니다.
아래 표에서 간략한 비교를 확인하세요:
| 기능 | Claude Sonnet 3.7 | Claude 4 모델 (Opus 4.5 이전) | Claude Opus 4.5 | Claude Opus 4.6 (적응형 사고) |
|---|---|---|---|---|
| 사고 출력 | 전체 사고 출력 반환 | 요약된 사고 반환 | 요약된 사고 반환 | 요약된 사고 반환 |
| 인터리브 사고 | 지원되지 않음 | interleaved-thinking-2025-05-14 베타 헤더로 지원 | interleaved-thinking-2025-05-14 베타 헤더로 지원 | 적응형 사고로 자동 지원 (베타 헤더 불필요) |
| 사고 블록 보존 | 턴 간 보존되지 않음 | 턴 간 보존되지 않음 | 기본적으로 보존됨 | 기본적으로 보존됨 |
Claude Opus 4.5부터 (Claude Opus 4.6 포함), 이전 어시스턴트 턴의 사고 블록이 기본적으로 모델 컨텍스트에 보존됩니다. 이는 이전 턴의 사고 블록을 제거하는 이전 모델과 다릅니다.
사고 블록 보존의 이점:
중요 고려 사항:
이전 모델(Claude Sonnet 4.5, Opus 4.1 등)의 경우, 이전 턴의 사고 블록은 계속해서 컨텍스트에서 제거됩니다. 프롬프트 캐싱을 사용한 확장된 사고 섹션에 설명된 기존 동작이 해당 모델에 적용됩니다.
For complete pricing information including base rates, cache writes, cache hits, and output tokens, see the pricing page.
The thinking process incurs charges for:
When extended thinking is enabled, a specialized system prompt is automatically included to support this feature.
When using summarized thinking:
The billed output token count will not match the visible token count in the response. You are billed for the full thinking process, not the summary you see.
max_tokens가 21,333보다 클 때 스트리밍을 요구합니다. 이는 클라이언트 측 유효성 검사이며 API 제한이 아닙니다. 이벤트를 점진적으로 처리할 필요가 없다면, .stream()과 .get_final_message() (Python) 또는 .finalMessage() (TypeScript)를 사용하여 개별 이벤트를 처리하지 않고 완전한 Message 객체를 얻을 수 있습니다 — 자세한 내용은 스트리밍 메시지를 참조하세요. 스트리밍 시, 사고 및 텍스트 콘텐츠 블록이 도착하는 대로 처리할 준비를 하세요.temperature 또는 top_k 수정 및 강제 도구 사용과 호환되지 않습니다.top_p를 1에서 0.95 사이의 값으로 설정할 수 있습니다.Was this page helpful?