tiktoken을 사용하지 않고 Claude의 정확한 토큰 수를 세는 방법을 설명합니다.
Claude의 비용 추정에서 tiktoken을 사용하면 잘못된 결과가 나올 수 있습니다. Claude는 OpenAI 모델과 다른 토크나이저를 사용하여, 텍스트를 토큰으로 나누는 방식이 다릅니다. 이는 영어 텍스트에서 15-20%의 오차를 발생시킵니다. 올바른 방법은 Claude의 전용 count_tokens 엔드포인트를 사용하는 것입니다.
Describes the correct way to count tokens for Claude without using tiktoken.
Using tiktoken for cost estimation in Claude can lead to significant inaccuracies due to differing tokenization methods. Claude uses its own tokenizer, which can undercount tokens by 15-20% compared to OpenAI's tiktoken, especially with non-English text or code. The proper method involves using Claude's dedicated count_tokens endpoint for accurate token counts.