-
Notifications
You must be signed in to change notification settings - Fork 937
Open
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issueservice:bedrock-runtime
Description
Describe the bug
There is very little information about the new token counting feature for Bedrock. It seems to work for basic text, which is cute, but the difficult part is documents, and it doesn't work for any kind of documents. I know that Claude 4 supports token counting, at least through their API, but Bedrock is throwing an exception.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
I expect token counting to work for Claude 4, including documents such as txt, md, doc, docx, csv, xls, xlsx, pdf.
Current Behavior
Exception for any document: "Document input not supported for token counting".
Reproduction Steps
bedrockRuntimeClient.countTokens({
it.modelId('anthropic.claude-sonnet-4-20250514-v1:0')
it.input({
it.converse {
it.messages([
Message.builder()
.content([
ContentBlock.fromDocument({
it.name('document')
it.source {
it.text('text')
}
})
])
.role(ConversationRole.USER)
.build()
])
}
})
}).inputTokens()
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.32.29
JDK version used
11
Operating System and version
MacOS 15.0.1
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issueservice:bedrock-runtime